8 Design Patterns And Modeling

Software Engineering · Unit 8

Design Patterns and Modeling

Exam-focused notes for Design Patterns and Modeling (Software Engineering, BIT302): what the TU syllabus asks and how it has actually been tested, with 4 solved past questions from this unit.

Design Patterns and Modeling in short

This chapter covers reusable design solutions (patterns), the models used to estimate software cost, and two common kinds of system: transaction processing and language processing.

Design Patterns and Modeling: notes

Design patterns and their benefits

A design pattern is a tested, reusable solution to a common design problem. It describes the problem and the core of its solution, so the solution can be applied many times in different forms. Patterns were made popular by the "Gang of Four" book.

A pattern description has four parts:

  • Name: a meaningful label.
  • Problem description: when the pattern applies.
  • Solution description: the design elements and how they relate (a template, not final code).
  • Consequences: results and trade-offs of using it.

Common patterns:

  • Creational: Singleton, Factory, Builder.
  • Structural: Adapter, Decorator, Facade.
  • Behavioural: Observer, Strategy, Iterator.

Example, Singleton makes sure a class has only one object.

public class Config {
    private static Config instance;
    private Config() { }
    public static Config getInstance() {
        if (instance == null) instance = new Config();
        return instance;
    }
}

Observer lets many objects react when one object changes, such as several views updating when data changes.

Benefits:

  • Reuse of proven experience.
  • A shared vocabulary for designers.
  • Better quality and flexibility.
  • Faster design and easier documentation.

What this unit covers

  • Design patterns and their benefits
  • Algorithmic cost modeling
  • COCOMO estimation models
  • Transaction processing systems
  • Language processing systems

Design patterns and their benefits

2082 · 5 marks

How do you think design patterns help in software development? Explain. [5]

A design pattern is a general, reusable solution to a commonly occurring problem within a given context in software design. It is not a finished design that can be directly converted into code, but rather a template or description for how to solve a problem that can be used in many different situ...

Open this answer on its own page →

Algorithmic cost modeling

2080 · 10 marks

What do you understand by algorithmic cost modeling? Explain COCOMO estimation models.[10]

--- Algorithmic cost modeling is a technique used in software project management where a mathematical model (formula or algorithm) is used to estimate the cost, effort, and duration of a software project based on measurable attributes of the software and the development environment. The general f...

Open this answer on its own page →

Transaction processing systems

2079 · 5 marks

Explain transaction procession system and language processing system. [5]

Note: The following answer is based on standard computer science / database and system software concepts, as no specific curriculum notes were available. --- A Transaction Processing System is a type of information system that collects, stores, modifies, and retrieves data transactions of an orga...

Open this answer on its own page →

COCOMO estimation models

0 · 5 marks

Write short notes on: a. COCOMO b. Design Pattern [5]

Show solved answer

Short Notes

a. COCOMO (Constructive Cost Model)

COCOMO is an algorithmic software cost estimation model developed by Barry Boehm in 1981. It is used to estimate the effort, time, and cost required to develop a software project based on the size of the software (measured in KLOC - Kilo Lines of Code).

Types of COCOMO:

1. Basic COCOMO

  • Provides a rough estimate of software development effort.
  • Formula:

Effort (E) = a × (KLOC)^b (Person-Months) Time (T) = c × (E)^d (Months)

2. Intermediate COCOMO

  • Refines the basic model by introducing cost driver attributes (hardware, personnel, project attributes).
  • More accurate than basic COCOMO.

3. Detailed COCOMO

  • Applies cost drivers at each phase of the software development lifecycle.
  • Most accurate among the three.

Project Categories:

ModeDescriptionExample
OrganicSmall, simple projectsPayroll system
Semi-detachedMedium complexityCompiler design
EmbeddedComplex, tight constraintsReal-time systems

Advantages:

  • Easy to use and understand
  • Provides quantitative estimates

Limitations:

  • Based only on KLOC (does not consider modern development methods)
  • Not suitable for agile or object-oriented projects

b. Design Pattern

A Design Pattern is a general, reusable solution to a commonly occurring problem in software design. It is not a finished design but a template or description of how to solve a problem that can be used in many different situations.

The concept was popularized by the "Gang of Four" (GoF) - Gamma, Helm, Johnson, and Vlissides in their book "Design Patterns: Elements of Reusable Object-Oriented Software" (1994).

Types of Design Patterns:

1. Creational Patterns

  • Deal with object creation mechanisms.
  • Examples: Singleton, Factory, Abstract Factory, Builder, Prototype

2. Structural Patterns

  • Deal with object composition and structure.
  • Examples: Adapter, Bridge, Composite, Decorator, Facade

3. Behavioral Patterns

  • Deal with communication and responsibility between objects.
  • Examples: Observer, Strategy, Command, Iterator, Template Method

Benefits of Design Patterns:

  • Promotes code reusability and maintainability
  • Provides a common vocabulary for developers
  • Speeds up the development process
  • Helps in writing flexible and scalable code

Example - Singleton Pattern:

Ensures that a class has only one instance and provides a global point of access to it.

class Singleton {
    private static Singleton instance;
    private Singleton() {}
    public static Singleton getInstance() {
        if (instance == null)
            instance = new Singleton();
        return instance;
    }
}
Open this answer on its own page →