kdocs
GitHub
SC - Software Architecture
SC - Software Architecture
  • About
    • Architectural Requirements (RAs)
    • Architectural Perspectives
  • Software Design
    • Microservices
      • Patterns
    • Monolithic
    • C4 Model
  • Software Architectures
    • Clean Architecture
    • DDD (Domain Driven Design)
      • Strategic Modeling
      • Tactical Modeling
    • Event Driven Architecture
      • CAP Theorem
    • Hexagonal Architecture (Ports and Adapters)
  • Design Patterns
    • Behavioral
    • Creational
    • Data Access
    • Structural
  • Practices
    • Clean Code
    • SOLID
  • Others
    • CQRS
Powered by GitBook
On this page
  • Adapter
  • Bridge
  • Composite
  • Composition Root
  • Decorator
  • Facade
  • Flyweight
  • Proxy
  1. Design Patterns

Structural

How objects relate to each other.

PreviousData AccessNextClean Code

Last updated 4 months ago

Adapter

Bridge

Composite

Composition Root

It is the main entry file for an application and where you instantiate everything used by the application.

Decorator

  • To extend an object, without changing the original object implementation.

  • Is used for the O of SOLID.

    • Open to extension, Closed to modification.

  • Ex.: You make the DecoratedComponent implement the same interface as the object you want to extend. And in the DecoretedComponent constructor you pass the original component as an argument.

class DecoratedComponent implements SomeObject {
	constructor (readonly obj: SomeObject) {
	}

	someFunc() {
		[extendDoingMoreStuff]
		...
		return this.obj.func()
	}
}

$Decorator \neq Middleware$, since middle kind of chains the layers in an array, and the decorators chains them kind of like recursively, one is inside of the other.

Facade

  • It is all about simplicity.

  • It's like a simplified 'mask' that will hide all the complexity for the outside.

  • You can encapsulate complex classes and functionalities with simpler classes that will deal with the complexity themselves and expose only simple statements.

    • Ex.: The Jquery is a Facade for some functions that deal with DOM manipulation.

Flyweight

Proxy

Designed to intercept a call, and do more stuff before releasing it.

Javascript natively supports it with new Proxy() .

Ex.: Frameworks like VUE use proxy to deal with reactivity for variable changes.

The Catalog of Design Patterns
Logo