Software Design Patterns Anton Danshin Moscow Institute of













- Slides: 13
Software Design Patterns Anton Danshin Moscow Institute of Physics and Technology Dolgoprudny - 2012
Contents 2 What is it? Why do we use it? Classification Example Criticism Anti-patterns Conclusion
What is it? 3 General repeatable solution to a commonly occurring problem in software design Description or template for how to solve a problem that can be used in many different situations
Why do we use it? Speed up development process Prevent future problems Ease comunication between developers Make your code better Simplicity is the soul of efficiency. -- Austin Freeman, "The Eye of Osiris" 4
Classification of design patterns Creational: Structural: 5 Adapter, Bridge, Composite, Decorator, Proxy, . . . Behavioral: Abstract factory, Builder, Factory method, Prototype, Singleton, . . . Chain of responsibility, Command, Iterator, Mediator, Strategy, . . . Concurrent
Example 1: Singleton Intent: Create a single-instance class Provide a global point of access to it Encapsulate initialization Problems 6 Application needs one, and only one, instance of an object. Lazy initialization and global access are necessary
Example 1: Singleton 7
Example 1: Singleton (Java) 8
Criticism Targets the wrong problem Lacks formal foundations Leads to inefficient solutions Do not overuse! 9
Anti-Patterns 10 Copy and Paste Programming Soft Code Reinventing the Wheel Spaghetti Code Golden Hammer Magic Numbers Blind Faith Hard Code Brute Force Coding Boat Anchor God Object Reinventing the Square Wheel Unnecessary comments
Conclusion Using design patterns makes your code better Design patterns are devided into: 11 Design pattern is a general solution to a commonly occurring problem in software design Creational Behavioral Structural Concurrent Do NOT OVERUSE design patterns
References 1. Source. Making. com – Software Design Patterns http: //sourcemaking. com/design_patterns 2. Wikipedia http: //en. wikipedia. org/wiki/Software_design_pattern 3. Habra. Habr. Ru http: //habrahabr. ru/blogs/refactoring/59005/ 12
Thanks for your attention!













