The Joel Test (Joel On Software) Do you use source control? SVN Can you make a build in one step? make or IDE Do you make daily builds? N/A Do you have a bug database? N/A or is it? Do you fix bugs before writing new code? You SHOULD Do you have an up-to-date schedule? Do you have a spec? Do programmers have quiet working conditions? Do you use the best tools money can buy? Do you have testers? Do new candidates write code during their interview? Do you do hallway usability testing?
Design Patterns
Gang of Four
Design Patterns A design pattern is a general, repeatable solution to a commonly occurring problem in software design. A description or template for how to solve a problem that can be used in many different situations. (Wikipedia)
Design Patterns are not designs that can be transformed directly into code are not algorithms Algorithms deal with computational problems, not design problems
Uses Speed up design process by providing tested, proven design paradigms Allow developers to communicate using well-known, well understood names for software interactions
Criticisms Targets the wrong problem Lacks formal foundations Unlike components, does not provide reuse Leads to inefficient solutions Does not differ significantly from other abstractions
Important Sections of Design Structure Participants Collaboration Patterns These sections describe a design motif: : a prototypical micro-architecture that developers copy and adapt to their particular designs to solve the recurrent problem described by the design pattern
Structure Section A graphical representation of the pattern. Class diagrams and interaction diagrams may be used for this purpose.
Participants Section A listing of the classes and objects used in the pattern and their roles in the design.
Collaboration Section A description of how classes and objects used in the pattern interact with each other.
Classification Creational Structural Behavioral Fundamental Concurrency Architectural
How Does One Create a Pattern?
How Does One Create a Pattern? Patterns are not created or invented. They are discovered and documented.
Documentation Pattern Name and Classification Intent Also Known As Motivation (Forces) Applicability Structure Participants Collaboration Consequences Implementation Sample Code Known Uses Related Patterns
Creational Deal with object creation mechanisms Singleton When only one instance of a class can exist Examples: recover program A game loop
Structural ease the design by identifying a simple way to realize relationships between entities Façade - provide a simplified interface to underlying subsystems - example: JDBC, ODBC
Behavioral identify common communication patterns between objects Observer Objects that display the data are different from those that contain the data Example: Stock price display Textual display Graphical display
Architectural Model-View-Controller Image editor Flight simulator Model: Simulation View: Display(s) Controller: Flight controls
Flight Simulator (or FPS, for that matter) Model: simulation Environment Flight physics View: displays Multiple out the window displays Alternate perspectives Wingman view Adversary view Controller: Simulation Inputs Flight controls Environment
Model-View-Controller (Sun)
Model-View-Controller (Sun)
Model-View-Controller The Model-View-Controller ("MVC") design pattern decouples the model from its view, enabling loose coupling and the ability to change one without affecting the other. http://www.exciton.cs.rice.edu/javaresources/designpatterns/mvc.htm
Model-View The model should operate independently from the manner in which the view interacts with the user. The view should be tailored to meet the interaction needs of the user, independent of the model below it.
Controller the controller is responsible for mapping end-user action to application response The mouse click or the keyboard press maps to an action In games, you can configure your controls
Anti-Patterns Commonly-reinvented bad solutions to problems (Wikipedia)
Anti-Patterns Project management Design OO Design Programming Methodological Configuration Management
Programming Anti-patterns Copy and paste programming Programming by permutation: Trying to approach a solution by successively modifying the code to see if it works Golden hammer: Assuming that a favorite solution is universally applicable Silver bullet: Assuming that a favorite or technical solution can solve a larger process or problem. Premature optimization: Optimization on the basis of insufficient information Reinventing the wheel: Failing to adopt an existing, adequate solution Reinventing the square wheel: Creating a poor solution when a good one exists
Framework a framework can be viewed as the implementation of a system of design patterns Design patterns are more abstract than frameworks Design patterns are smaller architectural elements than frameworks Design patterns are less specialized than frameworks (Brad Appleton - )
To Learn More Wikipedia Portland Pattern Repository: c2.com/ppr/ Hillside Group: hillside.net/patterns/ Design Patterns Java Companion: www.patterndepot.com/put/8/javapatterns.htm