This repository is a demonstration of the Abstract Factory design pattern implemented in Go. The project illustrates how to manage families of related products without specifying their concrete classes. The primary focus is on toy products, divided into two categories: Classic and Modern.
The Abstract Factory Pattern provides an interface for creating families of related or dependent objects without specifying their concrete classes. This project includes two factories: ClassicToyFactory
and ModernToyFactory
, each producing two types of products: Doll
and Car
. Each factory and product combination reflects a unique style and behavior, showcasing the pattern's ability to facilitate scalability and testability in software design.
- cmd/: Contains the application entry point (
main.go
), demonstrating the usage of different factories. - pkg/
- factory/: Includes the abstract factory interface (
factory.go
) and concrete factory implementations (classic_toy_factory.go
andmodern_toy_factory.go
). - product/: Contains interfaces and implementations for products (
dolls.go
andcars.go
).
- factory/: Includes the abstract factory interface (
Ensure you have Go installed on your system. You can download it from Go's official site.
Clone this repository to your local machine:
git clone https://github.com/arthurfp/Go_Abstract-Factory_Pattern.git
cd Go_Abstract-Factory_Pattern
To run the application, execute:
go run cmd/main.go
To execute the tests and verify the functionality:
go test ./...
Contributions are welcome! Please feel free to submit pull requests or open issues to discuss proposed changes or enhancements.
Arthur Ferreira - github.com/arthurfp