Вы находитесь на странице: 1из 2

What are Design Patterns?

A design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. It is a description or template for how to solve a problem that can be used in many different situations. Patterns are formalized best practices that the programmer himself must implement in the application.[1] Object-oriented design patterns typically show relationships and interactions between classes or objects, without specifying the final application classes or objects that are involved. Patterns that imply object-orientation or more generally mutable state, are not as applicable in functional programming languages. A Design Patterns describe an optimal solution to a common recurring design problem within a specific context. Design patterns are optimized, reusable solutions to the programming problems that we encounter every day. Every author defined Design Patterns in slight variations but the essence is the same. The best in my opinion is by Christopher Alexander Each pattern is a three-part rule, which expresses a relation between a certain context, a problem, and a solution What are some of the characteristics of Design Patterns? 1. Patterns are observed through experience. 2. Patterns are typically written in a structured format. 3. Patterns prevent reinventing the wheel. 4. Patterns exist at different levels of abstraction. 5. Patterns undergo continuous improvement. 6. Patterns are reusable artifacts. 7. Patterns communicate designs and best practices. 8. Patterns can be used together to solve a larger problem. 9. Patterns have their own pros and cons What are the Pros and Cons of Design Patterns? Pros: 1. Combination of Patterns can offer reusable architectures / artifacts. 2. Helps in the improvement of developer community by standardizing the design principles. 3. Capture expert knowledge and design trade-offs on the recurring problems and make the expertise widely available.

4. Reusability with out having to re-invent the wheel. 5. Helps provide a high-level language for discussing design issues in software industry. 6. Provides much of the design work upfront. 7. Design Patterns can be applied at any point during the project life cycle. 8. Design Patterns provide a standard vocabulary for software designers. Cons: 1. Some of the Design Patterns are complex in nature. 2. They are simply validated by experience and discussion. 3. Design patterns may increase or decrease the understandability of a design or implementation. 4. They can decrease understandability by adding indirection or increasing the amount of code. Common Structure of Design Pattern All Design Patterns adopt a common structure that presents various attributes for a given Pattern. In general, a Design Pattern consists of the following attributes 1. Context Describes the environment under which the Pattern exists 2. Problem Describes the recurring design issue 3. Forces Helps us understand the driving forces of adopting a Design Pattern 4. Solution Describes the solution and its elements (Structure and Strategy) in detail 5. Consequences Identifies the pros and cons of using a pattern pattern 6. Sample Code 7. Related Patterns (if any)

Вам также может понравиться