SlideShare uma empresa Scribd logo
1 de 39
Baixar para ler offline
Lego for Engineers

                                    How to build Reusable
                                      and Maintainable
                                        Applications
                                            in C#
Lego (trademarked in capitals as LEGO)   Theo Jungeblut 06/03/2011
Theo Jungeblut
• Senior Software Developer at
  Omnicell Inc. in Mountain View
• Has been designing and
  implementing .NET based
  applications , components and
  frameworks for 8 years
• Previously worked in factory
  automation with focus on
  component based software and
  framework development for 3 ½
  years
                                   theo@csharp-lighthouse.com
• Degree in Software Engineering
  and Network Communications       www.csharp-lightouse.com
Overview
    • Why Lego for Software Engineers?
    • Design Patterns, Principles and Best Practices
    • Dependency Injection Container & more
    • The “Must Read”-Book
    • Summary
    • Q&A
    • References


3
Why Lego for Software Engineers?
Lego (trademarked in capitals as LEGO) is a line of construction toys manufactured by the Lego Group




        http://upload.wikimedia.org/wikipedia/commons/7/75/Lego_technic_gears.jpg
                                                                                                       4
Design Patterns, Principals
         & Best Practices
         • Keep it simple stupid (KISS)
         • Separation of Concerns (SoC)
         • Single Responsibility Principle (SRP)
         • Component Oriented Programming (CoP)
         • Interface / Contract
         • Don’t Repeat Yourself (DRY)
         • Dependency Inversion Principal (DIP)
         • Inversion of Control (IoC)
              • Constructor Injection
              • Setter Injection
              • Interface Injection
              • Service Locator

5
Keep it simple, stupid
        (KISS)
KISS-Principle – “Keep It Simple Stupid”
   by Kelly Johnson




                      http://blogs.smarter.com/blogs/Lego%20Brick.jpg   7
The Power of Simplicity




                                                       Graphic by Nathan Sawaya courtesy of brickartist.com




Graphic by Nathan Sawaya courtesy of brickartist.com

8                                                                               http://www.geekalerts.com/lego-iphone/
Graphic by Nathan Sawaya courtesy of brickartist.com
Separation of Concerns
         (SoC)

 Single Responsibility
       Principle
         (SRP)
The Product




http://www.technicopedia.com/8865.html
Component / Service




          http://www.technicopedia.com/8865.html
Class, Struct, Enum etc.




http://technicbricks.blogspot.com/2009/06/tbs-techpoll-12-results-2009-1st.html
Separation of Concerns (SoC)
         probably by Edsger W. Dijkstra in 1974

 • “In computer science,
 separation of concerns (SoC) is
 the process of separating a
 computer program into distinct
 features that overlap in
 functionality as little as possible.

 •A concern is any piece of
 interest or focus in a program.
 Typically, concerns are
 synonymous with features or
 behaviors. “
     http://en.wikipedia.org/wiki/Separati
     on_of_Concerns

14
Single Responsibility Principle (SRP)
           by Robert C Martin


     “Every object should have a single responsibility, and that
     responsibility should be entirely encapsulated by the class.”
         http://en.wikipedia.org/wiki/Single_responsibility_principle




     public class Logger : ILogger
     {
       public Logger(ILoggingSink loggingSink)
       {}

          public void Log(string message)
          {}
     }
                                                                        http://www.ericalbrecht.com
15
Component-Oriented
   Programming
       (CoP)
Different Ways of doing Something Similar




http://www.ericalbrecht.com




                                                            http://www.julianaheng.com/transformers-rotf-bumblebee-
                                                            and-sam-action-figures/




                              http://www.ericalbrecht.com

17
Why Reusable Components Rock




     http://www.ericalbrecht.com/technic/8020/8020all.jpg



18
Interfaces / Contracts
     • Decouple Usage and Implementation through introduction of a contract
     • Allows to replace implementation without changing the consumer

     public interface ILogger              public class Logger : ILogger
     {                                     {
       void Log(string message);             public Logger(ILoggingSink loggingSink)
     }                                       {}

                                               public void Log(string message)
                                               {}
                                           }




19
Don’t repeat yourself
        (DRY)
Don’t repeat yourself (DRY)
         by Andy Hunt and Dave Thomas in their book “The Pragmatic Programmer”

 // Code Copy and Paste Method                                                    // DRY Method
 public Class Person                                                              public Class Person
  {                                                                                {
    public string FirstName { get; set;}                                             public string FirstName { get; set;}
    public string LastName { get; set;}                                              public string LastName { get; set;}

     public Person(Person person)                                                     public Person(Person person)
     {                                                                                {
       this.FirstName = string.IsNullOrEmpty(person.FirstName)                          this.FirstName = person.FirstName.CloneSecured();
                  ? string.Empty : (string) person.FirstName.Clone();                   this.LastName = person.LastName.CloneSecured();
                                                                                      }
         this.LastName = string.IsNullOrEmpty(person.LastName)
                   ? string.Empty : (string) person.LastName.Clone();                 public object Clone()
     }                                                                                {
                                                                                        return new Person(this);
     public object Clone()                                                            }
     {                                                                            }
       return new Person(this);
     }
 }                                         public static class StringExtension
                                            {
                                              public static string CloneSecured(this string original)
                                              {
                                                return string.IsNullOrEmpty(original) ? string.Empty : (string)original.Clone();
                                              }
                                           }
21
Dependency Inversion Principle
           (DIP)
Dependency Inversion Principle (DIP)
  by Robert C. Martin


• “High-level modules should not depend on
  low-level modules. Both should depend on
  abstractions.
• Abstractions should not depend upon details.
  Details should depend upon abstractions.”
  http://en.wikipedia.org/wiki/Dependency_inversion_principle




                                                                23
S               Single Responsibility Principle

   O               Open/Closed Principle

   L               Liskov Substitution Principle

   I               Interface Segregation Principle

   D               Dependency Inversion Principle

Robert C Martin:   http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod
Inversion of Control
        (IoC)
Inversion of Control (IoC)
     by Martin Fowler 1994




             Logger logger = new Logger();




26
Inversion of Control (IoC)
     by Martin Fowler 1994




             Logger logger = new Logger();




27
The “Must Read”-Book
      by Mark Seemann


     Dependency
     Injection is a set of
     software design
     principles and
     patterns that
     enable us to
     develop loosely
     coupled code.


28        http://www.manning.com/seemann/
Inversion of Control –

     Constructor Injection
     http://www.martinfowler.com/articles/injection.html


     public class ContactManager : IContactManager
     {
       public ContactManager(ILogger logger,
                               IContactPersistence contactPersistence)
       {
         this.logger = logger;
         if (logger == null)
         {
            throw new ArgumentNullException("logger");
         }

             …
         }
     }
29
Inversion of Control –
     Setter (Property) Injection
     http://www.martinfowler.com/articles/injection.html



        // UNITY Example
        public class ContactManager : IContactManager
        {
          [Dependency]
          public IContactPersistence ContactPersistence
          {
            get { return this.contactPersistence; }

                set { this.contactPersistence = value; }
            }
        }



30
Inversion of Control (IoC) –

      Interface Injection
       http://www.martinfowler.com/articles/injection.html


                                                            In this methodology we implement an
                                                            interface from the IOC framework. IOC
                                                            framework will use the interface method to
                                                            inject the object in the main class. You can see
                                                            in figure ‘Interface based DI’ we have
                                                            implemented an interface ‘IAddressDI’ which
                                                            has a ‘setAddress’ method which sets the
                                                            address object. This interface is then
                                                            implemented in the customer class. External
                                                            client / containers can then use the
                                                            ‘setAddress’ method to inject the address
                                                            object in the customer object.
     http://www.codeproject.com/KB/aspnet/IOCDI/InterfacebasedDI.JPG   http://www.codeproject.com/KB/aspnet/IOCDI.aspx




31
Inversion of Control –

     Service Locator
     http://www.martinfowler.com/articles/injection.html



     // UNITY Example
     internal static class Program
     {
       private static UnityContainer unityContainer;
       private static SingleContactManagerForm singleContactManagerForm;

         private static void InitializeMainForm()
         {
           singleContactManagerForm =
           unityContainer.Resolve<SingleContactManagerForm>();
         }
     }


32
Inversion of Control –

     Service Locator
     http://www.martinfowler.com/articles/injection.html



     // UNITY Example
     internal static class Program
     {
       private static UnityContainer unityContainer;
       private static SingleContactManagerForm singleContactManagerForm;

         private static void InitializeMainForm()
         {
           singleContactManagerForm =
           unityContainer.Resolve<SingleContactManagerForm>();
         }
     }


33
Inversion of Control
                         Service Locator vs Dependency Injection


 • Service Locator allows to request explicitly the needed instance/type/service

 • Every user of a service has a dependency to the Service Locator
      • Potential issue if the component need to be provided to 3rd parties.
      • Favorable for closed platforms as the Service Locator allow more control

 • Testing is easier with Dependency Injection than a Service Locator if Service
 provided is not easily substituted

 • In general Service Locator is only the less compelling choice if the code is
 mainly used out of the control of the writer




34
     http://www.martinfowler.com/articles/injection.html#ServiceLocatorVsDependencyInjection
Dependency Injection Container & more
     • Typically support all types of Inversion of Control mechanisms
        • Constructor Injection
        • Property (Setter) Injection
        • Interface Injection
        • Service Locator

     •.NET based DI-Container
        • Unity
        • Castle Windsor
        • StructureMap
                                        Related Technology:
        • Spring.NET                    • Managed Extensibility Framework (MEF)
        • Autofac                       • Windows Communication Foundation (WCF)
        • Puzzle.Nfactory
        • Ninject
        • PicoContainer.NET
        • and more
35
The “Must Read”-Book
     by Mark Seemann




36    http://www.manning.com/seemann/
Summary
     Improving Reusability and Maintainability through:

     • Simplification and Specialization
       (KISS, SoC, SRP)

     •Decoupling
       (Interfaces, CoP, DIP or SOA)

     • Avoiding Code Blow (DRY, YAGNI)

     • Testability (all of them!)


                                           Lego (trademarked in capitals as LEGO)
37
Q&A
                                         Feedback & Comments:
                                                       theo@csharp-lighthouse.com
                                                   www.csharp-lighthouse.com


Graphic by Nathan Sawaya courtesy of brickartist.com
References Part
     http://www.manning.com/seemann/
     http://en.wikipedia.org/wiki/Keep_it_simple_stupid
     http://picocontainer.org/patterns.html
     http://en.wikipedia.org/wiki/Separation_of_concerns
     http://en.wikipedia.org/wiki/Don't_repeat_yourself
     http://en.wikipedia.org/wiki/You_ain't_gonna_need_it
     http://en.wikipedia.org/wiki/Component-oriented_programming
     http://en.wikipedia.org/wiki/Service-oriented_architecture
     http://www.martinfowler.com/articles/injection.html
     http://www.codeproject.com/KB/aspnet/IOCDI.aspx
     http://msdn.microsoft.com/en-us/magazine/cc163739.aspx
     http://msdn.microsoft.com/en-us/library/ff650320.aspx
     http://msdn.microsoft.com/en-us/library/aa973811.aspx
     http://msdn.microsoft.com/en-us/library/ff647976.aspx
     http://msdn.microsoft.com/en-us/library/cc707845.aspx
     http://msdn.microsoft.com/en-us/library/bb833022.aspx
     http://dotnetslackers.com/articles/net/A-First-Look-at-Unity-2-0.aspx
     http://unity.codeplex.com/
     http://www.idesign.net/idesign/DesktopDefault.aspx?tabindex=5&tabid=11
39

Mais conteúdo relacionado

Mais procurados

Clean Code - Design Patterns and Best Practices at Silicon Valley Code Camp
Clean Code - Design Patterns and Best Practices at Silicon Valley Code CampClean Code - Design Patterns and Best Practices at Silicon Valley Code Camp
Clean Code - Design Patterns and Best Practices at Silicon Valley Code CampTheo Jungeblut
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design PrinciplesAndreas Enbohm
 
Clean code & design patterns
Clean code & design patternsClean code & design patterns
Clean code & design patternsPascal Larocque
 
Object-oriented design principles
Object-oriented design principlesObject-oriented design principles
Object-oriented design principlesXiaoyan Chen
 
Cut your Dependencies - Dependency Injection at Silicon Valley Code Camp
Cut your Dependencies - Dependency Injection at Silicon Valley Code CampCut your Dependencies - Dependency Injection at Silicon Valley Code Camp
Cut your Dependencies - Dependency Injection at Silicon Valley Code CampTheo Jungeblut
 
OO design principles & heuristics
OO design principles & heuristicsOO design principles & heuristics
OO design principles & heuristicsDhaval Shah
 
principles of object oriented class design
principles of object oriented class designprinciples of object oriented class design
principles of object oriented class designNeetu Mishra
 
Cut your Dependencies with Dependency Injection for East Bay.NET User Group
Cut your Dependencies with Dependency Injection for East Bay.NET User Group Cut your Dependencies with Dependency Injection for East Bay.NET User Group
Cut your Dependencies with Dependency Injection for East Bay.NET User Group Theo Jungeblut
 
Design Patterns: From STUPID to SOLID code
Design Patterns: From STUPID to SOLID codeDesign Patterns: From STUPID to SOLID code
Design Patterns: From STUPID to SOLID codePaulo Gandra de Sousa
 
ReactJS for Programmers
ReactJS for ProgrammersReactJS for Programmers
ReactJS for ProgrammersDavid Rodenas
 
Matteo Vaccari - TDD per Android | Codemotion Milan 2015
Matteo Vaccari - TDD per Android | Codemotion Milan 2015Matteo Vaccari - TDD per Android | Codemotion Milan 2015
Matteo Vaccari - TDD per Android | Codemotion Milan 2015Codemotion
 
Design patterns illustrated-2015-03
Design patterns illustrated-2015-03Design patterns illustrated-2015-03
Design patterns illustrated-2015-03Herman Peeren
 
Extreme Interview Questions
Extreme Interview QuestionsExtreme Interview Questions
Extreme Interview QuestionsEhtisham Ali
 
Advanced Object-Oriented/SOLID Principles
Advanced Object-Oriented/SOLID PrinciplesAdvanced Object-Oriented/SOLID Principles
Advanced Object-Oriented/SOLID PrinciplesJon Kruger
 

Mais procurados (20)

Clean Code - Design Patterns and Best Practices at Silicon Valley Code Camp
Clean Code - Design Patterns and Best Practices at Silicon Valley Code CampClean Code - Design Patterns and Best Practices at Silicon Valley Code Camp
Clean Code - Design Patterns and Best Practices at Silicon Valley Code Camp
 
Clean Code 2
Clean Code 2Clean Code 2
Clean Code 2
 
SOLID design principles applied in Java
SOLID design principles applied in JavaSOLID design principles applied in Java
SOLID design principles applied in Java
 
Binding android piece by piece
Binding android piece by pieceBinding android piece by piece
Binding android piece by piece
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
Exploring lambdas and invokedynamic for embedded systems
Exploring lambdas and invokedynamic for embedded systemsExploring lambdas and invokedynamic for embedded systems
Exploring lambdas and invokedynamic for embedded systems
 
Clean code & design patterns
Clean code & design patternsClean code & design patterns
Clean code & design patterns
 
Object-oriented design principles
Object-oriented design principlesObject-oriented design principles
Object-oriented design principles
 
Cut your Dependencies - Dependency Injection at Silicon Valley Code Camp
Cut your Dependencies - Dependency Injection at Silicon Valley Code CampCut your Dependencies - Dependency Injection at Silicon Valley Code Camp
Cut your Dependencies - Dependency Injection at Silicon Valley Code Camp
 
OO design principles & heuristics
OO design principles & heuristicsOO design principles & heuristics
OO design principles & heuristics
 
principles of object oriented class design
principles of object oriented class designprinciples of object oriented class design
principles of object oriented class design
 
SOLID principles
SOLID principlesSOLID principles
SOLID principles
 
Cut your Dependencies with Dependency Injection for East Bay.NET User Group
Cut your Dependencies with Dependency Injection for East Bay.NET User Group Cut your Dependencies with Dependency Injection for East Bay.NET User Group
Cut your Dependencies with Dependency Injection for East Bay.NET User Group
 
Design Patterns: From STUPID to SOLID code
Design Patterns: From STUPID to SOLID codeDesign Patterns: From STUPID to SOLID code
Design Patterns: From STUPID to SOLID code
 
SOLID principles
SOLID principlesSOLID principles
SOLID principles
 
ReactJS for Programmers
ReactJS for ProgrammersReactJS for Programmers
ReactJS for Programmers
 
Matteo Vaccari - TDD per Android | Codemotion Milan 2015
Matteo Vaccari - TDD per Android | Codemotion Milan 2015Matteo Vaccari - TDD per Android | Codemotion Milan 2015
Matteo Vaccari - TDD per Android | Codemotion Milan 2015
 
Design patterns illustrated-2015-03
Design patterns illustrated-2015-03Design patterns illustrated-2015-03
Design patterns illustrated-2015-03
 
Extreme Interview Questions
Extreme Interview QuestionsExtreme Interview Questions
Extreme Interview Questions
 
Advanced Object-Oriented/SOLID Principles
Advanced Object-Oriented/SOLID PrinciplesAdvanced Object-Oriented/SOLID Principles
Advanced Object-Oriented/SOLID Principles
 

Semelhante a Lego For Engineers - Dependency Injection for LIDNUG (2011-06-03)

Clean Code - Design Patterns and Best Practices for Bay.NET SF User Group (01...
Clean Code - Design Patterns and Best Practices for Bay.NET SF User Group (01...Clean Code - Design Patterns and Best Practices for Bay.NET SF User Group (01...
Clean Code - Design Patterns and Best Practices for Bay.NET SF User Group (01...Theo Jungeblut
 
Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...
Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...
Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...Theo Jungeblut
 
Clean Code I - Best Practices
Clean Code I - Best PracticesClean Code I - Best Practices
Clean Code I - Best PracticesTheo Jungeblut
 
Clean Code Part i - Design Patterns and Best Practices -
Clean Code Part i - Design Patterns and Best Practices -Clean Code Part i - Design Patterns and Best Practices -
Clean Code Part i - Design Patterns and Best Practices -Theo Jungeblut
 
2009 Dotnet Information Day: More effective c#
2009 Dotnet Information Day: More effective c#2009 Dotnet Information Day: More effective c#
2009 Dotnet Information Day: More effective c#Daniel Fisher
 
TWINS: OOP and FP - Warburton
TWINS: OOP and FP - WarburtonTWINS: OOP and FP - Warburton
TWINS: OOP and FP - WarburtonCodemotion
 
Use of Apache Commons and Utilities
Use of Apache Commons and UtilitiesUse of Apache Commons and Utilities
Use of Apache Commons and UtilitiesPramod Kumar
 
The software design principles
The software design principlesThe software design principles
The software design principlesAman Kesarwani
 
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...Tudor Dragan
 
designpatterns_blair_upe.ppt
designpatterns_blair_upe.pptdesignpatterns_blair_upe.ppt
designpatterns_blair_upe.pptbanti43
 
SOLID & IoC Principles
SOLID & IoC PrinciplesSOLID & IoC Principles
SOLID & IoC PrinciplesPavlo Hodysh
 
Cut your Dependencies with Dependency Injection - .NET User Group Osnabrueck
Cut your Dependencies with Dependency Injection - .NET User Group OsnabrueckCut your Dependencies with Dependency Injection - .NET User Group Osnabrueck
Cut your Dependencies with Dependency Injection - .NET User Group OsnabrueckTheo Jungeblut
 
Parsley & Flex
Parsley & FlexParsley & Flex
Parsley & Flexprideconan
 
From Android NDK To AOSP
From Android NDK To AOSPFrom Android NDK To AOSP
From Android NDK To AOSPMin-Yih Hsu
 
Real-time Computer Vision With Ruby - OSCON 2008
Real-time Computer Vision With Ruby - OSCON 2008Real-time Computer Vision With Ruby - OSCON 2008
Real-time Computer Vision With Ruby - OSCON 2008Jan Wedekind
 
Writing code that writes code - Nguyen Luong
Writing code that writes code - Nguyen LuongWriting code that writes code - Nguyen Luong
Writing code that writes code - Nguyen LuongVu Huy
 
TechkTalk #12 Grokking: Writing code that writes code – Nguyen Luong
TechkTalk #12 Grokking: Writing code that writes code – Nguyen LuongTechkTalk #12 Grokking: Writing code that writes code – Nguyen Luong
TechkTalk #12 Grokking: Writing code that writes code – Nguyen LuongGrokking VN
 
Gae icc fall2011
Gae icc fall2011Gae icc fall2011
Gae icc fall2011Juan Gomez
 

Semelhante a Lego For Engineers - Dependency Injection for LIDNUG (2011-06-03) (20)

Clean Code - Design Patterns and Best Practices for Bay.NET SF User Group (01...
Clean Code - Design Patterns and Best Practices for Bay.NET SF User Group (01...Clean Code - Design Patterns and Best Practices for Bay.NET SF User Group (01...
Clean Code - Design Patterns and Best Practices for Bay.NET SF User Group (01...
 
Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...
Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...
Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...
 
Clean Code I - Best Practices
Clean Code I - Best PracticesClean Code I - Best Practices
Clean Code I - Best Practices
 
Clean Code Part i - Design Patterns and Best Practices -
Clean Code Part i - Design Patterns and Best Practices -Clean Code Part i - Design Patterns and Best Practices -
Clean Code Part i - Design Patterns and Best Practices -
 
2009 Dotnet Information Day: More effective c#
2009 Dotnet Information Day: More effective c#2009 Dotnet Information Day: More effective c#
2009 Dotnet Information Day: More effective c#
 
TWINS: OOP and FP - Warburton
TWINS: OOP and FP - WarburtonTWINS: OOP and FP - Warburton
TWINS: OOP and FP - Warburton
 
Use of Apache Commons and Utilities
Use of Apache Commons and UtilitiesUse of Apache Commons and Utilities
Use of Apache Commons and Utilities
 
The software design principles
The software design principlesThe software design principles
The software design principles
 
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
 
Java Day-3
Java Day-3Java Day-3
Java Day-3
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
designpatterns_blair_upe.ppt
designpatterns_blair_upe.pptdesignpatterns_blair_upe.ppt
designpatterns_blair_upe.ppt
 
SOLID & IoC Principles
SOLID & IoC PrinciplesSOLID & IoC Principles
SOLID & IoC Principles
 
Cut your Dependencies with Dependency Injection - .NET User Group Osnabrueck
Cut your Dependencies with Dependency Injection - .NET User Group OsnabrueckCut your Dependencies with Dependency Injection - .NET User Group Osnabrueck
Cut your Dependencies with Dependency Injection - .NET User Group Osnabrueck
 
Parsley & Flex
Parsley & FlexParsley & Flex
Parsley & Flex
 
From Android NDK To AOSP
From Android NDK To AOSPFrom Android NDK To AOSP
From Android NDK To AOSP
 
Real-time Computer Vision With Ruby - OSCON 2008
Real-time Computer Vision With Ruby - OSCON 2008Real-time Computer Vision With Ruby - OSCON 2008
Real-time Computer Vision With Ruby - OSCON 2008
 
Writing code that writes code - Nguyen Luong
Writing code that writes code - Nguyen LuongWriting code that writes code - Nguyen Luong
Writing code that writes code - Nguyen Luong
 
TechkTalk #12 Grokking: Writing code that writes code – Nguyen Luong
TechkTalk #12 Grokking: Writing code that writes code – Nguyen LuongTechkTalk #12 Grokking: Writing code that writes code – Nguyen Luong
TechkTalk #12 Grokking: Writing code that writes code – Nguyen Luong
 
Gae icc fall2011
Gae icc fall2011Gae icc fall2011
Gae icc fall2011
 

Mais de Theo Jungeblut

Accidentally Manager – A Survival Guide for First-Time Engineering Managers
Accidentally Manager – A Survival Guide for First-Time Engineering ManagersAccidentally Manager – A Survival Guide for First-Time Engineering Managers
Accidentally Manager – A Survival Guide for First-Time Engineering ManagersTheo Jungeblut
 
Clean Code III - Software Craftsmanship
Clean Code III - Software CraftsmanshipClean Code III - Software Craftsmanship
Clean Code III - Software CraftsmanshipTheo Jungeblut
 
Cut your Dependencies with - Dependency Injection for South Bay.NET User Grou...
Cut your Dependencies with - Dependency Injection for South Bay.NET User Grou...Cut your Dependencies with - Dependency Injection for South Bay.NET User Grou...
Cut your Dependencies with - Dependency Injection for South Bay.NET User Grou...Theo Jungeblut
 
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...Theo Jungeblut
 
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...Theo Jungeblut
 
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...Theo Jungeblut
 
Clean Code II - Dependency Injection at SoCal Code Camp San Diego (07/27/2013)
Clean Code II - Dependency Injection at SoCal Code Camp San Diego (07/27/2013)Clean Code II - Dependency Injection at SoCal Code Camp San Diego (07/27/2013)
Clean Code II - Dependency Injection at SoCal Code Camp San Diego (07/27/2013)Theo Jungeblut
 

Mais de Theo Jungeblut (7)

Accidentally Manager – A Survival Guide for First-Time Engineering Managers
Accidentally Manager – A Survival Guide for First-Time Engineering ManagersAccidentally Manager – A Survival Guide for First-Time Engineering Managers
Accidentally Manager – A Survival Guide for First-Time Engineering Managers
 
Clean Code III - Software Craftsmanship
Clean Code III - Software CraftsmanshipClean Code III - Software Craftsmanship
Clean Code III - Software Craftsmanship
 
Cut your Dependencies with - Dependency Injection for South Bay.NET User Grou...
Cut your Dependencies with - Dependency Injection for South Bay.NET User Grou...Cut your Dependencies with - Dependency Injection for South Bay.NET User Grou...
Cut your Dependencies with - Dependency Injection for South Bay.NET User Grou...
 
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
 
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
 
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
 
Clean Code II - Dependency Injection at SoCal Code Camp San Diego (07/27/2013)
Clean Code II - Dependency Injection at SoCal Code Camp San Diego (07/27/2013)Clean Code II - Dependency Injection at SoCal Code Camp San Diego (07/27/2013)
Clean Code II - Dependency Injection at SoCal Code Camp San Diego (07/27/2013)
 

Último

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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 

Último (20)

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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
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...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Lego For Engineers - Dependency Injection for LIDNUG (2011-06-03)

  • 1. Lego for Engineers How to build Reusable and Maintainable Applications in C# Lego (trademarked in capitals as LEGO) Theo Jungeblut 06/03/2011
  • 2. Theo Jungeblut • Senior Software Developer at Omnicell Inc. in Mountain View • Has been designing and implementing .NET based applications , components and frameworks for 8 years • Previously worked in factory automation with focus on component based software and framework development for 3 ½ years theo@csharp-lighthouse.com • Degree in Software Engineering and Network Communications www.csharp-lightouse.com
  • 3. Overview • Why Lego for Software Engineers? • Design Patterns, Principles and Best Practices • Dependency Injection Container & more • The “Must Read”-Book • Summary • Q&A • References 3
  • 4. Why Lego for Software Engineers? Lego (trademarked in capitals as LEGO) is a line of construction toys manufactured by the Lego Group http://upload.wikimedia.org/wikipedia/commons/7/75/Lego_technic_gears.jpg 4
  • 5. Design Patterns, Principals & Best Practices • Keep it simple stupid (KISS) • Separation of Concerns (SoC) • Single Responsibility Principle (SRP) • Component Oriented Programming (CoP) • Interface / Contract • Don’t Repeat Yourself (DRY) • Dependency Inversion Principal (DIP) • Inversion of Control (IoC) • Constructor Injection • Setter Injection • Interface Injection • Service Locator 5
  • 6. Keep it simple, stupid (KISS)
  • 7. KISS-Principle – “Keep It Simple Stupid” by Kelly Johnson http://blogs.smarter.com/blogs/Lego%20Brick.jpg 7
  • 8. The Power of Simplicity Graphic by Nathan Sawaya courtesy of brickartist.com Graphic by Nathan Sawaya courtesy of brickartist.com 8 http://www.geekalerts.com/lego-iphone/
  • 9. Graphic by Nathan Sawaya courtesy of brickartist.com
  • 10. Separation of Concerns (SoC) Single Responsibility Principle (SRP)
  • 12. Component / Service http://www.technicopedia.com/8865.html
  • 13. Class, Struct, Enum etc. http://technicbricks.blogspot.com/2009/06/tbs-techpoll-12-results-2009-1st.html
  • 14. Separation of Concerns (SoC) probably by Edsger W. Dijkstra in 1974 • “In computer science, separation of concerns (SoC) is the process of separating a computer program into distinct features that overlap in functionality as little as possible. •A concern is any piece of interest or focus in a program. Typically, concerns are synonymous with features or behaviors. “ http://en.wikipedia.org/wiki/Separati on_of_Concerns 14
  • 15. Single Responsibility Principle (SRP) by Robert C Martin “Every object should have a single responsibility, and that responsibility should be entirely encapsulated by the class.” http://en.wikipedia.org/wiki/Single_responsibility_principle public class Logger : ILogger { public Logger(ILoggingSink loggingSink) {} public void Log(string message) {} } http://www.ericalbrecht.com 15
  • 16. Component-Oriented Programming (CoP)
  • 17. Different Ways of doing Something Similar http://www.ericalbrecht.com http://www.julianaheng.com/transformers-rotf-bumblebee- and-sam-action-figures/ http://www.ericalbrecht.com 17
  • 18. Why Reusable Components Rock http://www.ericalbrecht.com/technic/8020/8020all.jpg 18
  • 19. Interfaces / Contracts • Decouple Usage and Implementation through introduction of a contract • Allows to replace implementation without changing the consumer public interface ILogger public class Logger : ILogger { { void Log(string message); public Logger(ILoggingSink loggingSink) } {} public void Log(string message) {} } 19
  • 21. Don’t repeat yourself (DRY) by Andy Hunt and Dave Thomas in their book “The Pragmatic Programmer” // Code Copy and Paste Method // DRY Method public Class Person public Class Person { { public string FirstName { get; set;} public string FirstName { get; set;} public string LastName { get; set;} public string LastName { get; set;} public Person(Person person) public Person(Person person) { { this.FirstName = string.IsNullOrEmpty(person.FirstName) this.FirstName = person.FirstName.CloneSecured(); ? string.Empty : (string) person.FirstName.Clone(); this.LastName = person.LastName.CloneSecured(); } this.LastName = string.IsNullOrEmpty(person.LastName) ? string.Empty : (string) person.LastName.Clone(); public object Clone() } { return new Person(this); public object Clone() } { } return new Person(this); } } public static class StringExtension { public static string CloneSecured(this string original) { return string.IsNullOrEmpty(original) ? string.Empty : (string)original.Clone(); } } 21
  • 23. Dependency Inversion Principle (DIP) by Robert C. Martin • “High-level modules should not depend on low-level modules. Both should depend on abstractions. • Abstractions should not depend upon details. Details should depend upon abstractions.” http://en.wikipedia.org/wiki/Dependency_inversion_principle 23
  • 24. S Single Responsibility Principle O Open/Closed Principle L Liskov Substitution Principle I Interface Segregation Principle D Dependency Inversion Principle Robert C Martin: http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod
  • 26. Inversion of Control (IoC) by Martin Fowler 1994 Logger logger = new Logger(); 26
  • 27. Inversion of Control (IoC) by Martin Fowler 1994 Logger logger = new Logger(); 27
  • 28. The “Must Read”-Book by Mark Seemann Dependency Injection is a set of software design principles and patterns that enable us to develop loosely coupled code. 28 http://www.manning.com/seemann/
  • 29. Inversion of Control – Constructor Injection http://www.martinfowler.com/articles/injection.html public class ContactManager : IContactManager { public ContactManager(ILogger logger, IContactPersistence contactPersistence) { this.logger = logger; if (logger == null) { throw new ArgumentNullException("logger"); } … } } 29
  • 30. Inversion of Control – Setter (Property) Injection http://www.martinfowler.com/articles/injection.html // UNITY Example public class ContactManager : IContactManager { [Dependency] public IContactPersistence ContactPersistence { get { return this.contactPersistence; } set { this.contactPersistence = value; } } } 30
  • 31. Inversion of Control (IoC) – Interface Injection http://www.martinfowler.com/articles/injection.html In this methodology we implement an interface from the IOC framework. IOC framework will use the interface method to inject the object in the main class. You can see in figure ‘Interface based DI’ we have implemented an interface ‘IAddressDI’ which has a ‘setAddress’ method which sets the address object. This interface is then implemented in the customer class. External client / containers can then use the ‘setAddress’ method to inject the address object in the customer object. http://www.codeproject.com/KB/aspnet/IOCDI/InterfacebasedDI.JPG http://www.codeproject.com/KB/aspnet/IOCDI.aspx 31
  • 32. Inversion of Control – Service Locator http://www.martinfowler.com/articles/injection.html // UNITY Example internal static class Program { private static UnityContainer unityContainer; private static SingleContactManagerForm singleContactManagerForm; private static void InitializeMainForm() { singleContactManagerForm = unityContainer.Resolve<SingleContactManagerForm>(); } } 32
  • 33. Inversion of Control – Service Locator http://www.martinfowler.com/articles/injection.html // UNITY Example internal static class Program { private static UnityContainer unityContainer; private static SingleContactManagerForm singleContactManagerForm; private static void InitializeMainForm() { singleContactManagerForm = unityContainer.Resolve<SingleContactManagerForm>(); } } 33
  • 34. Inversion of Control Service Locator vs Dependency Injection • Service Locator allows to request explicitly the needed instance/type/service • Every user of a service has a dependency to the Service Locator • Potential issue if the component need to be provided to 3rd parties. • Favorable for closed platforms as the Service Locator allow more control • Testing is easier with Dependency Injection than a Service Locator if Service provided is not easily substituted • In general Service Locator is only the less compelling choice if the code is mainly used out of the control of the writer 34 http://www.martinfowler.com/articles/injection.html#ServiceLocatorVsDependencyInjection
  • 35. Dependency Injection Container & more • Typically support all types of Inversion of Control mechanisms • Constructor Injection • Property (Setter) Injection • Interface Injection • Service Locator •.NET based DI-Container • Unity • Castle Windsor • StructureMap Related Technology: • Spring.NET • Managed Extensibility Framework (MEF) • Autofac • Windows Communication Foundation (WCF) • Puzzle.Nfactory • Ninject • PicoContainer.NET • and more 35
  • 36. The “Must Read”-Book by Mark Seemann 36 http://www.manning.com/seemann/
  • 37. Summary Improving Reusability and Maintainability through: • Simplification and Specialization (KISS, SoC, SRP) •Decoupling (Interfaces, CoP, DIP or SOA) • Avoiding Code Blow (DRY, YAGNI) • Testability (all of them!) Lego (trademarked in capitals as LEGO) 37
  • 38. Q&A Feedback & Comments: theo@csharp-lighthouse.com www.csharp-lighthouse.com Graphic by Nathan Sawaya courtesy of brickartist.com
  • 39. References Part http://www.manning.com/seemann/ http://en.wikipedia.org/wiki/Keep_it_simple_stupid http://picocontainer.org/patterns.html http://en.wikipedia.org/wiki/Separation_of_concerns http://en.wikipedia.org/wiki/Don't_repeat_yourself http://en.wikipedia.org/wiki/You_ain't_gonna_need_it http://en.wikipedia.org/wiki/Component-oriented_programming http://en.wikipedia.org/wiki/Service-oriented_architecture http://www.martinfowler.com/articles/injection.html http://www.codeproject.com/KB/aspnet/IOCDI.aspx http://msdn.microsoft.com/en-us/magazine/cc163739.aspx http://msdn.microsoft.com/en-us/library/ff650320.aspx http://msdn.microsoft.com/en-us/library/aa973811.aspx http://msdn.microsoft.com/en-us/library/ff647976.aspx http://msdn.microsoft.com/en-us/library/cc707845.aspx http://msdn.microsoft.com/en-us/library/bb833022.aspx http://dotnetslackers.com/articles/net/A-First-Look-at-Unity-2-0.aspx http://unity.codeplex.com/ http://www.idesign.net/idesign/DesktopDefault.aspx?tabindex=5&tabid=11 39