Pattern Documentation Template (Part Three)

Pattern Documentation – Detailed Template (preferred):

  • Design & Implementation Issues: For each EBT, discuss the important issues required for linking the analysis phase to the design phase and For each BO, discuss the important issues required for linking the design phase to the implementation phase, for example hooks.

Length: 1/4 – 1 Pgs Max
Design Issues (EBT)
For example hooking issues
Implementation Issues (BO)
For example why using aggregation or delegation rather than inheritance
For example hooking, hot spots problems
Can show code here.
Here is a list of Analysis Issues:
  • Divide and conquer
  • Understanding
  • Simplicity
  • One unique base that suitable to many applications
  • Goals
  • Fitting with business modeling
  • Requirements Specifications Models
  • Packaging
  • Components
  • Type (TOP) (A)
  • Actors/Roles
  • Responsibility and Collaborations
  • Generic and Reusable models
  • Etc,
Here is a list of design and implementation issues:
  • Framework models (D)
  • Static Models (D)
  • Classes (TOP) (D)
  • Collaborations (D)
  • Refinement (D)
  • Generic and Reusable Designs (D)
  • Precision (I)
  • Hooks (I)
  • Pluggable Parts (I)
  • Navigation (I)
  • Object Identity (I)
  • ObjectState (I)
  • Associations/Aggregations (I)
  • Collections (I)
  • Static Invariants (I)
  • Boolean Operators (I)
  • Collection Operators (I)
  • Dictionary (D) (I)
  • Behavior models (D) (I)
  • Pre-Post-conditions specify actions (I)
  • Joint Actions (Use Cases) (D)
  • Localized Actions (I)
  • Action Parameters (I)
  • Actions and Effects (I)
  • Concurrent Actions (I)
  • Collaborations (I)
  • Interaction Diagrams (D)
  • Sequence Diagrams with Actions (D) (I)
  • Pattern 1: Continuity
  • Pattern 2: Performance
  • Pattern 3: Reuse
  • Pattern 4: Flexibility
  • Pattern 5: Orthogonal Abstractions
  • Pattern 6: Refinement
  • Pattern 7: Deliverables
  • Pattern 8: Recursive Refinement
  • Package (D) (I)
Here is a list of Java Patterns:
  • Fundamental Design Patterns
  • Delegation (When not to use Inheritance)
  • Proxy
  • Creational Patterns
  1. Abstract Factory
  2. Builder
  3. Factory Method
  4. Object Pool
  5. Prototype
  6. Singleton
  • Partitioning Patterns
  1. Composite
  2. Filter
  3. Layered Initialization
  • Structural Patterns
  1. Adaptor
  2. Bridge
  3. Cache Management
  4. Decorator
  5. Dynamic Linkage
  6. Façade
  7. Flyweight
  8. Iterator
  9. Virtual Proxy
  • Behavioral Patterns
  1. Chain of Responsibility
  2. Command
  3. Little Language / Interpreter
  4. Mediator
  5. Null Object
  6. Observer
  7. Snapshot
  8. State
  9. Strategy
  10. Template Method
  11. Visitor
Here is a list of UML Patterns:
  • GRASP Patterns
  1. Controller
  2. Creator
  3. Expert
  4. Law of Demeter
  5. Low Coupling/High Cohesion
  6. Polymorphism
  7. Pure Fabrication
  • Organizational Coding Patterns
  1. Accessor Method Name
  2. Anonymous Adapter
  3. Checked versus Unchecked Exceptions
  4. Client Socket
  5. Composed Method
  6. Conditional Compilation
  7. Covert Exceptions
  8. Define Constants in Interfaces
  9. Extend Super
  10. Intention Revealing Method
  11. Server Socket
  12. Switch
  13. Symbolic Constant Name
  • Code Optimization Patterns
  1. Double Checked Locking
  2. Hashed Adapter Objects
  3. Lazy Initialization
  4. Lookup Table
  5. Loop Unrolling
  • Code Robustness
1. Assertion Testing
2. Copy Mutable Parameters
3. Guaranteed Cleanup
4. Maximize Privacy

Example (1):

Pattern Name: AnyPattern Stable Analysis or Design Pattern
Delegation(When not to use Inheritance) [1]: within the context with our pattern.
a. Show an example of using delegation instead of inheritance within the application of the pattern
b. describe the context
c. Describe the challenges and constraints
d. Describe the solution
e. List and briefly discuss the consequences
f. Discuss Implementation with sample code.
References:
[1]Mark Grand. Patterns in Java I – A Catalog of Reusable Design Patterns Illustrated with UML. John Willey & Sons, Inc. 1998.

Example (2):

Pattern Name: AnyPattern Stable Analysis or Design Pattern
Proxy [1]: within the context with our pattern.
a. Show an example of using proxy pattern within the application of the pattern
b. describe the context
c. Describe the challenges and constraints
d. Describe the solution
e. List and briefly discuss the consequences
f. Discuss Implementation with sample code.
References:
[1] Mark Grand. Patterns in Java I – A Catalog of Reusable Design Patterns Illustrated with UML. John Willey & Sons, Inc. 1998.

Example (3):

Pattern Name: AnyPattern Stable Analysis or Design Pattern
Factory Method [1, 2]: within the context with our pattern.
a. Show an example of using factory method pattern within the application of the pattern
b. describe the context
c. Describe the challenges and constraints
d. Describe the solution
e. List and briefly discuss the consequences
f. Discuss Implementation with sample code.
References:
[1] Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. Design Pattern – the Element of Reusable Object-Oriented Software, Reading, Mass., Addison-Wesley, 1995.
[2] Mark Grand. Patterns in Java I – A Catalog of Reusable Design Patterns Illustrated with UML. John Willey & Sons, Inc. 1998.
You may repeat the above with any of the creation patterns: Abstract Factory, Builder, Prototype, Singleton, and Object Pool

Example (4):

Pattern Name: AnyPattern Stable Analysis or Design Pattern
Filter[1, 2]: within the context with our pattern.
a. Show an example of using filter pattern within the application of the pattern
b. describe the context
c. Describe the challenges and constraints
d. Describe the solution
e. List and briefly discuss the consequences
f. Discuss Implementation with sample code.
References:
[1]F. Buschmann et, al,.A System of Patterns, UK, John Willey & Sons, Inc. 1996..
[2] Mark Grand. Patterns in Java I – A Catalog of Reusable Design Patterns Illustrated with UML. John Willey & Sons, Inc. 1998.
You may repeat the above with any of the partitioning patterns: Layered Initialization and Composite

Example (5):

Pattern Name: AnyPattern Stable Analysis or Design Pattern
Adapter[1, 2]: within the context with our pattern.
a. Show an example of using adapter pattern within the application of the pattern
b. describe the context
c. Describe the challenges and constraints
d. Describe the solution
e. List and briefly discuss the consequences
f. Discuss Implementation with sample code.
References:
[1] Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. Design Pattern – the Element of Reusable Object-Oriented Software, Reading, Mass., Addison-Wesley, 1995.
[2] Mark Grand. Patterns in Java I – A Catalog of Reusable Design Patterns Illustrated with UML. John Willey & Sons, Inc. 1998.
You may repeat the above with any of the structural patterns: Iterator, Bridge, Façade, Flyweight, virtual Proxy, decorator, etc.

Example (6):

Pattern Name: AnyPattern Stable Analysis or Design Pattern
Observer [1, 2]: within the context with our pattern.
a. Show an example of using observer pattern within the application of the pattern
b. describe the context
c. Describe the challenges and constraints
d. Describe the solution
e. List and briefly discuss the consequences
f. Discuss Implementation with sample code.
References:
[1] Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. Design Pattern – the Element of Reusable Object-Oriented Software, Reading, Mass., Addison-Wesley, 1995.
[2] Mark Grand. Patterns in Java I – A Catalog of Reusable Design Patterns Illustrated with UML. John Willey & Sons, Inc. 1998.
You may repeat the above with any of the behavioral patterns: Chain of Responsibility, Command, Mediator, Snapshot, State, Null Object, Strategy, Template Method, Visitor, etc.

Example (7):

Pattern Name: AnyPattern Stable Analysis or Design Pattern
Law of Demeter [1, 2]: within the context with our pattern.
a. Show an example of using law of Demeter pattern within the application of the pattern
b. describe the context
c. Describe the challenges and constraints
d. Describe the solution
e. List and briefly discuss the consequences
f. Discuss Implementation with sample code.
References:
[1] Craig Larman. Applying UML and Patterns. Upper Saddle River, N.J.:Prentice Hall PTR, 1998.
[2] Mark Grand. Patterns in Java 2 – Vol. 2, John Willey & Sons, Inc. 1999.
You may repeat the above with any of the GRASP patterns: Low Coupling/High Cohesion, Expert, Creator, Polymorphism, Pure Fabrication, and Controller.

Example (8):

Pattern Name: AnyPattern Stable Analysis or Design Pattern
Anonymous Adapter [1]: within the context with our pattern.
a. Show an example of using anonymous adapter pattern within the application of the pattern
b. describe the context
c. Describe the challenges and constraints
d. Describe the solution
e. List and briefly discuss the consequences
f. Discuss Implementation with sample code.
References:
[1] Mark Grand. Patterns in Java 2 – Vol. 2. John Willey & Sons, Inc. 1999.
You may repeat the above with any of the organizational coding patterns: Checked and Unchecked Exceptions, Client Socket, Composed Method, Convert Exceptions, Extend Super, Intention Revealing Method, Server Socket, Switch, and Symbolic Constant Name..

Example (9):

Pattern Name: AnyPattern Stable Analysis or Design Pattern
Lazy Initialization[1, 2]: within the context with our pattern.
a. Show an example of using lazy initialization pattern within the application of the pattern
b. describe the context
c. Describe the challenges and constraints
d. Describe the solution
e. List and briefly discuss the consequences
f. Discuss Implementation with sample code.
References:
[1]Kent Beck. Smalltalk Best Practice Patterns. Upper Saddle River, N.J.: Prentice Hall PTR, 1998.
[2] Mark Grand. Patterns in Java 2 – Vol. 2. John Willey & Sons, Inc. 1999.
You may repeat the above with any of the Code Optimization patterns: Double Checked :Locking, Hashed Adapter Objects, Lookup Table, and Loop Unrolling...

Example (10):

Pattern Name: AnyPattern Stable Analysis or Design Pattern
Assertion Testing [1]: within the context with our pattern.
a. Show an example of using assertion testing pattern within the application of the pattern
b. describe the context
c. Describe the challenges and constraints
d. Describe the solution
e. List and briefly discuss the consequences
f. Discuss Implementation with sample code.
References:
[1] Mark Grand. Patterns in Java 2 – Vol. 2. John Willey & Sons, Inc. 1999.
You may repeat the above with any of the Code Robustness patterns: Copy Mutable Parameters, Guaranteed Cleanup, Maximize Privacy, etc.

Detailed Example:

Pattern Name: Discovery Stable Analysis Pattern
For a design pattern to be useful and applicable across many different problem domains, it must represent an enduring business theme (EBT), which defines the core value of the pattern, and which can withstand the change of time. For the Discovery pattern, the EBT is identified to be that of discovery. Discovery is the enduring concept of observing, finding and noting things that are not know to anyone before. This enduring concept must maintain its characteristics in different application. While analyzing the mapping concept, we identify a set of Business Objects that form the basis of the discovery pattern. These business Objects are also very stable and extendable into different industrial objects depending on the application. Therefore, discovery is the process of making AnyDiscovery by AnyParty. How any discovery is made is encapsulated by AnyDiscoveryMechanism and can be influenced by AnyEvidence. All these business objects are stable and generic enough that they will not change when discovery is applied in various contexts or over time.
To apply the discovery pattern to a particular application, we look for industrial objects that are extensible from the business objects and are tangible objects that reflect the true problem domain. Industrial objects generally are not stable and may need to be modified over time. However, since the BO layer remain stable and the EBT last over time, any possible changes are restricted to the IO layer only.
Stability Model is based on EBTs, BOs, and IOs. The EBTs used are general so that it can be applied in various domains. But there are few implementation issues which we have to deal with . They are as follows,

Delegation vs. Inheritance

Model implemented with Inheritance.

The above model is static and fix. Country and WHO are the sub-classes here which inherits attribute, operations and methods from AnyParty. If any change happens in
AnyParty then it will reflect in all the sub-classes even if that change is not needed for all sub-classes concerned here. In other words ,super class will not hide any methods from its sub-classes.
Model Implemented with delegation.
The model below shows use of delegation instead of inheritance. How it affects the modeling pattern is an interesting feature. Delegation provides dynamism i.e. run-time flexibility which is one of the distinct feature. Rest of the characteristics are similar to inheritance as it also provides reuse technique. Dynamic coupling between super-class and sub-class is the key feature.

In this case the same sub-model is implemented using delegation instead of inheritance. Now ,even if super-class adds some changes ,it will not reflect in all sub-classes because of delegation as it provides dynamic run-time linking by invoking call from one object in super-class to the object in concerned sub-class. Now , if some additional rules needs to be implemented for WHO guidelines then ,all we need to do is create a separate method for WHO Rules and then pass the object to WHO sub-class. So, in this case that particular change will not be seen in Country sub-class. In other words, super class can hide its methods from sub-classes.
The code for the delegation example taken is as below:
public class anyparty{
public void publichealth(system.out.println('public health issue'));
public void population(system.out.println('number of people in the country'));
}
public class who
{
anyparty a = new anyparty();
public void publichealth(a.publichealth());
}
public class country
{
anyparty b = new anyparty();
public void population(b.population());
}
The above code shows how class WHO creates an object and delegates the class AnyParty by using that object to invoke the method in class AnyParty. Thus, it will use the relevant methods from class AnyParty for its own class. In this way, class AnyParty can hide its methods from other classes which don’t require that methods

1