Posts

Showing posts from February, 2020

Business Delegate

Image
Business Delegate  - A single entry point class for client entities to provide access to Business Service methods. LookUp Service  - Lookup service object is responsible to get relative business implementation and provide business object access to business delegate object. Business Service  - Business Service interface. Concrete classes implement this business service to provide actual business implementation logic. Implementation We are going to create a Client, BusinessDelegate, BusinessService, LookUpService, JMSService and EJBService representing various entities of Business Delegate patterns. BusinessDelegatePatternDemo, our demo class, will use BusinessDelegate and Client to demonstrate use of Business Delegate pattern. Step 1 Create BusinessService Interface. BusinessService.java public interface BusinessService { public void doProcessing (); } Step 2 Create concrete Service classes. EJBService.java public class EJBS...

Chain of Responsibilty

Image
Chain of responsibility pattern is used to achieve loose coupling in software design where a request from the client is passed to a chain of objects to process them. Later, the object in the chain will decide themselves who will be processing the request and whether the request is required to be sent to the next object in the chain or not. Where and When Chain of Responsibility pattern is applicable : When you want to decouple a request’s sender and receiver Multiple objects, determined at runtime, are candidates to handle a request When you don’t want to specify handlers explicitly in your code When you want to issue a request to one of several objects without specifying the receiver explicitly. This pattern is recommended when multiple objects can handle a request and the handler doesn’t have to be a specific object. Also, the handler is determined at runtime. Please note that a request not handled at all by any handler is a valid use case. Handler :  This ca...

Observer Pattern

Image
Observer  pattern is classified among the behavioral design patterns. Behavioral design patterns are most specifically concerned with communication between classes/objects. What is an  observer pattern ? The pattern’s aim is to define a one-to-many relationship such that when one object changes  state , the others are  notified  and  updated  automatically. More precisely, it wishes to be informed about events happening in the system. Lets put the pieces of the puzzle together in three steps. Step 1 — Keywords Defining  keywords  is the secret recipe in this series of quick-guides. This method helped me truly understand the design patterns, hardcode them in my mind and comprehend the differences among other design patterns. Subject:  It is considered as the keeper of information, of data or of business logic. Register/Attach : Observers register themselves to the subject because they want to be notified when there is a change...