Your SlideShare is downloading. ×
Introduction To Design Patterns
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Introduction To Design Patterns

715
views

Published on

An intro to Design patterns

An intro to Design patterns


0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
715
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Introduction to Design Patterns Raju Golla …………………………………… .…….
  • 2. What are Design Patterns
    • General and reusable solutions to common problems in
    • software design.
    • Solutions to problems that have already been resolved
    • Structure or interfaces how the source code should be organised.
    • Interaction between Classes i.e., collaboration
    • .NET Framework BCL already makes extensive use of patterns.
    • Deal with higher level application and software design (Enterprise architecture) as well as low level abstractions on top of the source code.
    • It is a dialect for programmers, use templates rather than reinventing
    • the wheel, improves system and application design.
  • 3. Activity
  • 4. What they are not?
    • Reusable components
    • such as assemblies, algorithms or class specifications
  • 5. History
    • Success architect Christopher Alexander
    • book 'A Pattern Language: Towns, builds, construction,
    • 1977' (Non IT)
    • Design patterns: Elements of Reusable Object Oriented Software
    • Gang of Four: Erich Gamma, Richard Helm, Ralph Johnson
    • and John Vlissides (1995).
    • First time documented successful design patterns.
  • 6. Classifications
    • Design patterns for
    • Object oriented programming.
    • Functional programming.
    • Creational
    • Structural
    • Behavioral
    • Security
    • Concurrency
    • Sql
    • User interface
    • Relational
    • Social
    • Distributed
  • 7. Singleton pattern
    • Member of Creational family of patterns
    • The intention of this pattern is to ensure that a class has only one instance
    • Make the class itself is responsible for keeping track of its sole instance
    • The class must be accessible to clients
    • There can be only one
  • 8. Singleton implementation classic
  • 9. Thread safe
  • 10. Outcome
    • The default implementation of Singleton pattern is not thread-safe, it should not be used in multi threaded applications i.e., ASP.NET web apps.
    • Introduces tight coupling among collaborating classes.
    • Difficult to test
    • It is feasible to use IOC (Inversion of Control) to avoid tight coupling and testability issues.
  • 11. Strategy
    • Encapsulate related algorithms
    • Lets the algorithm vary and evolve from the class using it
    • Allows the class to maintain a separate purpose
    • Separates the implementation from the delivery of its results.
  • 12. Strategy – when to be used?
    • Switch statements.
    • Decouple algorithm implementation from a class.
    • Adding a new method (Calculation) requires class modification.
  • 13. Strategy implementation
    • Interface
    • Implementing classes
  • 14. Implementation continued.. Client
  • 15. Decorator
    • Structural design pattern
    • Allows to add functionality to objects at run time.
    • Alternative to sub classing.
    • Design flexibility
    • Allows adding behaviour to objects at run time.
    • Supports open closed principle.
  • 16. When to consider?
    • Legacy systems
    • Add functionality to UI controls (Controls, buttons etc)
    • Sealed classes (it is feasible to add
  • 17. Implementation
    • Classic implementation
    • -Base class
    • Derived classes
  • 18. Implementation continued…
    • Client
    Output
  • 19. Decorator class
  • 20. Implementation continued…
    • Concrete decorator
  • 21. Implementation continued…
    • Client
    Output
  • 22. Implementation continued…
  • 23. Continued… Client
  • 24. State
    • Member of behavioral pattern
    • Allows object to change methods behaviour based on state of the object, not the configuration.
    • Encapsulate the logic of each state into a single object
    • Allows for dynamic state discovery
    • Makes unit testing easier and efficient
  • 25. Example
    • Jira issue Object
  • 26. State – class diagram
  • 27. Benefits
    • Separation of concerns
    • Transition between sates is explicit and clear.
    • Reuse of the state object.
    • Simplify the program
    • Easier maintainability.
  • 28. References
    • Microsoft Patterns and practices at
    • http://msdn.microsoft.com/en-us/practices/default
    • Microsoft Patterns and practices team: Application architecture guide
    • http://apparchguide.codeplex.com/
    • Head First design patterns
    • C# in depth