Skip to content

Fulnir/Elixir-Design-Patterns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elixir Design Patterns

Build Status codecov Ebert License

🚧

Creational patterns

Builder

See https://en.wikipedia.org/wiki/Builder_pattern

The simplest way to build a struct.

car = Car.new("Blues Mobil")
# Or full struct
car = %Car{name: "Blue Ocean", color: :blue, color_doors: :cyan}

With a builder

CarBuilder.build()
    |> name("Blues Mobil")
    |> color_doors(:black)

Or with the Director

car = CarDirector.construct("Blues Mobil")

Builder Test

Singleton

This is useful when exactly one object is needed to coordinate actions across the system.

Singleton Test

See https://en.wikipedia.org/wiki/Singleton_pattern

🚧

Build Status codecov Ebert

Copyright © 2018 Edwin Bühler License

Releases

No releases published

Packages

No packages published

Languages