OVERVIEW
This course is designed for developers who want to extend their architectural skills using design patterns and related techniques. It is heavily interactive with delegates spending the majority of their time creating pattern based solutions to real world problems. In addition to implementing pattern based designs from scratch delegates incrementally refactor existing codebases to improve quality, introduce idioms and refactor towards patterns.Each pattern is introduced in terms of its abstract structure (via UML diagrams), its benefits and drawbacks, sample implementations and practical examples of how it can be used to simplify software development.
The course makes extensive use of JSE libraries and JEE frameworks as examples of pattern based design. In particular OSGi is used as a case-study of good architecture. Examples are also drawn from other Programming languages (C++, C#, Scala, F# and Ruby) where appropriate.
PRE-REQUISITES
Delegates should be experienced Java developers familiar with UML Sequence and Class diagrams.COURSE CONTENT
An Introduction To OO Design
• The distinction between analysis, design and implementation
• The (de)emphasis placed on design in Agile methodologies
• Comparing 'Agile Modeling' with conventional OOAD
• Do JEE containers and frameworks replace design?
Introduction to Patterns
• What is a design pattern?
• The evolution of design patterns
• Misconceptions about design patterns
• The dangers of becoming 'pattern happy'
• Distinguishing between patterns, idioms and refactorings
• Using refactorings to introduce patterns incrementally
• Using patterns to create an object oriented architecture
Proxy
• Adding services by intercepting messages
• Dynamically creating proxy classes in Java via Reflection
• How proxy objects are used in Enterprise JavaBeans
• How proxy objects are used to implement AOP in Spring
• The interception framework provided with .NET
• Interception functionality built into Ruby
Factory
• Advantages of separating clients from object creation
• Comparing the Factory Method and Abstract Factory Patterns
• How Factory Method is used with writing custom class loaders
• Using Abstract Factory to conceal XML Parsers and DB Drivers
• Using Factory and Proxy to control access to pooled resources
• Extending the Factory Pattern into Dependency Injection
• Examples of Dependency Injection Tools (Spring and Guice)
Builder
• Simplifying the creation of complex object trees
• How Groovy uses Builder to generate XML documents
Composite
• Modelling nested whole-part relationships in OO
• Examples of Composite in XML and GUI libraries
Singleton
• Why ensure a class only has a single instance?
• General problems implementing Singleton objects
• Language specific problems with Singletons (Java/C#/C++)
• Allowing singletons to be reborn (Phoenix Singleton pattern)
• Making Singletons safe and efficient in multithreaded environments
• Problems with the double checked locking idiom
Strategy
• Creating class hierarchies to represent algorithms
• Separating a class from a changing or complex algorithm
• The Strategy Pattern, functor objects and threading libraries
• Strategy and Layout Managers in Swing and SWT
• How Strategy is used in the JMock mock object generator
Command
• Similarities between Srategy and Command
• Using Command objects to simplfy event dispatching
• Incrementally refactoring code to introduce Command
• Uses of the Command Pattern in JEE Web Frameworks
Template
• Using polymorphism to customize algorithms
• Similarities between Template and Factory Method
• The Template Pattern and rendering Swing components
• Template and the Struts JEE Web Framework
Decorator
• Using composition to layer extra functionality
• Applying Decorator to create specialized collections
• Decorator as the basis of the Java I/O libraries
Adapter
• Distinguishing between Adapter and Decorator
• Uses of adapter in the Java I/O libraries
Iterator
• Accessing an aggregate object without knowing its representation
• How Iterator is used in the STL and the Java and .NET collections
• Adding iterator support to your own collections
Observer
• Informing interested objects of state changes
• Benefits and dangers in implementing Observer
• The Observer Pattern and event handling in Java
• The Observer Pattern, delegates and events in C#
Visitor
• Simplifying class design by modelling operations as visitors
• Adding support for Visitor to existing collections of objects
• Using Visitor to add reporting and logging behaviour
• Code generation in Java with Visitor and the ASM library
• Using Visitor in the design of a mock objects generator
State
• Benefits of the State Pattern over subclassing
• Modelling objects with complex internal state transitions
• Different approaches to implementing state transitions
• Automatically generating state machines
Threading Patterns
• Implementing the Active Object Pattern in Java, C# and C++
• Worker thread pool implementations in Java and C# • Introducing the IOU (Asynchronous Completion Token) Pattern • Futures in Java and Asynchronous Delegates in C# • The Fork/Join Framework in Java 7
The OSGi Architecture
• Components of an OSGi implementation
• The static and dynamic parts of OSGi
• How bundles create separate class-spaces
• Consumer Bundles verses Service Bundles
• The lifecycle for bundles defined by the OSGi spec
• How conflicts between class versions are resolved
• Services provided by an OSGi implementation
• OSGi enhancements to standard Java security