MVC1
MVC1
1. First client send as request to the server then the controller willtake that request to the the model
and the model will interact with the databse and in the process it may also execute some
business logic if required then after getting the data from the database it will pass it to the
controller then the controller will pass the data to our view then the view will format the data and
that formatted data will be sent to the client so this is how architecture works
2. Now each of this 3 components has specific responsibilities so our model it interacts with the
database and it is also responsible for executing business logic so our model basically deals with
data then our view is what used sees on the screen it generates UI or user interface for the user
and
3. Controller takes user input also called as request parameters it also interacts with the model and
view so our controller basically acts as a middle man between our model and view
The adapter design pattern is one of the structural design patterns and is used so that two
unrelated interfaces can work together. The object that joins these unrelated interfaces is called
an adapter.
Note: Learn more about the Adapter Pattern.
2. Composite Pattern
The composite pattern is used when we have to represent a part-whole hierarchy. When we
need to create a structure in a way that the objects in the structure have to be treated the same
way, we can apply the composite design pattern.
Note: Learn more about the Composite Pattern.
3. Proxy Pattern
The proxy pattern provides a placeholder for another Object to control access to it. This pattern
is used when we want to provide controlled access to functionality.
Note: Learn more about the Proxy Pattern.
4. Flyweight Pattern
The flyweight design pattern is used when we need to create a lot of Objects of a Class. Since
every Object consumes memory space that can be crucial for low-memory devices (such as
mobile devices or embedded systems), the flyweight design pattern can be applied to reduce
the load on memory by sharing Objects.
String pool implementation in Java is one of the best examples of flyweight pattern
implementation.
Note: Learn more about the Flyweight Pattern.
5. Facade Pattern
The facade pattern is used to help client applications easily interact with the system.
Note: Learn more about the Facade Pattern.
6. Bridge Pattern
When we have interface hierarchies in both interfaces as well as implementations, then the
bridge design pattern is used to decouple the interfaces from the implementation and to hide
the implementation details from the client programs. The implementation of the bridge design
pattern follows the notion of preferring composition over inheritance.
Note: Learn more about the Bridge Pattern.
7. Decorator Pattern
The decorator design pattern is used to modify the functionality of an object at runtime. At the
same time, other instances of the same class will not be affected by this, so the individual
object gets the modified behavior. The decorator design pattern is one of the structural design
patterns (such as adapter pattern, bridge pattern, or composite pattern) and uses abstract
classes or interface with the composition to implement. We use inheritance or composition to
extend the behavior of an object, but this is done at compile-time, and it’s applicable to all the
instances of the class. We can’t add any new functionality to remove any existing behavior at
runtime – this is when the decorator pattern is useful.
Note: Learn more about the Decorator Pattern.
The template method pattern is a behavioral design pattern and is used to create a method
stub and to defer some of the steps of implementation to the subclasses. The template method
defines the steps to execute an algorithm, and it can provide a default implementation that
might be common for all or some of the subclasses.
Note: Learn more about the Template Method Pattern.
2. Mediator Pattern
The mediator design pattern is used to provide a centralized communication medium between
different objects in a system. If the objects interact with each other directly, the system
components are tightly-coupled with each other which makes maintainability cost higher and
not flexible to extend easily. The mediator pattern focuses on providing a mediator between
objects for communication and implementing loose-coupling between objects. The mediator
works as a router between objects, and it can have its own logic to provide a way of
communication.
Note: Learn more about the Mediator Pattern
3. Chain of Responsibility Pattern
The 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. Then the object in the
chain will decide who will be processing the request and whether the request is required to be
sent to the next object in the chain or not.
We know that we can have multiple catch blocks in a try-catch block code. Here
every catch block is kind of a processor to process that particular exception. So when an
exception occurs in the try block, it’s sent to the first catch block to process. If the catch block
is not able to process it, it forwards the request to the next Object in the chain (i.e., the
next catch block). If even the last catch block is not able to process it, the exception is thrown
outside of the chain to the calling program.
Note: Learn more about the Chain of Responsibility Pattern.
4. Observer Pattern
An observer design pattern is useful when you are interested in the state of an Object and
want to get notified whenever there is any change. In the observer pattern, the Object that
watches the state of another Object is called observer, and the Object that is being watched is
called subject.
Java provides an built-in platform for implementing the observer pattern through
the java.util.Observable class and java.util.Observer interface. However, it’s not widely
used because the implementation is limited and most of the time we don’t want to end up
extending a class solely for implementing the observer pattern as Java doesn’t provide multiple
inheritances in classes. Java Message Service (JMS) uses the observer pattern along with the
mediator pattern to allow applications to subscribe and publish data to other applications.
Note: Learn more about the Observer Pattern.
5. Strategy Pattern
Strategy pattern is used when we have multiple algorithms for a specific task, and the client
decides the actual implementation be used at runtime. A strategy pattern is also known as a
policy pattern. We define multiple algorithms and let client applications pass the algorithm to be
used as a parameter.
One of the best examples of this pattern is the Collections.sort() method that takes
the Comparator parameter. Based on the different implementations of comparator interfaces,
the objects are getting sorted in different ways.
Note: Learn more about the Strategy Pattern.
6. Command Pattern
The command pattern is used to implement loose-coupling in a request-response model. In this
pattern, the request is sent to the invoker and the invoker passes it to the
encapsulated command object. The command object passes the request to the appropriate
method of receiver to perform the specific action.
Note: Learn more about the Command Pattern.
7. State Pattern
The state design pattern is used when an Object changes its behavior based on its internal
state. If we have to change the behavior of an Object based on its state, we can have a state
variable in the Object and use if-else condition block to perform different actions based on
the state. The state pattern is used to provide a systematic and loosely-coupled way to achieve
this through context and state implementations.
Note: Learn more about the State Pattern.
8. Visitor Pattern
The visitor pattern is used when we have to perform an operation on a group of similar kinds of
objects. With the help of a visitor pattern, we can move the operational logic from the objects to
another class.
Note: Learn more about the Visitor Pattern.
9. Interpreter Pattern
The Data Access Object (DAO) design pattern is used to decouple the data persistence logic to
a separate layer. DAO is a very popular pattern when we design systems to work with
databases. The idea is to keep the service layer separate from the data access layer. This way
we implement the separation of logic in our application.
Note: Learn more about the DAO Pattern.
2. Dependency Injection Pattern
The dependency injection pattern allows us to remove the hard-coded dependencies and make
our application loosely-coupled, extendable, and maintainable. We can implement dependency
injection in Java to move the dependency resolution from compile-time to runtime. Spring
framework is built on the principle of dependency injection.
Note: Learn more about the Dependency Injection Pattern.
3. MVC Pattern
Model-View-Controller (MVC) Pattern is one of the oldest architectural patterns for creating web
applications.