Slide - 8 (Design Pattern) (1)
Slide - 8 (Design Pattern) (1)
Lecture 10:
Design Pattern
Md. Al-Hasan
Assistant Professor
Department of Computer Science & Engineering (CSE)
Bangladesh Army University of Science & Technology (BAUST)
Design Patterns
We will just see some different definition to understand design pattern better.
Design patterns are reusable solutions to the problems that we encounter in the day to
day programming. They are generally targeted at solving the problems of object
generation and integration. In other words, Design patterns acts as templates which can
be applied to the real-world programming problems.
Design patterns are used to represent some of the best practices adapted by
experienced object-oriented software developers. A design pattern systematically
names, motivates, and explains a general design that addresses a recurring design
problem in object-oriented systems. It describes the problem, the solution, when to
apply the solution, and its consequences. It also gives implementation hints and
examples.
Evolution of design Patterns
The four authors of the book famously know as Gang of four are the ones
who brought the concepts of design patterns in their book “Elements of
reusable Object-Oriented software” .
Gang of Four has divided the book into two parts with first part explaining
about the pros and cons of object oriented programming and the second part
describes the evolution of 23 classic software design patterns.
2. Best Practices
Design patterns have been evolved over a long period of time and they provide best
solutions to certain problems faced during software development. Learning these
patterns helps inexperienced developers to learn software design in an easy and faster
way.
Types of Design Patterns
3 types based on different problems encountered in the real world applications:
– Creational
– Structural and
– Behavioral
Creational design patterns: These patterns deal with object creation and initialization.
Creational pattern gives the program more flexibility in deciding which objects need to be
created for a given case.
Examples: Singleton , Factory and Abstract Factory etc.
Structural design patterns: This pattern deals with class and object composition. In simple
words, This pattern focuses on decoupling interface, implementation of classes and its
objects.
Examples: Adapter, Facade and Bridge etc
Behavioral design patterns: These patterns deal with communication between Classes and
objects.
Examples: Chain of Responsibility, Command and Interpreter etc.
https://www.geeksforgeeks.org/mvc-design-pattern/
Architectural Pattern
An architectural pattern is a general, reusable solution to a commonly occurring problem
in software architecture within a given context.
Architectural patterns are similar to software design patterns but have a broader scope. The
architectural patterns address various issues in software engineering, such as:
computer hardware performance limitations
high availability and
minimization of a business risk
Some architectural patterns have been implemented within software frameworks.
The Model View Controller (MVC) design pattern specifies that an application consist of a
data model, presentation information, and control information. The pattern requires that each
of these be separated into different objects.
MVC is more of an architectural pattern, but not for complete application. MVC mostly
relates to the UI / interaction layer of an application. You’re still going to need business
logic layer, maybe some service layer and data access layer.
Pre-requisite Concept
For understanding design patterns better it is very
important to have basic knowledge about the
following object oriented concepts
– Abstraction
– Inheritance
– Polymorphism
– Encapsulation
– Interfaces
– Classes
– Abstract classes
Interface
An interface is defined as a syntactical contract that all the classes inheriting the
interface should follow. The interface defines the 'what' part of the syntactical
contract and the deriving classes define the 'how' part of the syntactical contract.
Abstract Class
- Abstract classes allow you to provide default functionality for the subclasses. Compared to
interfaces abstract classes can have implementation. Without implementation an abstract
class does the same as an interface but C# allows you to inherit from / implement multiple
interfaces but inherit from one base class only.
- The short answer: An abstract class allows you to create functionality that subclasses can
implement or override. An interface only allows you to define functionality, not implement it.
And whereas a class can extend only one abstract class, it can take advantage of multiple
interfaces.
- No difference but only difference a class can inherit from one class (concrete or abstract)
but a class can implement lots of interface means more than one interface
http://
csharp-video-tutorials.blogspot.com/2012/06/part-33-c-tutorial-difference-between.html
# Design pattern link:
1. https://sourcemaking.com/design_patterns
2. read :
• Creational design patterns-> Abstract Factory,
Singleton
• Structural design patterns-> Adapter
• Behavioral design patterns-> Chain of
Resposibility
What Next??
Thank You