Skip to content

A Go project demonstrating the Composite design pattern with a hierarchical structure management system. This repository showcases the creation and manipulation of composite and leaf nodes, emphasizing best practices in design patterns and unit testing.

Notifications You must be signed in to change notification settings

arthurfp/Go_Composite_Pattern

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hierarchical Structure Management Using Composite Pattern in Go

Overview

This repository demonstrates the application of the Composite design pattern in Go. The project highlights the implementation of composite structures, allowing individual objects and compositions of objects to be treated uniformly. This pattern is ideal for representing part-whole hierarchies in a system.

Pattern Description

The Composite pattern is used to compose objects into tree structures to represent part-whole hierarchies. It lets clients treat individual objects and compositions of objects uniformly. In this project, we have implemented both Leaf and Composite components to demonstrate this pattern effectively.

Project Structure

  • cmd/: Contains the application entry point (main.go), demonstrating the creation and manipulation of the composite structure.
  • pkg/
    • composite/: Houses the component interfaces and their implementations (Leaf and Composite).

Component Management

This project features the management of components within a composite structure. It includes functionality for adding, removing, displaying, and counting components, showcasing the flexibility and power of the Composite pattern.

Getting Started

Prerequisites

Ensure you have Go installed on your system. You can download it from Go's official site.

Installation

Clone this repository to your local machine:

git clone https://github.com/arthurfp/Go_Composite_Pattern.git
cd Go_Composite_Pattern

Running the Application

To run the application, execute:

go run cmd/main.go

Running the Tests

To execute the tests and verify the functionality:

go test ./...

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues to discuss proposed changes or enhancements.

Author

Arthur Ferreira - github.com/arthurfp

About

A Go project demonstrating the Composite design pattern with a hierarchical structure management system. This repository showcases the creation and manipulation of composite and leaf nodes, emphasizing best practices in design patterns and unit testing.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages