Template Method
Template method defines the skeleton of how a certain algorithm could be performed, but defers the implementation of those steps to the children classes. Real world example Suppose we are getting some house built. The steps for building might look like Prepare the base of house Build the walls Add roof A…
Strategy
Strategy pattern allows you to switch the algorithm or strategy based upon the situation. Real world example Consider the example of sorting, we implemented bubble sort but the data started to grow and bubble sort started getting very slow. In order to tackle this we implemented Quick sort. But now a…
Visitor
Visitor pattern lets you add further operations to objects without having to modify them. Real world example Consider someone visiting Dubai. They just need a way (i.e. visa) to enter Dubai. After arrival, they can come and visit any place in Dubai on their own without having to ask for permission or…
Observer
Defines a dependency between objects so that whenever an object changes its state, all its dependents are notified. Real world example A good example would be the job seekers where they subscribe to some job posting site and they are notified whenever there is a matching job opportunity.
Memento
Memento pattern is about capturing and storing the current state of an object in a manner that it can be restored later on in a smooth manner. Real world example Take the example of calculator (i.e. originator), where whenever you perform some calculation the last calculation is saved in memory (i.e.…
Mediator
Mediator pattern adds a third party object (called mediator) to control the interaction between two objects (called colleagues). It helps reduce the coupling between the classes communicating with each other. Because now they don't need to have the knowledge of each other's implementation. R…
Iterator
It presents a way to access the elements of an object without exposing the underlying presentation. Real world example An old radio set will be a good example of iterator, where user could start at some channel and then use next or previous buttons to go through the respective channels. Or take an ex…
Command
Allows you to encapsulate actions in objects. The key idea behind this pattern is to provide the means to decouple client from receiver. Real world example A generic example would be you ordering food at a restaurant. You (i.e. Client ) ask the waiter (i.e. Invoker ) to bring some food (i.e. Command ) a…
Chain of Responsibility
It helps building a chain of objects. Request enters from one end and keeps going from object to object till it finds the suitable handler. Real world example For example, you have three payment methods ( A , B and C ) setup in your account; each having a different amount in it. A has 100 USD, B has 300…
Proxy
Using the proxy pattern, a class represents the functionality of another class. Real world example Have you ever used an access card to go through a door? There are multiple options to open that door i.e. it can be opened either using access card or by pressing a button that bypasses the security. Th…
Flyweight
It is used to minimize memory usage or computational expenses by sharing as much as possible with similar objects. Real world example Did you ever have fresh tea from some stall? They often make more than one cup that you demanded and save the rest for any other customer so to save the resources e.g.…
Facade
Facade pattern provides a simplified interface to a complex subsystem. Real world example How do you turn on the computer? "Hit the power button" you say! That is what you believe because you are using a simple interface that computer provides on the outside, internally it has to do a lot …
Decorator
Decorator pattern lets you dynamically change the behavior of an object at run time by wrapping them in an object of a decorator class. Real world example Imagine you run a car service shop offering multiple services. Now how do you calculate the bill to be charged? You pick one service and dynamical…
Composite
Composite pattern lets clients treat the individual objects in a uniform manner. Real world example Every organization is composed of employees. Each of the employees has the same features i.e. has a salary, has some responsibilities, may or may not report to someone, may or may not have some subordi…
Bridge
Bridge pattern is about preferring composition over inheritance. Implementation details are pushed from a hierarchy to another object with a separate hierarchy. Real world example Consider you have a website with different pages and you are supposed to allow the user to change the theme. What would y…
Adapter
Adapter pattern lets you wrap an otherwise incompatible object in an adapter to make it compatible with another class. Real world example Consider that you have some pictures in your memory card and you need to transfer them to your computer. In order to transfer them you need some kind of adapter th…
Singleton
Ensures that only one object of a particular class is ever created. Real world example There can only be one president of a country at a time. The same president has to be brought to action, whenever duty calls. President here is singleton.
Prototype
Create object based on an existing object through cloning. Real world example Remember dolly? The sheep that was cloned! Lets not get into the details but the key point here is that it is all about cloning
Builder
Allows you to create different flavors of an object while avoiding constructor pollution. Useful when there could be several flavors of an object. Or when there are a lot of steps involved in creation of an object. Real world example Imagine you are at Hardee's and you order a specific deal, lets…
Abstract Factory
A factory of factories; a factory that groups the individual but related/dependent factories together without specifying their concrete classes. Real world example Extending our door example from Simple Factory. Based on your needs you might get a wooden door from a wooden door shop, iron door from a…
Factory Method
It provides a way to delegate the instantiation logic to child classes. Real world example Consider the case of a hiring manager. It is impossible for one person to interview for each of the positions. Based on the job opening, she has to decide and delegate the interview steps to different people.
Simple Factory
Simple factory simply generates an instance for client without exposing any instantiation logic to the client Real world example Consider, you are building a house and you need doors. You can either put on your carpenter clothes, bring some wood, glue, nails and all the tools required to build the do…
Behavioral Design Patterns
It is concerned with assignment of responsibilities between the objects. What makes them different from structural patterns is they don't just specify the structure but also outline the patterns for message passing/communication between them. Or in other words, they assist in answering "Ho…
State
It lets you change the behavior of a class when the state changes. Real world example Imagine you are using some drawing application, you choose the paint brush to draw. Now the brush changes its behavior based on the selected color i.e. if you have chosen red color it will draw in red, if blue then …
Structural Design Patterns
Structural patterns are mostly concerned with object composition or in other words how the entities can use each other. Or yet another explanation would be, they help in answering "How to build a software component?" Types of Structural Patterns Adapter Bridge Composite Decorator Facade Flyweigh…
Creational Design Patterns
Creational patterns are focused towards how to instantiate an object or group of related objects. Types of Creational Patterns Simple Factory Factory Method Abstract Factory Builder Prototype Singleton
Design Patterns
A software design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. It is not a finished design that can be transformed directly into source or machine code. It is a description or template for how to solve a problem that can be used i…
wget -p -k -E -U mozilla https://example.com/
🧾 Command: wget -p -k -E -U mozilla https://example.com/ 🧩 Option Breakdown: Option Description -p ( --page-requisites ) Downloads everything needed to display the page properly , like images, CSS, JavaScript. -k ( --convert-links ) Converts all the links in the downloaded page so they point to local copies …
wget --random-wait -r -p -e robots=off -U mozilla https://example.com
Absolutely! Let’s walk through what this wget command does, piece by piece: 🧾 Full Command: wget --random-wait -r -p -e robots=off -U mozilla https://example.com 🧩 Option Breakdown: Option What It Does --random-wait Adds random delays between downloads to mimic human behavior (helps avoid being flagge…