Design Patterns For 70% Of Programmers In The WorldPresentation Transcript
Design Patterns for 70% of genious programmers Aamir Khan Solution Architect
Design Patterns for 70% of programmers in the world Saurabh Verma Solution Architect I blog at http://www.domaindrivendesign.info
Agenda
Do you OOPs?
Design Patterns? Why
Design Patterns? What
Design Patterns? How
I hate my job
Normal Classes vs Abstract Classes vs Interfaces Normal Class: This is a normal class Abstract Class: These cannot be instantiated directly. They may provide partial implementations and exists solely for the purpose of inheritance. Interfaces: Defines a contract. Concrete implementations needs to implement each property and method as per contract. Shut up ! We know all this
Million Dollar Question? What is Why?
Normal Class vs Abstract Class? If a particular class is a entity which is not required to be instantiated by the application directly, go for Abstract Class Employee can be abstract class
Abstract Class vs Interfaces? If a particular class contains any default behavior, go for Abstract Class If every concrete class has its own implementation, go for Interfaces Work – Management, Programming
MOVIES & ACTORS Shahrukh Khan Salman Khan riding bike Actors in a Movie
IS-A vs HAS-A vs CAN-DO IS-A Inheritance Shahrukh Khan is an ACTOR HAS-A Composition Movie has ACTORS CAN-DO Interfaces Salman Khan can DRIVE BIKE IS-A Inheritance Shahrukh Khan is an ACTOR HAS-A Composition Movie has ACTORS CAN-DO Interfaces Salman Khan can DRIVE BIKE
What is a Pattern
An 'element of reusable software’
A design pattern systematically names, motivates, and explains a general design that addresses a recurring design problem in object-oriented systems.
It describes the problem, the solution, when to apply the solution, and its consequences.
It also gives implementation hints and examples. The solution is a general arrangement of objects and classes that solve the problem. The solution is customized and implemented to solve the problem in a particular context.
History of Software Patterns
What Wikipedia says,
A design pattern is a general repeatable solution to a commonly occurring problem in software design.
A design pattern is not a finished design that can be transformed directly into code.
Algorithms are not thought of as design patterns.
Let’s understand design patterns by purpose
Let’s understand the purpose + Creational Patterns Structural Patterns Final Product Behavioral Patterns
Let’s understand the purpose
Design Patterns as per their PURPOSE
Creational Patterns
Factory Method
Factory Method
Define an interface for creating an object, but let subclass decide which class to instantiate
Prevents creation of any additional instances, while simultaneously allowing global access
Creation can be delayed until it is actually required
Decorator vs Adapter Decorator looks like Adapter which “decorates” an existing class to make it compatible. Though, Decorator doesn’t wants you to decorate every method in the Adapted class. But who has stopped from doing it. “ Never underestimate the power of a developer”
Decorator vs Façade Façade is a way of hiding a complex system inside a simpler interface, whereas Decorator adds function by wrapping a class.
Behavioural Patterns
Command Pattern
Command Pattern
Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests.
If all commands can service a specific request, they can be entertained by the invoker
1–8 of 8 previous next Post a comment