- Information
- AI Chat
Was this document helpful?
CS 3203 Software Engineering Lab 5
Course: Software Engineering (CS391)
174 Documents
Students shared 174 documents in this course
University: Fayoum University
Was this document helpful?
Eng. Yossr - Eng. Esraa
1
Design Pattern
What Is a Design Pattern?
A design pattern provides a general reusable solution for the common problems that occur
in software design.
The pattern typically shows relationships and interactions between classes or objects.
WHY?
• The idea is to speed up the development process by providing well tested, proven
development/design paradigm.
• Design patterns are programming language independent strategies for solving a
common problem.
• That means a design pattern represents an idea, not a particular implementation. By
using the design patterns, you can make your code more flexible, reusable, and
maintainable.
Types of Design Patterns
Gang of Four categorized the Design Pattern into three main categories based on the three-
problem area of software architecture. They are as follows: -
1. Creational patterns
2. Structural patterns
3. Behavioral patterns
1. Creational Design Patterns
What is the Creational Design Pattern in C#?
Creational design patterns are design patterns that deal with object creation mechanisms
i.e., trying to create objects in a manner that is suitable to a given situation.
The Creational design patterns are categorized into two types:
Object-creational patterns: The Object-creational patterns deal with object creation.
Here, it defers part of its object creation to another object.
Class-creational patterns: The Class-creational patterns deal with class-instantiation.
Here, it defers its object creation to subclasses.
When to use the Creational Design Pattern?
Ex:
Suppose a developer wants to create a simple DBConnection class to connect to a database
and wants to access the database at multiple locations from code, generally what
developer will do is create an instance of DBConnection class and use it for doing database
operations wherever required. Which results in creating multiple connections from the
database as each instance of DBConnection class will have a separate connection to the
database. To deal with it, we create DBConnection class as a singleton class, so that only
one instance of DBConnection is created and a single connection is established. Because we
CS 3203 Software Engineering (1) – 2020/2021
Lab (6)