Skip to content
This repository has been archived by the owner on Dec 4, 2017. It is now read-only.

StyleGuide - Delegate complex instantiation logic to a factory service #1183

Open
mgechev opened this issue Apr 26, 2016 · 2 comments
Open

Comments

@mgechev
Copy link
Member

mgechev commented Apr 26, 2016

Based on discussions:

When the instantiation of given dependency or a series of dependencies involves complex logic or configuration you can consider using a factory service.

Taking this further, an abstract class can define the interface and the basic/common operations for the dependency instantiation and/or configuration of a series of abstract objects. Concrete implementations of the factory can specify the instantiation process further in order to return instances of concrete dependencies. This is the abstract factory pattern.

// cc @johnpapa @wardbell

@mgechev
Copy link
Member Author

mgechev commented Apr 26, 2016

To me it seems like a design decision not that much as a style which belongs to the guide.

What are your thoughts?

@johnpapa
Copy link
Contributor

Not sure ... Ward raised this and I see the value in it. Though I agree it may not be a style thing. Let's think on this

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants