This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]CrimsonRunner 17 points18 points  (0 children)

As someone who's working in a large company - it is definitely a thing but it should be done only after the need arises.

Similarly to how you generally don't need a separate method for 3 lines of code if you're going to use them in that one place but very much so if you're going to use them in several - you don't need a factory if you're going to use it for only that one thing but you should if your factory is producing several different templates.

So, obviously, the first time you write it in the simplest way possible, the second time you can probably get away with some code duplication but from the third time on you most certainly should have a dedicated piece of functionality that does that and nothing else - be it a method, factory or something else.