LogoEdwin's Blog
Logo Inverted Logo
  • Posts
  • AWS
    • Local Stack
      • AWS and Localstack
  • Golang
    • Design Patterns
      • Factory method
Hero Image
Handling creating of concrete types with Factory method

Factory Method Is a pattern of type creational that delegates the construction of objects to an interface. The interface has a method that return a type of specific object. Problem The company TransportPassengers has to transport many passengers after your workday. Solution First of all, we have to create our factory: func GetTransportType(quPassengers int) (product.ITransport, error) { if quPassengers >= 1 && quPassengers <=5 { return concrete.NewTaxi(), nil } if quPassengers >= 6 && quPassengers <=15 { return concrete.

April 8, 2021 Read
Navigation
  • About
  • Skills
  • Experiences
  • Recent Posts
Contact me:
  • Email: ing.edwincabezas@gmail.com
  • Phone: +573163738937

Stay up to date with email notification

We'll never share your email with anyone else.

Toha Theme Logo Toha
© 2020 Copyright.
Powered by Hugo Logo