Design Pattern Lectures PDF

Title Design Pattern Lectures
Author James Hendrick
Course Advanced Design
Institution University of Texas at El Paso
Pages 31
File Size 2.4 MB
File Type PDF
Total Downloads 57
Total Views 147

Summary

Design Pattern Lecture Notes are available here....


Description

1/21/2021

Explain difference between the Facade, Proxy, Adapter and Decorator design patterns? | FullStack.Cafe

FullStackFSC

Café

Sign Out

Kil You Tech Interview 3877 Full-Stack, Coding & System Design Interview Questions

Answered To Get Your Next Six-Figure Job Offer See All Questions

.NET Core 52

ADO.NET 33

ASP.NET Web API 33 Angular 120

Ionic 29

AngularJS 61

Git 36

Redux 30

PHP 82

WebSockets 24

h

Entity Framework 57 GraphQL 25

MySQL 55 PWA 22

Ruby 84

Vue.js 41 Xamarin 83

T-SQL 36 WCF 33

LINQ 38

Node.js 88

Python 96

Ruby on Rails 72 Spring 87

HTML5 55

Kotlin 68

Reactive Programming 12

Software Testing 26 UX Design 78

CSS 50

JavaScript 142

MongoDB 83

React Native 72

Android 113

Golang 49

Java 147

ASP.NET MVC 36

C# 115

DevOps 39

Laravel 41 OOP 54

ASP.NET 42

Agile & Scrum 47

Design Patterns 45 Flutter 68

Improve Your Resume

React 164

Redis 25 SQL 56 TypeScript 39 Web Security 58

jQuery 51

1

1/21/2021

Explain difference between the Facade, Proxy, Adapter and Decorator design patterns? | FullStack.Cafe

FullStackFSC

Café

Sign Out

To 4 Design Pattern Interview Questions 👋 Join Our Referral

Entry

Junior

Mid

Senior

Expert

Program, Share And Get Paid

Only Code Challenges

Topic Progress:

Q1: What are the main categories of Design Patterns?

Add to PDF

Entry

Add to PDF

Entry

Answer The Design patterns can be classified into three main categories: Creational Patterns Behavioral Patterns Functional Patterns

Source: www.educba.com

Q2: What is Singleton pattern?

Answer Singleton pattern comes under creational patterns category and introduces a single class which is responsible to create an object while making sure that only single object gets created. This class provides a way to access its only object which can be accessed directly without need to instantiate the object of the class.

h

1

1/21/2021

Explain difference between the Facade, Proxy, Adapter and Decorator design patterns? | FullStack.Cafe

FullStackFSC

Café

Sign Out

Source: refactoring.guru

Q3: What is Design Patterns and why anyone should use them?

Add to PDF

Entry

Answer Design patterns are a well-described solution to the most commonly encountered problems which occur during software development. Design pattern represents the best practices evolved over a period of time by experienced software developers. They promote reusability which leads to a more robust and maintainable code.

Source: www.educba.com

Q4: What is a pattern?

Add to PDF

Entry

Answer Patterns in programming are like recipes in cooking. They are not ready dishes, but instructions for slicing and dicing products, cooking them, serving them and so forth. Pattern content As a rule, a pattern description consists of the following: a problem that the pattern solves; motivation for solving the the problem using the method suggested by the pattern; structures of classes comprising the solution; an example in one of the programming languages; a description of the nuances of pattern implementation in various contexts; relations with other patterns.

Source: refactoring.guru

Q5: What is Factory pattern? h

Add to PDF

Junior 1

1/21/2021

Explain difference between the Facade, Proxy, Adapter and Decorator design patterns? | FullStack.Cafe

FullStackFSC

Café

Sign Out

In Factory pattern, we create object without exposing the creation logic to the client and refer to newly created object using a common interface.

Pro's: Allows you to hide implementation of an application seam (the core interfaces that make up your application) Allows you to easily test the seam of an application (that is to mock/stub) certain parts of your application so you can build and test the other parts Allows you to change the design of your application more readily, this is known as loose coupling Con's Makes code more difficult to read as all of your code is behind an abstraction that may in turn hide abstractions. Can be classed as an anti-pattern when it is incorrectly used, for example some people use it to wire up a whole application when using an IOC container, instead use Dependency Injection.

Source: tutorialspoint.com

Q6: What is Filter pattern?

Add to PDF

Junior

Answer Filter pattern or Criteria pattern is a design pattern that enables developers to filter a set of objects using different criteria and chaining them in a decoupled way through logical operations. This type of design pattern comes under structural pattern as this pattern combines multiple criteria to obtain single criteria.

h

1

1/21/2021

Explain difference between the Facade, Proxy, Adapter and Decorator design patterns? | FullStack.Cafe

FullStackFSC

Café

Sign Out

List laptops = LaptopFactory.manufactureInBulk(); AndCriteria searchCriteria = new AndCriteria( new HardDisk250GBFilter(), new MacintoshFilter(), new I5ProcessorFilter()); List filteredLaptops = searchCriteria.meets(laptops);

Source: tutorialspoint.com

Q7: What is Template pattern?

Add to PDF

Junior

Answer In Template pattern, an abstract class exposes defined way(s)/template(s) to execute its methods. Its subclasses can override the method implementation as per need but the invocation is to be in the same way as defined by an abstract class. This pattern comes under behavior pattern category.

Source: tutorialspoint.com

Q8: What is State pattern?

Add to PDF

Junior

Answer In State pattern a class behavior changes based on its state. This type of design pattern comes under behavior pattern. In State pattern, we create objects which represent various states and a context object whose behavior varies as its state object changes.

h

1

1/21/2021

Explain difference between the Facade, Proxy, Adapter and Decorator design patterns? | FullStack.Cafe

FullStackFSC

Café

Sign Out

Source: tutorialspoint.com

Q9: What is Inversion of Control?

Add to PDF

Junior

Answer Inversion of control is a broad term but for a software developer it's most commonly described as a pattern used for decoupling components and layers in the system. For example, say your application has a text editor component and you want to provide spell checking. Your standard code would look something like this:

public class TextEditor { private SpellChecker checker; public TextEditor() { this.checker = new SpellChecker(); } }

What we've done here creates a dependency between the TextEditor and the SpellChecker. In an IoC scenario we would instead do something like this:

public class TextEditor { private IocSpellChecker checker; public TextEditor(IocSpellChecker checker) { this.checker = checker; } }

You have inverted control by handing the responsibility of instantiating the spell checker from the TextEditor class to the caller.

SpellChecker sc = new SpellChecker; // dependency TextEditor textEditor = new TextEditor(sc);

Source: stackoverflow.com h

1

1/21/2021

Explain difference between the Facade, Proxy, Adapter and Decorator design patterns? | FullStack.Cafe

FullStackFSC

Café

Sign Out

Design patterns can be classified in three categories: Creational, Structural and Behavioral patterns. Creational Patterns - These design patterns provide a way to create objects while hiding the creation logic, rather than instantiating objects directly using new opreator. This gives program more flexibility in deciding which objects need to be created for a given use case. Structural Patterns - These design patterns concern class and object composition. Concept of inheritance is used to compose interfaces and define ways to compose objects to obtain new functionalities. Behavioral Patterns - These design patterns are specifically concerned with communication between objects.

Source: tutorialspoint.com

Q11: What is Null Object pattern?

Add to PDF

Junior

Answer In Null Object pattern, a null object replaces check of NULL object instance. Instead of putting if check for a null value, Null Object reflects a do nothing relationship. Such Null object can also be used to provide default behaviour in case data is not available. In Null Object pattern, we create an abstract class specifying various operations to be done, concrete classes extending this class and a null object class providing do nothing implementation of this class and will be used seamlessly where we need to check null value.

Source: tutorialspoint.com

Q12: What is Builder pattern?

Add to PDF

Junior

Answer

h

1

1/21/2021

Explain difference between the Facade, Proxy, Adapter and Decorator design patterns? | FullStack.Cafe

FullStackFSC

Café

Sign Out

aClient c re ate create

aConcreteBuilder a Dir ect or

Construct() BuildPartA() BuildPartB() BuildPartC() GetResult()

The Director class is optional and is used to make sure that the building steps are executed in the right order with the right data by the right builder. It's about validation and delegation. Builder/Director pattern's steps invocations could be semantically presented by method chaining or so called Fluent Interface syntax.

Pizza pizza = new Pizza.Builder() .cheese(true) .pepperoni(true) .bacon(true) .build();

Source: tutorialspoint.com

Q13: Can we create a clone of a singleton object?

Add to PDF

Junior

Answer Yesl, we can but the purpose of Singleton Object creation is to have single instance serving all requests.

Source: tutorialspoint.com

Q14: What is Strategy pattern?

Add to PDF

Junior

Answer In Strategy pattern, a class behavior or its algorithm can be changed at run time. This type of design pattern comes under behavior pattern. In Strategy pattern, we create objects which represent various strategies and a context object whose behavior varies as per its strategy object. The strategy object changes the executing algorithm of the context object.

h

1

1/21/2021

Explain difference between the Facade, Proxy, Adapter and Decorator design patterns? | FullStack.Cafe

FullStackFSC

Café

Sign Out

Source: tutorialspoint.com

Q15: What is Iterator pattern?

Add to PDF

Junior

Answer Iterator pattern is very commonly used design pattern in Java and .Net programming environment. This pattern is used to get a way to access the elements of a collection object in sequential manner without any need to know its underlying representation. Iterator pattern falls under behavioral pattern category.

Source: tutorialspoint.com

Q16: What is Proxy pattern?

Add to PDF

Junior

Answer In proxy pattern, a class represents functionality of another class. This type of design pattern comes under structural pattern. In proxy pattern, we create object having original object to interface its functionality to outer world.

h

1

1/21/2021

Explain difference between the Facade, Proxy, Adapter and Decorator design patterns? | FullStack.Cafe

FullStackFSC

Café

Sign Out

Source: tutorialspoint.com

Q17: What is Dependency Injection?

Add to PDF

Junior

Answer Dependency injection makes it easy to create loosely coupled components, which typically means that components consume functionality defined by interfaces without having any first-hand knowledge of which implementation classes are being used. Dependency injection makes it easier to change the behavior of an application by changing the components that implement the interfaces that define application features. It also results in components that are easier to isolate for unit testing.

Source: Pro ASP.NET Core MVC 2

Q18: What is Bridge pattern?

Add to PDF

Mid

Answer Bridge pattern is used when we need to decouple an abstraction from its implementation so that the two can vary independently. This type of design pattern comes under structural pattern as this pattern decouples implementation class and abstract class by providing a bridge structure between them. The bridge pattern is useful when both the class and what it does vary often. The class itself can be thought of as the abstraction and what the class can do as the implementation. The bridge pattern can also be thought of as two layers of abstraction.

h

1

1/21/2021

Explain difference between the Facade, Proxy, Adapter and Decorator design patterns? | FullStack.Cafe

FullStackFSC

Café

Sign Out

This pattern involves an interface which acts as a bridge which makes the functionality of concrete classes independent from interface implementer classes. Both types of classes can be altered structurally without affecting each other. The example of bridge pattern implementation is when:

----Shape--/

\

Rectangle

Circle \ / \ RedRectangle BlueCircle RedCircle

/ BlueRectangle

refactored to:

----Shape--/ \ Rectangle(Color) Circle(Color)

Color / \ Blue Red

or in general when:

A / Aa / \ Aa1 Aa2

\ Ab / \ Ab1 Ab2

refactored to:

A / \ Aa(N) Ab(N)

N / \ 1

2

Source: tutorialspoint.com

Q19: What is Facade pattern?

Add to PDF

Mid

Answer Facade pattern hides the complexities of the system and provides an interface to the client using h

1

1/21/2021

Explain difference between the Facade, Proxy, Adapter and Decorator design patterns? | FullStack.Cafe

FullStackFSC

Café

Sign Out

This pattern involves a single class which provides simplified methods required by client and delegates calls to methods of existing system classes.

Source: tutorialspoint.com

Q20: What is Prototype pattern?

Add to PDF

Mid

Answer Prototype pattern refers to creating duplicate object while keeping performance in mind. This pattern involves implementing a prototype interface which tells to create a clone of the current object.

The Prototype pattern is used when creation of object directly is costly. For example, an object is to be created after a costly database operation. We can cache the object, returns its clone on next request and update the database as and when needed thus reducing database calls.

Source: tutorialspoint.com h

1

1/21/2021

Explain difference between the Facade, Proxy, Adapter and Decorator design patterns? | FullStack.Cafe

FullStackFSC

Café

Sign Out

Adapter pattern works as a bridge between two incompatible interfaces. This pattern involves a single class which is responsible to join functionalities of independent or incompatible interfaces (adaptees).

A real life example could be a case of card reader which acts as an adapter between memory card and a laptop. You plugin the memory card into card reader and card reader into the laptop so that memory card can be read via laptop.

Source: tutorialspoint.com

Q22: What does “program to interfaces, not implementations” mean? Related To: Software Architecture

Add to PDF

Mid

Answer Coding against interface means, the client code always holds an Interface object which is supplied by a factory. Any instance returned by the factory would be of type Interface which any factory candidate class must have implemented. This way the client program is not worried about implementation and the interface signature determines what all operations can be done. This approach can be used to change the behavior of a program at run-time. It also helps you to write far better programs from the maintenance point of view.

Source: tutorialspoint.com

Q23: What is Interpreter pattern? h

Add to PDF

Mid

1

1/21/2021

Explain difference between the Facade, Proxy, Adapter and Decorator design patterns? | FullStack.Cafe

FullStackFSC

Café

Sign Out

which tells to interpret a particular context.

This class diagram means that an AbstractExpression is either a TerminalExpression or a NonTerminalExpression . If its a NonTerminalExpression , it is itself an aggregation of one or several AbstractExpression .

Any mechanism for interpreting formal languages suites this pattern perfectly, it can be anything: from a simple calculator to a C# parser.

Source: tutorialspoint.com

Q24: What is Command pattern?

Add to PDF

Mid

Answer Command pattern is a data driven design pattern and falls under behavioural pattern category. A request is wrapped under an object as command and passed to invoker object. Invoker object looks for the appropriate object which can handle this command and passes the command to the corresponding receiver which executes the command.

Source: tutorialspoint.com

Q25: What is the Chain of Responsibility pattern?

Add to PDF

Mid

Answer As the name suggests, the chain of responsibility pattern creates a chain of receiver objects for a request. This pattern decouples sender and receiver of a request based on type of request. This h

1

1/21/2021

Explain difference between the Facade, Proxy, Adapter and Decorator design patterns? | FullStack.Cafe

FullStackFSC

Café

Sign Out

responsibility is an object oriented version of the if ... else if ... else if ....... else ... endif idiom, with the benefit that the condition–action blocks can be dynamically rearranged and

reconfigured at runtime.

Source: tutorialspoint.com

Q26: What is Abstract Factory pattern?
...


Similar Free PDFs