Design Pattern Download: The Composite Pattern

Example

When to use the Composite?

  • When we want to represent a tree like hierarchy in code
  • When the functionality of one node in the tree depends on their parent or children to do some function

What is the Composite Pattern composed of?

  • Hierarchal classes ( each class will have a list of the class type on layer below it)

Implementation

The Interface

The Hierarchal Classes

--

--

--

I am a software engineer working for Amazon living in SF/NYC.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Raycast for FPS shooting in Unity 3D

How to Become a Successful Web Developer in 2021

Real Talk with Bukola Akinfaderin

Humidifiers, the harm to the human body to see this article is Enough!

LATEST TRENDS IN FRONT END DEVELOPMENT 2022

How to install Ansible in CentOS 8

Building EKS cluster using Terraform

Developers Want to Code, Hence Serverless

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Matthew MacFarquhar

Matthew MacFarquhar

I am a software engineer working for Amazon living in SF/NYC.

More from Medium

Auto-configuration with Spring Boot

Debugging RAM: Detect/Fix Memory Leaks in Managed Languages — Heap Deep Dive, Part 2

Unit Testing Apache Camel

All You Need To Know About JVM Cache Management and Garbage Collection (With Commands) Pt. 2/2