SlideShare uma empresa Scribd logo
1 de 62
Baixar para ler offline
ColdFusion Summit 2016
Dependency Injection:
Why is it awesome
and why should I care?
Nolan Erck
About Me
Consultant (southofshasta.com)
Software Development, Training, Design
Tools I use: ColdFusion, C++, Java, jQuery, PHP, .NET, HTML5,
Android, SQL, you get the idea...
Manager of SacInteractive User Group
Reformed Video Game Developer (Grim Fandango, SimPark,
StarWars Rogue Squadron, etc).
Music Junkie
Title Slide
Title Slide
‱ Text ‱ Text
Title Slide
‱ Text ‱ Text
Today’s Agenda
What is Dependency Injection?
When/why do I want it in my projects?
Intro to Bean Management
Intro to Inversion of Control (IOC)
Intro to Aspect Oriented Programming (AOP)
Other info
Questions
Prerequisites
Have some experience building classes and
objects.
Don't need to be an expert.
Don't need to have used an MVC framework.
D/I frameworks can be totally separate.
And 1 more thing you need to know...
Prerequisites
Know that Object Oriented Programming is hard.
And some of it is confusing at first.
And that's NORMAL.
What Is Dependency Injection?
What Is Dependency Injection?
A “design pattern”
$6 phrase for “a way to organize your classes so they work together in
a flexible way”.
Like a for() loop, if(), array[]
Reusable technique, based around objects.
There are lots of design patterns:
Dependency Injection is 1 design pattern
Inversion of Control (IOC), Aspect Oriented Programming (AOP) and
Bean Management are all “variations on that theme”.
There are lots of others too.
What Is Dependency Injection?
It's not platform specific.
Available for ColdFusion, Java, .NET, JavaScript, etc.
For today's preso:
Using mostly pseudocode / concepts.
No specific code samples.
Some keywords will change.
All the concepts work the same across libraries and languages.
When / Why Use D/I?
Short answer:
When you have lots of classes that talk to each other,
want to keep code organized, and make it easy to swap
different “types” of objects in/out of your application.
When / Why Use D/I?
Short answer:
When you have lots of classes that talk to each other,
want to keep code organized, and make it easy to swap
different “types” of objects in/out of your application.
Longer answer:
That's what the rest of the slides are for...
Does this mean

I have to rebuild my entire app to use D/I?
No. But you might get more benefits if you make a few changes to
legacy code along the way.
I have to learn a new way to code all my classes?
No. You can leave everything as-is.
The nice thing about D/I is you can use it or not use it. If you want to
write code the “old way” in part of your app, there's nothing stopping
you from doing so. It will all still work as-is.
Neat huh? Let's learn a bit more, shall we?
Bean Management
What’s a Bean?
A “thing” your D/I framework knows about.
class User{ 
 }
class DateUtils {
}
In your DI framework:
bean id=”myUser” class=”User”
bean id=”myDateUtils” class=”DateUtils”
(Exact syntax varies between DI libraries.)
Bean Management - First Example
MailService.cfc
<cfcomponent>
<cffunction name=”sendEmail”>
<cfargument name=”from”>
<cfargument name=”to”>
<cfagument name=”body”>
[ code for sending the email ]
</cffunction>
</cfcomponent>
Usage:
myMailService = CreateObject( “MailService” );
myMailService.sendEmail( to=”...”, from=”...”, body=”...” );
Bean Management - First Example
myMailSvc = DILibrary.getBean( “MailService” );
myMailSvc.sendEmail( to=”...”,
from=”...”,
body=”...” );
Cute, but we haven't gained anything yet.
CreateObject() was 1 line of code – DI.getBean() is 1 line if code.
No real improvements, but this is an easy way to start using DI:
Remove calls to CreateObject(), replace with calls to the DI library.
Bean Management
class A {
public class A() {...}
}
class B{
public class B(A a)
{ 
 }
}
class C {
public class C(B b)
{ 
 }
}
class D{
public class D(C c)
{...}
}
So if I -JUST- want a D object made...
Bean Management
I have to do all this...
A a = new A();
B b = new B( a );
C c = new C( b );
D d = new D( c );
4 lines of code.
The first 3 are “boilerplate” to create the variables I need to make a D.
Multiply that out over all the objects in your app...
= a LOT of boilerplate code!
Another way to say it:
“D depends on A, B and C being made first”.
Bean Management
With a D/I library that does Bean Management, you'd write something like
this instead...
D d = ColdSpring.getBean( “D” );
4 lines of code just became 1. And no more boilerplate stuff!
You tell your D/I framework “I need a D. Go find out what D depends on,
make those as needed, and hand me back D when you're done.”
(“ColdSpring” is a placeholder here for any D/I framework. They all work
about the same.)
Bean Management
Quasi Real World Example.
Mailing department wide messages.
Mail Service CFC
‱ Needs a Department CFC to know which Department is being
emailed.
‱ Department needs a Department DAO for it's SQL stuff.
‱ And a SecurityLogin CFC to make sure it's validated/logged in/
whatever.
Bean Management
Old Way
mySecLogin = CreateObject( “component”, “SecurityLogin”);
myDeptDAO = CreateObject(“component”,“DepartmentDAO”);
dept = CreateObject( “component”, “Department” );
dept.init( mySecLogin, myDeptDAO );
mailSvc = CreateObject( “component”, “MailService” );
mailSvc.init( dept );
mailSvc.sendEmail();
Bean Management
New Way
WireBox.getBean( “mailService” ).sendMail();
Bean Management
New Way
WireBox.getBean( “mailService” ).sendMail();
Yes, 1 line of code.
Yes, it is THAT easy.
(I'm over simplifying a little.)
Bean Management
So how does the D/I framework “know” that I need an A, B and C to make a D
object?
Varies a little from framework to framework.
Configuration based:
XML file that “describes” the relationship between the objects.
(ColdSpring, Spring)
Nice for, say, white-box testing w/ hands-on QA team.
Convention based:
Works automatically by which folders you store classes in, and how the
classes are named. (DI/1, WireBox)
Just pick one and try it out, they all do the same core “things”.
Inversion of Control (IOC)
Inversion of Control (IOC)
Fancy term for “flipping” some code around from the
“traditional” or “normal” way you'd build objects.
Instead of building an Employee object, then a Department
object, then putting the Employee IN the Department.
You say “get me a fully populated/constructed Department”.
Magic happens, automatically building the Employee object for
you.
Inversion of Control (IOC)
class RockGroup
{
private String groupName;
public String getGroupName(){
return groupName;
}
public void setGroupName(String name) {
this.groupName = name;
}
}
No Constructor.
“groupName” is private.
So we have to call the
setter to initialize the
variable with something.
Inversion of Control (IOC)
With regular code, we'd do this:
String myBandName = “Depeche Mode”;
RockGroup rg = new RockGroup();
rg.setGroupName( myBandName );
That works but...
Every time I want to provide a different default value, I have to
change code, and recompile.
Inversion of Control (IOC)
What if we could provide that default value in a “config file”,
outside of code?
And whenever we create a RockGroup object, it automatically gets
a default value for groupName passed in at that instant?
You can!
Inversion of Control (IOC)
Using a D/I framework, you can have a “config” that notes default values for
your classes:
<class name=”RockGroup”>
<property name=”groupName” value=”Depeche Mode”/>
</class>
rg = ColdSpring.getBean( “RockGroup” )
...any time I make a RockGroup, it will automatically initialize the
“groupName” variable to the default value I provided. No extra lines of
code. And changing this default is now done in a config file. No recompiling
code to change it!
Inversion of Control (IOC)
What about classes inside of other classes?
AKA “Composition”, the “has a” relationship.
Kind of the same thing...
Inversion of Control (IOC)
class RockGroup{
private String groupName;
public String getGroupName(){ 
 }
public void setGroupName( String name )
{
}
private Musician singer;
public Musician getSinger(){ 
 }
public void setSinger( Musician m ) {
}
}
class Musician{
private String name;
private int yearsSober;
private int age;
public String getName() { return name; }
public void setName(String n){ this.name = n; }
public int getYearsSober() { 
 }
public void setYearsSober(int y) { 
 }
public void setAge( int a ){
}
public int getAge(){ return age; }
}
Inversion of Control (IOC)
With straight code...
Musician m = new Musician();
m.name = “George Harrison”;
m.age = 64;
m.yearsSober = 10;
RockGroup rg = new RockGroup();
rg.setGroupName( “The Beatles” );
rg.setMusician( m );
Inversion of Control (IOC)
With D/I...
RockGroup rg = Spring.getBean(“RockGroup”);
Inversion of Control (IOC)
The Musician class has a String property, that gets initialized just like
the String property in RockGroup. Ditto for the “int” properties, etc:
Spring.getBean( “Musician” );
“name” will always be whatever is in my config for the Musician class.
<class name=”Musician”>
<property name=”name” value=”George Harrison” />
<property name=”age” value=”64” />
<property name=”yearsSober” value=”10” />
</class>
Inversion of Control (IOC)
You can also refer to other classes in the config, and “inject” them into each
other, just like we “injected” the String and int into Musician:
<class name=”Musician” id=”drummerBean1”>
<property name=”name” value=”Pete Best” />
<property name=”yearsSober” value=”10” />
<property name=”age” value=”64” />
</class>
<class name=”RockGroup”>
<property name=”groupName” value=”The Beatles” />
<property name=”drummer” ref=”drummerBean1” />
</class>
Inversion of Control (IOC)
So now when I do this...
rg = DIFramework.getBean( “RockGroup” );
rg will be fully constructed

‱ It will have a “groupName” property set to “The Beatles”.
‱ It will have a “drummer” property set to “Pete Best”, he'll be 64 years
old and 10 years sober.
‱ 1 line of code, no boilerplate stuff.
‱ If I want to change those defaults, I don't have to recompile, I just
change a “config” setting.
Inversion of Control (IOC)
Swapping out one type of Musician for another doesn't require
recompiling code, just change a config:
<class name=”Drummer” id=”drummerBean1”>
<property name=”name” value=”Pete Best” />
<property name=”yearsSober” value=”10” />
<property name=”age” value=”55” />
</class>
<class name=”RockGroup”>
<property name=”groupName” value=”The Beatles” />
<property name=”drummer” ref=”drummerBean1” />
</class>
Inversion of Control (IOC)
Swapping out one type of Musician for another doesn't require
recompiling code, just change a config:
<class name=”Drummer” id=”drummerBean2”>
<property name=”name” value=”Ringo Starr” />
<property name=”yearsSober” value=”22” />
<property name=”age” value=”57” />
</class>
<class name=”RockGroup”>
<property name=”groupName” value=”The Beatles” />
<property name=”drummer” ref=”drummerBean2” />
</class>
Inversion of Control (IOC)
Swapping out one type of Musician for another doesn't require
recompiling code, just change a config:
<class name=”Drummer” id=”drummerBean2”>
<property name=”name” value=”Ringo Starr” />
<property name=”yearsSober” value=”22” />
<property name=”age” value=”57” />
</class>
<class name=”RockGroup”>
<property name=”groupName” value=”The Beatles” />
<property name=”drummer” ref=”drummerBean2” />
</class> Off topic: discussing if Pete is better/worse than Ringo.
Aspect Oriented Programming (AOP)
Aspect Oriented Programming (AOP)
AKA “Cross Cutting”.
Change the “aspect” of how a function is called.
Say I have a foo() method.
Any time foo() is called...
Automatically...
Call code before or after foo()
Wrap some sort of code “around” foo()
e.g. try/catch blocks
It no longer just does “foo()”.
Also does whatever you define as an aspect of calling foo().
Aspect Oriented Programming (AOP)
Example: drawSalesReport()
In your AOP library:
<func name=”drawSalesReport”>
<aspect before run=”checkIfLoggedIn” />
<aspect after run=”saveToDebugLogFile” />
</func>
Aspect Oriented Programming (AOP)
In your code, it USED to look like this:
checkIfLoggedIn();
drawSalesReport( UserID=555,
dtCreated='1/1/2015' );
SaveToDebugLogFile();
What happens now is...
DIFramework.runWithAdvice( “drawSalesReport”,
{ UserID=555,
dtCreated='1/1/2015' } );
and that does all 3 things, in correct order.
Aspect Oriented Programming (AOP)
But wait, there's more!
Can also wrap “blocks” of code around each other, not just
function calls before/after each other.
e.g. try/catch blocks.
Aspect Oriented Programming (AOP)
Say I have a query like so:
<cfquery name=”qryGetUsers”>
SELECT * FROM Users
</cfquery>
In Production, I want that wrapped in a try/catch, but in QA/
Development, I don't. (So I can see the debug output, etc.)
Aspect Oriented Programming (AOP)
I'd have to set some kind of “flag”:
<cfif isProduction>
<cftry>
<cfquery name=”qryGetUsers”>
SELECT * FROM Users
</cfquery>
<cfcatch> <cflog 
 /> </cfcatch>
</cftry>
<cfelse>
<cfquery name=”qryGetUsers”>
SELECT * FROM Users
</cfquery>
</cfif>
Duplicate Code!
Remember the DRY rule!
Aspect Oriented Programming (AOP)
Instead of calling a getUsers() method directly:
GetUsers();
In your AOP library:
<advice around functionName=”getUsersWithAdvice”>
<method name=”getUsers” />
</advice>
Aspect Oriented Programming (AOP)
<advice around functionName=”getUsersWithAdvice”>
<method name=”getUsers” />
</advice>
function getUsersWithAdvice( funcToRun ) {
if( isProduction ) {
try{
#funcToRun#();
}
catch{ 
 }
}else{
#funcToRun#();
}
}
Aspect Oriented Programming (AOP)
In your code:
DIFramework.runWithAdvice( “getUsers” );
The if() statement is still there but our duplicate SQL is gone!
Aspect Oriented Programming (AOP)
Can also use it for

SaaS feature flags - turn on functionality only when a customer
pays for it. No need to edit code, just toggle a config.
Swap out 3rd party/vendor integrations easily.
Cranky vendor: “it will take you months to remove our tech from
your product.”
App with AOP: No, actually it will take me 5 minutes
So what’s the catch?
A new way of thinking about how you build your classes.
Takes some getting used to.
A little extra “set up” work.
Naming conventions, or typing some XML.
Debugging errors can be slower at first due to learning curve.

but

So what’s the catch?

but

It makes your code more reusable

More flexible

Easier to test

Easier to turn features (aka “aspects”) on/off easily

So what’s the catch?
“But now I have tons of files in my app!”
So what?
Breathe.
Use version control to keep them safe.
Each file does “1 thing”. Easy to know which file you’ll need to
edit.
Remember

You don't have to do this all at once.
Start with (for example) Bean Management.
Add other bits as you get comfortable.
It's not like an MVC framework where the whole app has to be
considered.
Find 1 tiny spot in your app, add a little DI there.
Add more in increments, go as you learn.
Also Remember

Object-Oriented Programming is hard.
It's different than Procedural code.
Takes getting used to.
That's NORMAL.
Nobody learns all this stuff instantly.
It takes some time.
(But it is the way many languages are going these days.)
Other Resources
Book: Spring In Action (Java)
Book: Head First Design Patterns
Framework/1, DI/1 and AOP/1
ColdSpring documentation
Good examples, not overwhelming.
SpringByExample.org
Java code, but explanation of the general concepts is pretty
good.
The ColdBox docs are also great for this too.
Those guys like to write!
Questions? Comments?
Ways to reach me...
Email: nolan@southofshasta.com
Twitter: @southofshasta
Blog: southofshasta.com
(Slides are on my website.)
Thanks!
Thank
you!

Mais conteĂșdo relacionado

Mais procurados

The Play Framework at LinkedIn
The Play Framework at LinkedInThe Play Framework at LinkedIn
The Play Framework at LinkedInYevgeniy Brikman
 
We Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentWe Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentAll Things Open
 
Crash Course in AngularJS + Ionic (Deep dive)
Crash Course in AngularJS + Ionic (Deep dive)Crash Course in AngularJS + Ionic (Deep dive)
Crash Course in AngularJS + Ionic (Deep dive)ColdFusionConference
 
Composable and streamable Play apps
Composable and streamable Play appsComposable and streamable Play apps
Composable and streamable Play appsYevgeniy Brikman
 
How do I Write Testable Javascript so I can Test my CF API on Server and Client
How do I Write Testable Javascript so I can Test my CF API on Server and ClientHow do I Write Testable Javascript so I can Test my CF API on Server and Client
How do I Write Testable Javascript so I can Test my CF API on Server and ClientColdFusionConference
 
Choosing the Right Framework for Running Docker Containers in Prod
Choosing the Right Framework for Running Docker Containers in ProdChoosing the Right Framework for Running Docker Containers in Prod
Choosing the Right Framework for Running Docker Containers in ProdJosh Padnick
 
Conquering AngularJS Limitations
Conquering AngularJS LimitationsConquering AngularJS Limitations
Conquering AngularJS LimitationsValeri Karpov
 
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017Ortus Solutions, Corp
 
3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION API3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION APIGavin Pickin
 
Testcontainers - Geekout EE 2017 presentation
Testcontainers - Geekout EE 2017 presentationTestcontainers - Geekout EE 2017 presentation
Testcontainers - Geekout EE 2017 presentationRichard North
 
cf.Objective() 2017 - Design patterns - Brad Wood
cf.Objective() 2017 - Design patterns - Brad Woodcf.Objective() 2017 - Design patterns - Brad Wood
cf.Objective() 2017 - Design patterns - Brad WoodOrtus Solutions, Corp
 
High Performance JavaScript 2011
High Performance JavaScript 2011High Performance JavaScript 2011
High Performance JavaScript 2011Nicholas Zakas
 
Testing Web Applications
Testing Web ApplicationsTesting Web Applications
Testing Web ApplicationsSeth McLaughlin
 
Gruntwork Executive Summary
Gruntwork Executive SummaryGruntwork Executive Summary
Gruntwork Executive SummaryYevgeniy Brikman
 
Capybara testing
Capybara testingCapybara testing
Capybara testingFutureworkz
 
Java 6 [Mustang] - Features and Enchantments
Java 6 [Mustang] - Features and Enchantments Java 6 [Mustang] - Features and Enchantments
Java 6 [Mustang] - Features and Enchantments Pavel Kaminsky
 
Using Play Framework 2 in production
Using Play Framework 2 in productionUsing Play Framework 2 in production
Using Play Framework 2 in productionChristian Papauschek
 

Mais procurados (20)

The Play Framework at LinkedIn
The Play Framework at LinkedInThe Play Framework at LinkedIn
The Play Framework at LinkedIn
 
Cfml features modern_coding
Cfml features modern_codingCfml features modern_coding
Cfml features modern_coding
 
We Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentWe Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End Development
 
Crash Course in AngularJS + Ionic (Deep dive)
Crash Course in AngularJS + Ionic (Deep dive)Crash Course in AngularJS + Ionic (Deep dive)
Crash Course in AngularJS + Ionic (Deep dive)
 
Composable and streamable Play apps
Composable and streamable Play appsComposable and streamable Play apps
Composable and streamable Play apps
 
How do I Write Testable Javascript so I can Test my CF API on Server and Client
How do I Write Testable Javascript so I can Test my CF API on Server and ClientHow do I Write Testable Javascript so I can Test my CF API on Server and Client
How do I Write Testable Javascript so I can Test my CF API on Server and Client
 
Dust.js
Dust.jsDust.js
Dust.js
 
Choosing the Right Framework for Running Docker Containers in Prod
Choosing the Right Framework for Running Docker Containers in ProdChoosing the Right Framework for Running Docker Containers in Prod
Choosing the Right Framework for Running Docker Containers in Prod
 
Conquering AngularJS Limitations
Conquering AngularJS LimitationsConquering AngularJS Limitations
Conquering AngularJS Limitations
 
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
 
3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION API3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION API
 
Testcontainers - Geekout EE 2017 presentation
Testcontainers - Geekout EE 2017 presentationTestcontainers - Geekout EE 2017 presentation
Testcontainers - Geekout EE 2017 presentation
 
cf.Objective() 2017 - Design patterns - Brad Wood
cf.Objective() 2017 - Design patterns - Brad Woodcf.Objective() 2017 - Design patterns - Brad Wood
cf.Objective() 2017 - Design patterns - Brad Wood
 
High Performance JavaScript 2011
High Performance JavaScript 2011High Performance JavaScript 2011
High Performance JavaScript 2011
 
Testing Web Applications
Testing Web ApplicationsTesting Web Applications
Testing Web Applications
 
Gruntwork Executive Summary
Gruntwork Executive SummaryGruntwork Executive Summary
Gruntwork Executive Summary
 
Capybara testing
Capybara testingCapybara testing
Capybara testing
 
Apache Ant
Apache AntApache Ant
Apache Ant
 
Java 6 [Mustang] - Features and Enchantments
Java 6 [Mustang] - Features and Enchantments Java 6 [Mustang] - Features and Enchantments
Java 6 [Mustang] - Features and Enchantments
 
Using Play Framework 2 in production
Using Play Framework 2 in productionUsing Play Framework 2 in production
Using Play Framework 2 in production
 

Destaque

API Economy, Realizing the Business Value of APIs
API Economy, Realizing the Business Value of APIsAPI Economy, Realizing the Business Value of APIs
API Economy, Realizing the Business Value of APIsColdFusionConference
 
ITB2016 - Integration testing in a modern world
ITB2016 - Integration testing in a modern worldITB2016 - Integration testing in a modern world
ITB2016 - Integration testing in a modern worldOrtus Solutions, Corp
 
RESTFul Tools For Lazy Experts - CFSummit 2016
RESTFul Tools For Lazy Experts - CFSummit 2016RESTFul Tools For Lazy Experts - CFSummit 2016
RESTFul Tools For Lazy Experts - CFSummit 2016Ortus Solutions, Corp
 
Ready? bootstrap. go! (cf objective 14 05-2014)
Ready? bootstrap. go! (cf objective 14 05-2014)Ready? bootstrap. go! (cf objective 14 05-2014)
Ready? bootstrap. go! (cf objective 14 05-2014)ColdFusionConference
 
2015 in tothebox-introtddbdd
2015 in tothebox-introtddbdd2015 in tothebox-introtddbdd
2015 in tothebox-introtddbddColdFusionConference
 
Building Multi-Tenant Saas Apps
Building  Multi-Tenant Saas AppsBuilding  Multi-Tenant Saas Apps
Building Multi-Tenant Saas AppsColdFusionConference
 
Load Balancing, Failover and Scalability with ColdFusion
Load Balancing, Failover and Scalability with ColdFusionLoad Balancing, Failover and Scalability with ColdFusion
Load Balancing, Failover and Scalability with ColdFusionColdFusionConference
 
My charts can beat up your charts
My charts can beat up your chartsMy charts can beat up your charts
My charts can beat up your chartsColdFusionConference
 
Workflows and Digital Signatures
Workflows and Digital SignaturesWorkflows and Digital Signatures
Workflows and Digital SignaturesColdFusionConference
 
Realtime with-websockets-2015
Realtime with-websockets-2015Realtime with-websockets-2015
Realtime with-websockets-2015ColdFusionConference
 
Powering GIS Operations with ColdFusion
Powering GIS Operations with ColdFusionPowering GIS Operations with ColdFusion
Powering GIS Operations with ColdFusionColdFusionConference
 
Building better SQL Server Databases
Building better SQL Server DatabasesBuilding better SQL Server Databases
Building better SQL Server DatabasesColdFusionConference
 
Multiply like rabbits with rabbit mq
Multiply like rabbits with rabbit mqMultiply like rabbits with rabbit mq
Multiply like rabbits with rabbit mqColdFusionConference
 
Building Software in a weekend
Building Software in a weekendBuilding Software in a weekend
Building Software in a weekendColdFusionConference
 

Destaque (20)

Cf ppt vsr
Cf ppt vsrCf ppt vsr
Cf ppt vsr
 
API Economy, Realizing the Business Value of APIs
API Economy, Realizing the Business Value of APIsAPI Economy, Realizing the Business Value of APIs
API Economy, Realizing the Business Value of APIs
 
ITB2016 - Integration testing in a modern world
ITB2016 - Integration testing in a modern worldITB2016 - Integration testing in a modern world
ITB2016 - Integration testing in a modern world
 
RESTFul Tools For Lazy Experts - CFSummit 2016
RESTFul Tools For Lazy Experts - CFSummit 2016RESTFul Tools For Lazy Experts - CFSummit 2016
RESTFul Tools For Lazy Experts - CFSummit 2016
 
Ready? bootstrap. go! (cf objective 14 05-2014)
Ready? bootstrap. go! (cf objective 14 05-2014)Ready? bootstrap. go! (cf objective 14 05-2014)
Ready? bootstrap. go! (cf objective 14 05-2014)
 
2015 in tothebox-introtddbdd
2015 in tothebox-introtddbdd2015 in tothebox-introtddbdd
2015 in tothebox-introtddbdd
 
Building Multi-Tenant Saas Apps
Building  Multi-Tenant Saas AppsBuilding  Multi-Tenant Saas Apps
Building Multi-Tenant Saas Apps
 
CFML Sessions For Dummies
CFML Sessions For DummiesCFML Sessions For Dummies
CFML Sessions For Dummies
 
Load Balancing, Failover and Scalability with ColdFusion
Load Balancing, Failover and Scalability with ColdFusionLoad Balancing, Failover and Scalability with ColdFusion
Load Balancing, Failover and Scalability with ColdFusion
 
My charts can beat up your charts
My charts can beat up your chartsMy charts can beat up your charts
My charts can beat up your charts
 
Workflows and Digital Signatures
Workflows and Digital SignaturesWorkflows and Digital Signatures
Workflows and Digital Signatures
 
Sql killedserver
Sql killedserverSql killedserver
Sql killedserver
 
Realtime with websockets
Realtime with websocketsRealtime with websockets
Realtime with websockets
 
Realtime with-websockets-2015
Realtime with-websockets-2015Realtime with-websockets-2015
Realtime with-websockets-2015
 
Powering GIS Operations with ColdFusion
Powering GIS Operations with ColdFusionPowering GIS Operations with ColdFusion
Powering GIS Operations with ColdFusion
 
Building better SQL Server Databases
Building better SQL Server DatabasesBuilding better SQL Server Databases
Building better SQL Server Databases
 
Multiply like rabbits with rabbit mq
Multiply like rabbits with rabbit mqMultiply like rabbits with rabbit mq
Multiply like rabbits with rabbit mq
 
Where is cold fusion headed
Where is cold fusion headedWhere is cold fusion headed
Where is cold fusion headed
 
Building Software in a weekend
Building Software in a weekendBuilding Software in a weekend
Building Software in a weekend
 
Preso slidedeck
Preso slidedeckPreso slidedeck
Preso slidedeck
 

Semelhante a Dependency Injection

Dependency Injection Why is it awesome and Why should I care?
Dependency Injection Why is it awesome and Why should I care?Dependency Injection Why is it awesome and Why should I care?
Dependency Injection Why is it awesome and Why should I care?ColdFusionConference
 
Dependency Injection: Why is awesome and why should I care?
Dependency Injection: Why is awesome and why should I care?Dependency Injection: Why is awesome and why should I care?
Dependency Injection: Why is awesome and why should I care?devObjective
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyDavid Padbury
 
The Ring programming language version 1.5.4 book - Part 15 of 185
The Ring programming language version 1.5.4 book - Part 15 of 185The Ring programming language version 1.5.4 book - Part 15 of 185
The Ring programming language version 1.5.4 book - Part 15 of 185Mahmoud Samir Fayed
 
Demystifying The Solid Works Api
Demystifying The Solid Works ApiDemystifying The Solid Works Api
Demystifying The Solid Works ApiRazorleaf Corporation
 
Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011Anton Arhipov
 
iOS Programming - MCV (Delegate/Protocols/Property&Syntax)
iOS Programming - MCV (Delegate/Protocols/Property&Syntax)iOS Programming - MCV (Delegate/Protocols/Property&Syntax)
iOS Programming - MCV (Delegate/Protocols/Property&Syntax)Oliver Lin
 
From Java to Kotlin - The first month in practice
From Java to Kotlin - The first month in practiceFrom Java to Kotlin - The first month in practice
From Java to Kotlin - The first month in practiceStefanTomm
 
Intro to OOP
Intro to OOPIntro to OOP
Intro to OOPGant Laborde
 
01 - Intro To Using Java
01 - Intro To Using Java01 - Intro To Using Java
01 - Intro To Using Javathewhiteafrican
 
Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)jeffz
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsJeff Durta
 
Rifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobotRifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobotTsai Tsung-Yi
 
The First C# Project Analyzed
The First C# Project AnalyzedThe First C# Project Analyzed
The First C# Project AnalyzedPVS-Studio
 
All of Javascript
All of JavascriptAll of Javascript
All of JavascriptTogakangaroo
 
Robots in Swift
Robots in SwiftRobots in Swift
Robots in SwiftJanie Clayton
 

Semelhante a Dependency Injection (20)

Dependency injectionpreso
Dependency injectionpresoDependency injectionpreso
Dependency injectionpreso
 
Dependency Injection Why is it awesome and Why should I care?
Dependency Injection Why is it awesome and Why should I care?Dependency Injection Why is it awesome and Why should I care?
Dependency Injection Why is it awesome and Why should I care?
 
Dependency Injection: Why is awesome and why should I care?
Dependency Injection: Why is awesome and why should I care?Dependency Injection: Why is awesome and why should I care?
Dependency Injection: Why is awesome and why should I care?
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
 
Koin Quickstart
Koin QuickstartKoin Quickstart
Koin Quickstart
 
The Ring programming language version 1.5.4 book - Part 15 of 185
The Ring programming language version 1.5.4 book - Part 15 of 185The Ring programming language version 1.5.4 book - Part 15 of 185
The Ring programming language version 1.5.4 book - Part 15 of 185
 
Java Performance Tuning
Java Performance TuningJava Performance Tuning
Java Performance Tuning
 
Demystifying The Solid Works Api
Demystifying The Solid Works ApiDemystifying The Solid Works Api
Demystifying The Solid Works Api
 
Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011
 
iOS Programming - MCV (Delegate/Protocols/Property&Syntax)
iOS Programming - MCV (Delegate/Protocols/Property&Syntax)iOS Programming - MCV (Delegate/Protocols/Property&Syntax)
iOS Programming - MCV (Delegate/Protocols/Property&Syntax)
 
From Java to Kotlin - The first month in practice
From Java to Kotlin - The first month in practiceFrom Java to Kotlin - The first month in practice
From Java to Kotlin - The first month in practice
 
Intro to OOP
Intro to OOPIntro to OOP
Intro to OOP
 
01 - Intro To Using Java
01 - Intro To Using Java01 - Intro To Using Java
01 - Intro To Using Java
 
Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
 
Rifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobotRifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobot
 
The First C# Project Analyzed
The First C# Project AnalyzedThe First C# Project Analyzed
The First C# Project Analyzed
 
All of Javascript
All of JavascriptAll of Javascript
All of Javascript
 
Robots in Swift
Robots in SwiftRobots in Swift
Robots in Swift
 

Mais de ColdFusionConference

Crafting ColdFusion Applications like an Architect
Crafting ColdFusion Applications like an ArchitectCrafting ColdFusion Applications like an Architect
Crafting ColdFusion Applications like an ArchitectColdFusionConference
 
Security And Access Control For APIS using CF API Manager
Security And Access Control For APIS using CF API ManagerSecurity And Access Control For APIS using CF API Manager
Security And Access Control For APIS using CF API ManagerColdFusionConference
 
Monetizing Business Models: ColdFusion and APIS
Monetizing Business Models: ColdFusion and APISMonetizing Business Models: ColdFusion and APIS
Monetizing Business Models: ColdFusion and APISColdFusionConference
 
Become a Security Rockstar with ColdFusion 2016
Become a Security Rockstar with ColdFusion 2016Become a Security Rockstar with ColdFusion 2016
Become a Security Rockstar with ColdFusion 2016ColdFusionConference
 
ColdFusion in Transit action
ColdFusion in Transit actionColdFusion in Transit action
ColdFusion in Transit actionColdFusionConference
 
Developer Insights for Application Upgrade to ColdFusion 2016
Developer Insights for Application Upgrade to ColdFusion 2016Developer Insights for Application Upgrade to ColdFusion 2016
Developer Insights for Application Upgrade to ColdFusion 2016ColdFusionConference
 
ColdFusion Keynote: Building the Agile Web Since 1995
ColdFusion Keynote: Building the Agile Web Since 1995ColdFusion Keynote: Building the Agile Web Since 1995
ColdFusion Keynote: Building the Agile Web Since 1995ColdFusionConference
 
Instant ColdFusion with Vagrant
Instant ColdFusion with VagrantInstant ColdFusion with Vagrant
Instant ColdFusion with VagrantColdFusionConference
 
Restful services with ColdFusion
Restful services with ColdFusionRestful services with ColdFusion
Restful services with ColdFusionColdFusionConference
 
Super Fast Application development with Mura CMS
Super Fast Application development with Mura CMSSuper Fast Application development with Mura CMS
Super Fast Application development with Mura CMSColdFusionConference
 
Build your own secure and real-time dashboard for mobile and web
Build your own secure and real-time dashboard for mobile and webBuild your own secure and real-time dashboard for mobile and web
Build your own secure and real-time dashboard for mobile and webColdFusionConference
 
Why Everyone else writes bad code
Why Everyone else writes bad codeWhy Everyone else writes bad code
Why Everyone else writes bad codeColdFusionConference
 
Rest ful tools for lazy experts
Rest ful tools for lazy expertsRest ful tools for lazy experts
Rest ful tools for lazy expertsColdFusionConference
 
Herding cats managing ColdFusion servers with commandbox
Herding cats managing ColdFusion servers with commandboxHerding cats managing ColdFusion servers with commandbox
Herding cats managing ColdFusion servers with commandboxColdFusionConference
 
Instant ColdFusion with Vagrant
Instant ColdFusion with VagrantInstant ColdFusion with Vagrant
Instant ColdFusion with VagrantColdFusionConference
 

Mais de ColdFusionConference (20)

Api manager preconference
Api manager preconferenceApi manager preconference
Api manager preconference
 
Don't just pdf, Smart PDF
Don't just pdf, Smart PDFDon't just pdf, Smart PDF
Don't just pdf, Smart PDF
 
Crafting ColdFusion Applications like an Architect
Crafting ColdFusion Applications like an ArchitectCrafting ColdFusion Applications like an Architect
Crafting ColdFusion Applications like an Architect
 
Security And Access Control For APIS using CF API Manager
Security And Access Control For APIS using CF API ManagerSecurity And Access Control For APIS using CF API Manager
Security And Access Control For APIS using CF API Manager
 
Monetizing Business Models: ColdFusion and APIS
Monetizing Business Models: ColdFusion and APISMonetizing Business Models: ColdFusion and APIS
Monetizing Business Models: ColdFusion and APIS
 
Become a Security Rockstar with ColdFusion 2016
Become a Security Rockstar with ColdFusion 2016Become a Security Rockstar with ColdFusion 2016
Become a Security Rockstar with ColdFusion 2016
 
ColdFusion in Transit action
ColdFusion in Transit actionColdFusion in Transit action
ColdFusion in Transit action
 
Developer Insights for Application Upgrade to ColdFusion 2016
Developer Insights for Application Upgrade to ColdFusion 2016Developer Insights for Application Upgrade to ColdFusion 2016
Developer Insights for Application Upgrade to ColdFusion 2016
 
ColdFusion Keynote: Building the Agile Web Since 1995
ColdFusion Keynote: Building the Agile Web Since 1995ColdFusion Keynote: Building the Agile Web Since 1995
ColdFusion Keynote: Building the Agile Web Since 1995
 
Instant ColdFusion with Vagrant
Instant ColdFusion with VagrantInstant ColdFusion with Vagrant
Instant ColdFusion with Vagrant
 
Restful services with ColdFusion
Restful services with ColdFusionRestful services with ColdFusion
Restful services with ColdFusion
 
Super Fast Application development with Mura CMS
Super Fast Application development with Mura CMSSuper Fast Application development with Mura CMS
Super Fast Application development with Mura CMS
 
Build your own secure and real-time dashboard for mobile and web
Build your own secure and real-time dashboard for mobile and webBuild your own secure and real-time dashboard for mobile and web
Build your own secure and real-time dashboard for mobile and web
 
Why Everyone else writes bad code
Why Everyone else writes bad codeWhy Everyone else writes bad code
Why Everyone else writes bad code
 
Securing applications
Securing applicationsSecuring applications
Securing applications
 
Testing automaton
Testing automatonTesting automaton
Testing automaton
 
Rest ful tools for lazy experts
Rest ful tools for lazy expertsRest ful tools for lazy experts
Rest ful tools for lazy experts
 
Herding cats managing ColdFusion servers with commandbox
Herding cats managing ColdFusion servers with commandboxHerding cats managing ColdFusion servers with commandbox
Herding cats managing ColdFusion servers with commandbox
 
Instant ColdFusion with Vagrant
Instant ColdFusion with VagrantInstant ColdFusion with Vagrant
Instant ColdFusion with Vagrant
 
Hidden gems in cf2016
Hidden gems in cf2016Hidden gems in cf2016
Hidden gems in cf2016
 

Último

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Último (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Dependency Injection

  • 2. Dependency Injection: Why is it awesome and why should I care? Nolan Erck
  • 3. About Me Consultant (southofshasta.com) Software Development, Training, Design Tools I use: ColdFusion, C++, Java, jQuery, PHP, .NET, HTML5, Android, SQL, you get the idea... Manager of SacInteractive User Group Reformed Video Game Developer (Grim Fandango, SimPark, StarWars Rogue Squadron, etc). Music Junkie
  • 7. Today’s Agenda What is Dependency Injection? When/why do I want it in my projects? Intro to Bean Management Intro to Inversion of Control (IOC) Intro to Aspect Oriented Programming (AOP) Other info Questions
  • 8. Prerequisites Have some experience building classes and objects. Don't need to be an expert. Don't need to have used an MVC framework. D/I frameworks can be totally separate. And 1 more thing you need to know...
  • 9. Prerequisites Know that Object Oriented Programming is hard. And some of it is confusing at first. And that's NORMAL.
  • 10. What Is Dependency Injection?
  • 11. What Is Dependency Injection? A “design pattern” $6 phrase for “a way to organize your classes so they work together in a flexible way”. Like a for() loop, if(), array[] Reusable technique, based around objects. There are lots of design patterns: Dependency Injection is 1 design pattern Inversion of Control (IOC), Aspect Oriented Programming (AOP) and Bean Management are all “variations on that theme”. There are lots of others too.
  • 12. What Is Dependency Injection? It's not platform specific. Available for ColdFusion, Java, .NET, JavaScript, etc. For today's preso: Using mostly pseudocode / concepts. No specific code samples. Some keywords will change. All the concepts work the same across libraries and languages.
  • 13. When / Why Use D/I? Short answer: When you have lots of classes that talk to each other, want to keep code organized, and make it easy to swap different “types” of objects in/out of your application.
  • 14. When / Why Use D/I? Short answer: When you have lots of classes that talk to each other, want to keep code organized, and make it easy to swap different “types” of objects in/out of your application. Longer answer: That's what the rest of the slides are for...
  • 15. Does this mean
 I have to rebuild my entire app to use D/I? No. But you might get more benefits if you make a few changes to legacy code along the way. I have to learn a new way to code all my classes? No. You can leave everything as-is. The nice thing about D/I is you can use it or not use it. If you want to write code the “old way” in part of your app, there's nothing stopping you from doing so. It will all still work as-is. Neat huh? Let's learn a bit more, shall we?
  • 17. What’s a Bean? A “thing” your D/I framework knows about. class User{ 
 } class DateUtils {
} In your DI framework: bean id=”myUser” class=”User” bean id=”myDateUtils” class=”DateUtils” (Exact syntax varies between DI libraries.)
  • 18. Bean Management - First Example MailService.cfc <cfcomponent> <cffunction name=”sendEmail”> <cfargument name=”from”> <cfargument name=”to”> <cfagument name=”body”> [ code for sending the email ] </cffunction> </cfcomponent> Usage: myMailService = CreateObject( “MailService” ); myMailService.sendEmail( to=”...”, from=”...”, body=”...” );
  • 19. Bean Management - First Example myMailSvc = DILibrary.getBean( “MailService” ); myMailSvc.sendEmail( to=”...”, from=”...”, body=”...” ); Cute, but we haven't gained anything yet. CreateObject() was 1 line of code – DI.getBean() is 1 line if code. No real improvements, but this is an easy way to start using DI: Remove calls to CreateObject(), replace with calls to the DI library.
  • 20. Bean Management class A { public class A() {...} } class B{ public class B(A a) { 
 } } class C { public class C(B b) { 
 } } class D{ public class D(C c) {...} } So if I -JUST- want a D object made...
  • 21. Bean Management I have to do all this... A a = new A(); B b = new B( a ); C c = new C( b ); D d = new D( c ); 4 lines of code. The first 3 are “boilerplate” to create the variables I need to make a D. Multiply that out over all the objects in your app... = a LOT of boilerplate code! Another way to say it: “D depends on A, B and C being made first”.
  • 22. Bean Management With a D/I library that does Bean Management, you'd write something like this instead... D d = ColdSpring.getBean( “D” ); 4 lines of code just became 1. And no more boilerplate stuff! You tell your D/I framework “I need a D. Go find out what D depends on, make those as needed, and hand me back D when you're done.” (“ColdSpring” is a placeholder here for any D/I framework. They all work about the same.)
  • 23. Bean Management Quasi Real World Example. Mailing department wide messages. Mail Service CFC ‱ Needs a Department CFC to know which Department is being emailed. ‱ Department needs a Department DAO for it's SQL stuff. ‱ And a SecurityLogin CFC to make sure it's validated/logged in/ whatever.
  • 24. Bean Management Old Way mySecLogin = CreateObject( “component”, “SecurityLogin”); myDeptDAO = CreateObject(“component”,“DepartmentDAO”); dept = CreateObject( “component”, “Department” ); dept.init( mySecLogin, myDeptDAO ); mailSvc = CreateObject( “component”, “MailService” ); mailSvc.init( dept ); mailSvc.sendEmail();
  • 25. Bean Management New Way WireBox.getBean( “mailService” ).sendMail();
  • 26. Bean Management New Way WireBox.getBean( “mailService” ).sendMail(); Yes, 1 line of code. Yes, it is THAT easy. (I'm over simplifying a little.)
  • 27. Bean Management So how does the D/I framework “know” that I need an A, B and C to make a D object? Varies a little from framework to framework. Configuration based: XML file that “describes” the relationship between the objects. (ColdSpring, Spring) Nice for, say, white-box testing w/ hands-on QA team. Convention based: Works automatically by which folders you store classes in, and how the classes are named. (DI/1, WireBox) Just pick one and try it out, they all do the same core “things”.
  • 29. Inversion of Control (IOC) Fancy term for “flipping” some code around from the “traditional” or “normal” way you'd build objects. Instead of building an Employee object, then a Department object, then putting the Employee IN the Department. You say “get me a fully populated/constructed Department”. Magic happens, automatically building the Employee object for you.
  • 30. Inversion of Control (IOC) class RockGroup { private String groupName; public String getGroupName(){ return groupName; } public void setGroupName(String name) { this.groupName = name; } } No Constructor. “groupName” is private. So we have to call the setter to initialize the variable with something.
  • 31. Inversion of Control (IOC) With regular code, we'd do this: String myBandName = “Depeche Mode”; RockGroup rg = new RockGroup(); rg.setGroupName( myBandName ); That works but... Every time I want to provide a different default value, I have to change code, and recompile.
  • 32. Inversion of Control (IOC) What if we could provide that default value in a “config file”, outside of code? And whenever we create a RockGroup object, it automatically gets a default value for groupName passed in at that instant? You can!
  • 33. Inversion of Control (IOC) Using a D/I framework, you can have a “config” that notes default values for your classes: <class name=”RockGroup”> <property name=”groupName” value=”Depeche Mode”/> </class> rg = ColdSpring.getBean( “RockGroup” ) ...any time I make a RockGroup, it will automatically initialize the “groupName” variable to the default value I provided. No extra lines of code. And changing this default is now done in a config file. No recompiling code to change it!
  • 34. Inversion of Control (IOC) What about classes inside of other classes? AKA “Composition”, the “has a” relationship. Kind of the same thing...
  • 35. Inversion of Control (IOC) class RockGroup{ private String groupName; public String getGroupName(){ 
 } public void setGroupName( String name ) {
} private Musician singer; public Musician getSinger(){ 
 } public void setSinger( Musician m ) {
} } class Musician{ private String name; private int yearsSober; private int age; public String getName() { return name; } public void setName(String n){ this.name = n; } public int getYearsSober() { 
 } public void setYearsSober(int y) { 
 } public void setAge( int a ){
} public int getAge(){ return age; } }
  • 36. Inversion of Control (IOC) With straight code... Musician m = new Musician(); m.name = “George Harrison”; m.age = 64; m.yearsSober = 10; RockGroup rg = new RockGroup(); rg.setGroupName( “The Beatles” ); rg.setMusician( m );
  • 37. Inversion of Control (IOC) With D/I... RockGroup rg = Spring.getBean(“RockGroup”);
  • 38. Inversion of Control (IOC) The Musician class has a String property, that gets initialized just like the String property in RockGroup. Ditto for the “int” properties, etc: Spring.getBean( “Musician” ); “name” will always be whatever is in my config for the Musician class. <class name=”Musician”> <property name=”name” value=”George Harrison” /> <property name=”age” value=”64” /> <property name=”yearsSober” value=”10” /> </class>
  • 39. Inversion of Control (IOC) You can also refer to other classes in the config, and “inject” them into each other, just like we “injected” the String and int into Musician: <class name=”Musician” id=”drummerBean1”> <property name=”name” value=”Pete Best” /> <property name=”yearsSober” value=”10” /> <property name=”age” value=”64” /> </class> <class name=”RockGroup”> <property name=”groupName” value=”The Beatles” /> <property name=”drummer” ref=”drummerBean1” /> </class>
  • 40. Inversion of Control (IOC) So now when I do this... rg = DIFramework.getBean( “RockGroup” ); rg will be fully constructed
 ‱ It will have a “groupName” property set to “The Beatles”. ‱ It will have a “drummer” property set to “Pete Best”, he'll be 64 years old and 10 years sober. ‱ 1 line of code, no boilerplate stuff. ‱ If I want to change those defaults, I don't have to recompile, I just change a “config” setting.
  • 41. Inversion of Control (IOC) Swapping out one type of Musician for another doesn't require recompiling code, just change a config: <class name=”Drummer” id=”drummerBean1”> <property name=”name” value=”Pete Best” /> <property name=”yearsSober” value=”10” /> <property name=”age” value=”55” /> </class> <class name=”RockGroup”> <property name=”groupName” value=”The Beatles” /> <property name=”drummer” ref=”drummerBean1” /> </class>
  • 42. Inversion of Control (IOC) Swapping out one type of Musician for another doesn't require recompiling code, just change a config: <class name=”Drummer” id=”drummerBean2”> <property name=”name” value=”Ringo Starr” /> <property name=”yearsSober” value=”22” /> <property name=”age” value=”57” /> </class> <class name=”RockGroup”> <property name=”groupName” value=”The Beatles” /> <property name=”drummer” ref=”drummerBean2” /> </class>
  • 43. Inversion of Control (IOC) Swapping out one type of Musician for another doesn't require recompiling code, just change a config: <class name=”Drummer” id=”drummerBean2”> <property name=”name” value=”Ringo Starr” /> <property name=”yearsSober” value=”22” /> <property name=”age” value=”57” /> </class> <class name=”RockGroup”> <property name=”groupName” value=”The Beatles” /> <property name=”drummer” ref=”drummerBean2” /> </class> Off topic: discussing if Pete is better/worse than Ringo.
  • 45. Aspect Oriented Programming (AOP) AKA “Cross Cutting”. Change the “aspect” of how a function is called. Say I have a foo() method. Any time foo() is called... Automatically... Call code before or after foo() Wrap some sort of code “around” foo() e.g. try/catch blocks It no longer just does “foo()”. Also does whatever you define as an aspect of calling foo().
  • 46. Aspect Oriented Programming (AOP) Example: drawSalesReport() In your AOP library: <func name=”drawSalesReport”> <aspect before run=”checkIfLoggedIn” /> <aspect after run=”saveToDebugLogFile” /> </func>
  • 47. Aspect Oriented Programming (AOP) In your code, it USED to look like this: checkIfLoggedIn(); drawSalesReport( UserID=555, dtCreated='1/1/2015' ); SaveToDebugLogFile(); What happens now is... DIFramework.runWithAdvice( “drawSalesReport”, { UserID=555, dtCreated='1/1/2015' } ); and that does all 3 things, in correct order.
  • 48. Aspect Oriented Programming (AOP) But wait, there's more! Can also wrap “blocks” of code around each other, not just function calls before/after each other. e.g. try/catch blocks.
  • 49. Aspect Oriented Programming (AOP) Say I have a query like so: <cfquery name=”qryGetUsers”> SELECT * FROM Users </cfquery> In Production, I want that wrapped in a try/catch, but in QA/ Development, I don't. (So I can see the debug output, etc.)
  • 50. Aspect Oriented Programming (AOP) I'd have to set some kind of “flag”: <cfif isProduction> <cftry> <cfquery name=”qryGetUsers”> SELECT * FROM Users </cfquery> <cfcatch> <cflog 
 /> </cfcatch> </cftry> <cfelse> <cfquery name=”qryGetUsers”> SELECT * FROM Users </cfquery> </cfif> Duplicate Code! Remember the DRY rule!
  • 51. Aspect Oriented Programming (AOP) Instead of calling a getUsers() method directly: GetUsers(); In your AOP library: <advice around functionName=”getUsersWithAdvice”> <method name=”getUsers” /> </advice>
  • 52. Aspect Oriented Programming (AOP) <advice around functionName=”getUsersWithAdvice”> <method name=”getUsers” /> </advice> function getUsersWithAdvice( funcToRun ) { if( isProduction ) { try{ #funcToRun#(); } catch{ 
 } }else{ #funcToRun#(); } }
  • 53. Aspect Oriented Programming (AOP) In your code: DIFramework.runWithAdvice( “getUsers” ); The if() statement is still there but our duplicate SQL is gone!
  • 54. Aspect Oriented Programming (AOP) Can also use it for
 SaaS feature flags - turn on functionality only when a customer pays for it. No need to edit code, just toggle a config. Swap out 3rd party/vendor integrations easily. Cranky vendor: “it will take you months to remove our tech from your product.” App with AOP: No, actually it will take me 5 minutes
  • 55. So what’s the catch? A new way of thinking about how you build your classes. Takes some getting used to. A little extra “set up” work. Naming conventions, or typing some XML. Debugging errors can be slower at first due to learning curve. 
but

  • 56. So what’s the catch? 
but
 It makes your code more reusable
 More flexible
 Easier to test
 Easier to turn features (aka “aspects”) on/off easily

  • 57. So what’s the catch? “But now I have tons of files in my app!” So what? Breathe. Use version control to keep them safe. Each file does “1 thing”. Easy to know which file you’ll need to edit.
  • 58. Remember
 You don't have to do this all at once. Start with (for example) Bean Management. Add other bits as you get comfortable. It's not like an MVC framework where the whole app has to be considered. Find 1 tiny spot in your app, add a little DI there. Add more in increments, go as you learn.
  • 59. Also Remember
 Object-Oriented Programming is hard. It's different than Procedural code. Takes getting used to. That's NORMAL. Nobody learns all this stuff instantly. It takes some time. (But it is the way many languages are going these days.)
  • 60. Other Resources Book: Spring In Action (Java) Book: Head First Design Patterns Framework/1, DI/1 and AOP/1 ColdSpring documentation Good examples, not overwhelming. SpringByExample.org Java code, but explanation of the general concepts is pretty good. The ColdBox docs are also great for this too. Those guys like to write!
  • 61. Questions? Comments? Ways to reach me... Email: nolan@southofshasta.com Twitter: @southofshasta Blog: southofshasta.com (Slides are on my website.) Thanks!