Posts

Showing posts with the label OOPS

SOLID Design Principle

SOLID principles are the set of principle fist given by Robert.C.Martin. SOLID principle as name given its set of principle that allows building SOLID software system. Unlike OOD and Design Pattern, SOLID principles are related with the design and maintenance of software system.SOLID prinicples helps in designing a software which is easy to maintain, easy to expand , easy to understand, easy to implement, easy to explain. S.O.L.I.D is acronym for Single Responsibility Principle :  Principle is related to Designing software module, class or function that should perform only one task. So this principle is about Creation. Open/Close Principle :  Principle is applied after 1 (Single Responsibility Principle), again this principle is related to Designing module, class or function. But it about closing already designed thing for modification but opening designed thing for extension i.e. extending functionality. So this principle is about extension. Liskov Substitutio...

Factory Design Pattern

Image
Factory design pattern is a creational design pattern. In Factory design pattern we create a factory method which gives us object on the basis of the input we provide. Objects are being created without exposing the creation logic of instance from client. Factory design pattern is mainly used when we have one super class and multiple sub class and on the basis of the input we have to return one of the sub class . Super class in design pattern can be an abstract class, interface and normal class. In below diagram, we have interface as Computer, we have implemented it as "PC" in which we need normal RAM, CPU and Hard Disk and other we have implemented it as "Server" in which we have High RAM, High CPU and very large memory Hard Disk. Client class will ask to factory method to give the instance of one of them and   factory method will return the instance of PC or Server on the basis of input. Implementation : Computer.java PC.java : Se...