Tag: gangoffour

  • How to implement Composite pattern in Java?

    Let’s say you are the manager of a project. You have been asked to calculate the total cost to your company of your entire team. You have a service development team with two members. You have a UI development team with two members. You have a Quality Assurance team with two members. You have a…

  • How to implement Bridge pattern in Java?

    Let’s say you are a technical manager. You have several projects under you. You have designed them already to use different client and server technologies. Client technologies include Angular , VueJS and React. Server technologies include Java, DotNet and NodeJS. You are combining these two categories in different combinations and using each combination for a…

  • How to implement Adapter pattern in Java?

    Let’s say you love nuts. You buy them every now and then from a vendor named Raghav. You buy it online through a java program which calls Raghav’s shop API. Let’s say you have created a Shop interface to represent Raghav’s shop and created a class RaghavShop implementing it. And you have declared a method…

  • How to implement Prototype pattern in Java?

    Lets say you run a modelling agency. You are creating an application to manage your models. They are of different types – actors, male and female , can do anchoring , can play the role of video jockey , can act in cinema etc. To design classes for the above use case , you could…

  • How to implement Factory Method pattern in Java?

    Lets say you want to sell headphones. You create an application to handle your sales. You create a generic HeadPhoneShop class which can handle creating(buying from the manufacturer) the head phones and sell them. But you don’t want it to do the actual creation. You want to delegate it a shop which deals with creating…