Explain the Analysis phase and Design phase.Analysis Phase:
1. It belongs to the high level design stage
2. It helps in discovery of classes and specification of data and processes associated with those classes.
3. It is represented through UML
1. It belongs to the low level design stage
2. It helps in takes analysis model and produces set of models which closely mirror classes and processing in target implementation language.
3. It overlaps analysis and implementation
4. It is represented through UML.
What are design patterns? Name some.Design Patterns: can be thought of as a simple and elegant solution to specific problems in object oriented design. They are Sign of maturity idea of an object oriented patterns is to encapsulate functionality and data inside a collection of classes. Patterns can suggest ways in which subsystems (collection of classes) can be reused.
1. Abstract factory
3. Factory Method
What are the four major categories in which design patters can be categorized? Name the methods that lie in these categories1. Creational:
a. Abstract factory
c. Factory Method
d. Chain of responsibility
Explain the design pattern Façade.Façade provides a unified interface to a set of interfaces in a subsystem. It defines a higher-level interface that makes the subsystem easier to use. Structuring a system into subsystems helps to reduce the complexity. A common design goal is to minimize the communication and dependencies between subsystems. One way to achieve this goal is to introduce a façade object that provides a single, simplified interface to the more general facilities of a subsystem. Façade is the fundamental pattern for splitting up your subsystems and keeping them under control.
When should you use Façade?Façade should be considered when you want to provide a simple interface to a complex subsystem. Subsystems often get more complex as they evolve. Most patterns, when applied, result in more and smaller classes. This makes the subsystem more reusable and easier to customize, but it also becomes harder to use for clients that don't need to customize it. A facade can provide a simple default view of the subsystem that is good enough for most clients. Only clients needing more customizability will need to look beyond the facade.
What are the advantages of Façade?Advantages:
1. Decoupling: the subsystem from clients and other subsystems promoting subsystem independence and portability.
2. Façade promotes layering
3. Reduces coupling by making Facade an abstract class with concrete subclasses for different implementations of a subsystem. Then clients can communicate with the subsystem through the interface of the abstract Facade class. This abstract coupling keeps clients from knowing which implementation of a subsystem is used.
What does a façade compiler do?Facade Compiler:
1. Knows which subsystem classes are responsible for a request.
2. Delegates client requests to appropriate subsystem objects.
3. Implements subsystem functionality.
4. Handles work assigned by the Facade object.
5. Have no knowledge of the facade; that is, they keep no references to it.
When is adapter design pattern used?Adapter pattern is used when you want to use an existing class, and its interface does not match the one you need. It is used when you want to create a reusable class that cooperates with unrelated or unforeseen classes, that is, classes that don't necessarily have compatible interfaces. The object adapter pattern is used only when you need to use several existing subclasses, but it's impractical to adapt their interface by subclassing every one. An object adapter can adapt the interface of its parent class.
What are the various trade-offs of a class adapter pattern?Class and object adapters have different trade-offs.
1. A class adapter adapts Adaptee to Target by committing to a concrete Adapter class. As a consequence, a class adapter won't work when we want to adapt a class and all its subclasses.
2. Class adapter lets Adapter override some of Adaptee's behavior, since Adapter is a subclass of Adaptee.
3. Class adapter introduces only one object, and no additional pointer indirection is needed to get to the adaptee
4. Object adapter lets a single Adapter work with many Adaptees—that is, the Adaptee itself and all of its subclasses (if any). The Adapter can also add functionality to all Adaptees at once.
5. Object adapter makes it harder to override Adaptee behavior. It will require subclassing Adaptee and making Adapter refer to the subclass rather than the adaptee itself.
What is a mediator design pattern and when is it used?Mediator pattern defines an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently. It is a class which regulates interaction of all the other classes within a subsystem
Mediator pattern is used when a set of objects communicate in well-defined but complex ways. The resulting interdependencies are unstructured and difficult to understand. It is used when reusing an object is difficult because it refers to and communicates with many other objects. It’s also used when a behavior that's distributed between several classes should be customizable without a lot of subclassing.