8000 GitHub - zidane0000/POSD · GitHub
[go: up one dir, main page]

Skip to content
zidane0000Public

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pattern-oriented Software Design - POSD

Table of Contents

  1. Introduction
  2. Design Patterns Used in This Repository
  3. Folder Structure and Purpose
  4. System Architecture Overview
  5. Setting Up the Environment to Build This Repository

Introduction

This project demonstrates the application of pattern-oriented software design principles in C++. It includes implementations of various design patterns to manage shapes and their operations.

Design Patterns are models of code that solve classic problems. They are solutions to software design problems that you can find in a real-world application. A Design Pattern is not a code that is ready to be used in your application, but it is a model that you can use to solve a problem. Design patterns are language neutral, so they can be applied to any language that supports object-orientation.

Design Patterns Used in This Repository

This repository demonstrates the use of several design patterns to solve common software design problems. Below is a list of the design patterns implemented:

  1. Composite Pattern

    • Used to represent and manage compound shapes that can contain other shapes. This allows treating individual shapes and groups of shapes uniformly.
  2. Visitor Pattern

    • Enables operations (like calculating area or generating info) to be performed on shapes without modifying their classes.
  3. Iterator Pattern

    • Provides a way to traverse shapes in a compound structure, such as iterating through the components of a compound shape.
  4. Builder Pattern

    • Used to construct shapes and compound shapes incrementally, providing a flexible way to create complex objects.
  5. Filter Pattern

    • Allows filtering shapes based on specific criteria, such as area, perimeter, or type.

These patterns are implemented in the src/ folder and are tested extensively in the test/ folder.

Folder Structure and Purpose

src/

This folder contains the core implementation of the project, including:

  • Shape Classes: Represent individual shapes like rectangles, ellipses, and triangles.
  • CompoundShape: Implements the Composite Pattern to manage groups of shapes.
  • Visitors: Implements the Visitor Pattern for operations like calculating area and generating info.
  • Iterators: Implements the Iterator Pattern to traverse shapes in a compound structure.
  • Filters: Implements the Filter Pattern to filter shapes based on criteria like area, perimeter, or type.
  • Builders: Implements the Builder Pattern to construct shapes and compound shapes incrementally.
  • Utilities: Provides helper functions for shape management and filtering.

test/

This folder contains unit tests for all major components of the project. It uses Google Test to validate the functionality of:

  • Shape classes (e.g., ut_rectangle.h, ut_ellipse.h, ut_triangle.h)
  • Compound shapes (ut_compound_shape.h)
  • Visitors (ut_visitor.h)
  • Iterators (ut_iterator.h)
  • Filters (ut_filter.h)
  • Builders (ut_shape_builder.h)
  • Parsers (ut_shape_parser.h)
  • Sorting (ut_sort.h)
  • Terminal interaction (ut_terminal.h)

bin/

This folder stores the compiled binaries of the project.

obj/

This folder stores the compiled object files (.o) generated during the build process.

Root Files

  • makefile: Automates the build process, including compilation and testing.
  • README.md: Provides documentation for the project.
  • input.txt: Example input file for testing or demonstration purposes.

System Architecture Overview

graph TD
    A[Main Program] -->|Input Parsing| B[ShapeParser]
    B -->|Build Shapes| C[ShapeBuilder]
    C -->|Create Shapes| D[Shapes]
    D -->|Composite Pattern| E[CompoundShape]
    D -->|Visitor Pattern| F[Visitors]
    D -->|Iterator Pattern| G[Iterators]
    D -->|Filter Pattern| H[Filters]
    E -->|Manage Shapes| I[Shape Collection]
    F -->|Calculate Area| J[AreaVisitor]
    F -->|Generate Info| K[InfoVisitor]
    G -->|Traverse Shapes| L[ShapeIterator]
    H -->|Filter Shapes| M[ShapeFilter]
    M -->|Apply Filters| N[ShapeSetter]
Loading

This diagram illustrates the relationships between the main components and the design patterns used in the repository.

Setting Up the Environment to Build This Repository

If you are starting with a fresh operating system, follow these steps to set up the required tools and dependencies to build and run this repository.

Prerequisites

  1. Install make

    • make is required to build the project using the provided makefile.
    • On Ubuntu (or WSL):
    sudo apt update
    sudo apt install make
    • On Windows, you can install make via MinGW or Cygwin.
  2. Install g++

    • A C++ compiler is required to compile the source code.
    • On Ubuntu (or WSL):
    sudo apt install g++
    • On Windows, you can install g++ via MinGW or WSL.
  3. Install CMake

    • CMake is required to build Google Test and other CMake-based tools.
    • On Ubuntu (or WSL):
    sudo apt install cmake
    • On Windows, download and install CMake from cmake.org.
  4. Install Google Test (gtest)

    • Google Test is required to run the unit tests.
    • On Ubuntu (or WSL):
    sudo apt install libgtest-dev
    cd /usr/src/gtest
    sudo cmake .
    sudo make
    sudo cp *.a /usr/lib
    • On Windows, you can use vcpkg to install Google Test:
    git clone https://github.com/microsoft/vcpkg.git
    cd vcpkg
    .\bootstrap-vcpkg.bat
    .\vcpkg.exe install gtest

Building the Project

  1. Clone the repository:

    git clone https://github.com/zidane0000/POSD.git
    cd POSD
  2. Build the project:

    make
  3. Run the tests:

    ./bin/ut_main

Cleaning the Build

To clean up the build artifacts, run:

make clean

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

0