Category Archives: Design Patterns

How to Write Good API

 1– methods should do only one operation (only one function per method) this enable -code reuse -modularity -sample for testing 2– keep method small if method have to make more than function you can encapsulate them in object 3– defensive … Continue reading

Posted in Design Patterns

Visitor Design pattern

the visitor design pattern is a way of separating an algorithm from an object structure it operates on. A practical result of this separation is the ability to add new operations to existing object structures without modifying those structures. It … Continue reading

Posted in Design Patterns | Leave a comment

strategy design pattern

public interface Sender { public boolean Send(NotificationBean notificationBean,List … temp); } public abstract class sendEmailTemplate implements Sender { public abstract void preSend(NotificationBean notification,List … temp); public abstract void PostSend(); public abstract boolean TryToSend(); public abstract boolean IsSent(); public abstract boolean … Continue reading

Posted in Design Patterns, java | Leave a comment

Abstract Factory Design Pattern

1-This pattern is one level of abstraction higher than factory pattern. 2-the abstract factory returns the factory of classes. Like Factory pattern returned one of the several sub-classes, this returns such factory which later will return one of the sub-classes. … Continue reading

Posted in Design Patterns, java | Tagged | Leave a comment

Factory Design Pattern

if we have a super class and n sub-classes, and based on data provided, we have to return the object of one of the sub-classes, we use a factory pattern. Example: Let’s suppose an application asks for entering the name … Continue reading

Posted in Design Patterns, java | Tagged | Leave a comment

Design Pattern

Introduction Instead of defining what is design pattern lets define what we mean by design and what we mean by pattern. According to me design is blue print or sketch of something so it can be defined as creation of … Continue reading

Posted in Design Patterns | Leave a comment

Strategy Design Pattern

Lets say your in the military and are charged with defending a country. A top general tells you that you need to design a computer system that will activate the military when an invasion happens. You might begin to layout … Continue reading

Posted in Design Patterns | Leave a comment