DESIGN PATTERN CH0&Ch1

Telechargé par i love engineering
1
CHAPTER 0
DESIGN PATTERNS
INTRODUCTION
Common Design Patterns in C# 4.0
Design Patterns provide standardized and efficient solutions to software design and programming
problems that are re-usable in your code. Software Architects and developers use them to build high
quality robust applications.
However, you have to take care to select the right pattern for the right problem. If you need to modify
the initial pattern too much, this may indicate that it is not adapted to your needs and may in the worst
case lead to unmaintainable, complex and inefficient code. The opposite of what you intend when using
Design Patterns!!
You may also create your own custom Design Patterns. Whenever you come up with a certain solution
that is reusable in a vast majority of your projects, you may decide to abstract a design pattern out of it.
Then you may create your own library of patterns and share them within your whole company, thus
creating standards and ameliorating maintainability.
Authoring software requires a set of rules and methodologies to take your idea to center point without any
rework for future enhancements. In Software Engineering, we have a set of principles stated by Robert
Martin called SOLID principle. SOLID word has principles as Single Responsibility, Open Close, Liskov’s
Substitution, Interface Segregation and Dependency Inversion. Let me explain you about SOLID as one word
SOLID
Single Responsibility Principle There should be a one strong reason to change the class.
Open/Close Principle Entities should open only for adding new functionality and Close for any updates after
testing phase.
Liskov’s Substitution Principle – Functions accessing base class must be able to access derived class
Interface Segregation Principle Clients should use Interface members completely.
Dependency Inversion Principle High level modules and Details should depend on abstractions only.
Other Main Principles of Software design Engineering is
Dry (Don’t Repeat Yourself): Code should occur exactly once in the system.
2
KISS (Keep it Simple, Stupid!): Unnecessary complex code should be avoided.
YAGNI (You ain’t gonna need it): Implement the things when you need them
These principles results to maintain your software code as manageable, Scalable and reusable code and
results in faster development.
In point of code reusability Design Patterns are introduced. Design patterns are introduced by Christopher
Alexander in 1977, Kent Beck and Ward Cunningham in 1987. Design patterns are considered as reusable
solutions for commonly occurring problems in software designs. Advantages of design patterns are, they
provide solutions for commonly occurring problems in software designs, they can implement in any language,
provide standard terminology and specific to particular scenario. Design Patterns are categorized into 5
categories.
1. Creational Patterns
2. Structural Patterns
3. Behavioral Patterns
4. Model View Controller Patterns
5. Concurrency Patterns
Creational Patterns:
Creational Patterns are patterns deals with object Creations. Creational Patterns are applicable when:
1. A system should be independent of how its objects and products are creating.
2. Two or more objects designed to use each other.
3. Instance, can be extended without modification.
4. Sub class of a class wants to access class object.
5. Reveling interfaces of a product.
6. Constructing different independent Complex objects.
7. Single instance can be access all the time.
Structure of these creational patterns contains creation followed by its concrete creator. Creation Patterns
group contains 7 Design patterns.
1. Abstract Factory
2. Factory Method
3. Builder
4. Lazy Initialization
5. Object Pool
6. Prototype
7. Singleton
Structural Patterns:
Structural Design Patterns are used to define entity relationships in simple ways. Structural patterns use
inheritance to compose interfaces or implementations. Structural patterns are useful to develop
independent class libraries to work together.
Structural Patterns has 11 Patterns with it.
3
1. Adapter
2. Aggregate
3. Bridge
4. Composite
5. Decorator
6. Extensibility
7. Facade
8. Flyweight
9. Pipes and filters
10. Private Class Data
11. Proxy
Behavioral Patterns:
Behavioral Design Patterns identifies common communication between objects and realize these
patterns. These patterns increase the flexibility of communication between the objects.
Behavioral Patterns has 19 patterns.
1. Chain of responsibility
2. Command
3. Externalize the Stack
4. Hierarchical visitor
5. Interpreter
6. Iterator
7. Mediator
8. Memento
9. Null Object
10. Observer
11. Weak reference
12. Protocol stack
13. Scheduled-task
14. Single-serving visitor
15. Specification
16. State
17. Strategy
18. Template method
19. Visitor
Model-View-Controller:
Model View Controller design pattern has its own identity which has 3 inter connected parts, Model, View
and Controller. We use this mainly for User Interfaces.
Concurrency Patterns:
These Patterns mainly deals with Multi thread Programming. They were associated with Pattern Oriented
Software Architecture. Concurrency Patterns have 11 Patterns.
4
1. Active Object
2. Balking pattern
3. Double checked locking pattern
4. Guarded suspension
5. Leaders/followers pattern
6. Monitor Object
7. Reactor pattern
8. Read write lock pattern
9. Scheduler pattern
10. Thread pool pattern
11. Thread-Specific Storage
5
Chapter1
Creational patterns
Topics:
Introduction
What are creational design patterns?
Abstract factory
o Structural code example
o Real world example
Builder
o Structural code example
o Real world example
Factory method
o Structural code example
o Real world example
Prototype
o Structural code example
o Real world example
Singleton
o Structural code example
o Real world example
1 / 24 100%
La catégorie de ce document est-elle correcte?
Merci pour votre participation!

Faire une suggestion

Avez-vous trouvé des erreurs dans linterface ou les textes ? Ou savez-vous comment améliorer linterface utilisateur de StudyLib ? Nhésitez pas à envoyer vos suggestions. Cest très important pour nous !