Solid design principles in the programming -
S - Single responsibility principle (SRP) - Class should have only one reason to change.
O - Open closed Principle (OCP) - Software entities should be open for extensions and closed for modifications.
L - Liskov substitution principle (LSP)
I - Interface Segregation Principle (ISP) - (Big interfaces to break in to smaller interfaces)
D - Dependency Inversion principle (DIP) - one should depend on abstraction and not concretions.
Design patterns videos:-
https://www.youtube.com/watch?v=rI4kdGLaUiQ&list=PL6n9fhu94yhUbctIoxoVTrklN3LMwTCmd
Types of design patterns
Creational - (flexiblity in deciding which objects need to create for given case). e.g. Singleton, Factory, Abstract Factory, builder, prototype.
Structural - (Decoupling interface and implementaion of classes and its objects.) e.g. Adapter, Bridge
Behavioural - (Communication between classes and objects) e.g. Chain of responsiblity, Command, Interpreter.
Singleton design pattern -
Implementation guidlines -
Ensure that only one instance of the class exists
provide global access to that instance by
-- Declaring all constructor of the class to be private.
-- Providing static method that returns a reference to the instance.
-- The instance is stored as a private static variable.
e.g.
Exception or information logging.
Managing a connection or a pool of connections to Database.
Printer Spooling
File management
Configuration
Cache
Session based shopping carts.
Static class Vs Singleton -
Static is a keyword and singleton is desgin pattern.
Static classes can contains only static members.
Signleton is object creational pattern with one instance of the class.
Singleton can implement interfaces, inherit from other classes and it aligns with oops concept.
Singleton object can be passed as a reference.
Singleton supports object disposal.
Singleton object is stored on the heap, where as static can stored on stack.
Singleton object cab be cloned.
Factory design pattern -
Let subclasses to decide which class to instanciated.
Factory pattern creates object without exposing the creation logic to client and refer to newly created object using a common interface.
The factory method lets a class defer intantiation it uses to subclasses.
Implementation guidelines -
The object need to be extended to sub-classes.
The classes does not know what exact sub-classes it has to create.
The product implementation tend to change over time and the client remains change.
e.g. client uses factory to creates instance of the product.
Client --uses--> Factory --creates--> Product
S - Single responsibility principle (SRP) - Class should have only one reason to change.
O - Open closed Principle (OCP) - Software entities should be open for extensions and closed for modifications.
L - Liskov substitution principle (LSP)
I - Interface Segregation Principle (ISP) - (Big interfaces to break in to smaller interfaces)
D - Dependency Inversion principle (DIP) - one should depend on abstraction and not concretions.
Design patterns videos:-
https://www.youtube.com/watch?v=rI4kdGLaUiQ&list=PL6n9fhu94yhUbctIoxoVTrklN3LMwTCmd
Types of design patterns
Creational - (flexiblity in deciding which objects need to create for given case). e.g. Singleton, Factory, Abstract Factory, builder, prototype.
Structural - (Decoupling interface and implementaion of classes and its objects.) e.g. Adapter, Bridge
Behavioural - (Communication between classes and objects) e.g. Chain of responsiblity, Command, Interpreter.
Singleton design pattern -
Implementation guidlines -
Ensure that only one instance of the class exists
provide global access to that instance by
-- Declaring all constructor of the class to be private.
-- Providing static method that returns a reference to the instance.
-- The instance is stored as a private static variable.
e.g.
Exception or information logging.
Managing a connection or a pool of connections to Database.
Printer Spooling
File management
Configuration
Cache
Session based shopping carts.
Static class Vs Singleton -
Static is a keyword and singleton is desgin pattern.
Static classes can contains only static members.
Signleton is object creational pattern with one instance of the class.
Singleton can implement interfaces, inherit from other classes and it aligns with oops concept.
Singleton object can be passed as a reference.
Singleton supports object disposal.
Singleton object is stored on the heap, where as static can stored on stack.
Singleton object cab be cloned.
Factory design pattern -
Let subclasses to decide which class to instanciated.
Factory pattern creates object without exposing the creation logic to client and refer to newly created object using a common interface.
The factory method lets a class defer intantiation it uses to subclasses.
Implementation guidelines -
The object need to be extended to sub-classes.
The classes does not know what exact sub-classes it has to create.
The product implementation tend to change over time and the client remains change.
e.g. client uses factory to creates instance of the product.
Client --uses--> Factory --creates--> Product
Comments
Post a Comment