This is the second part of the series "The Singleton and Factory Design Patterns in the real world." Welcome back. Throughout the first part of the series, I provided you with an overview of building object-oriented forms using two popular design patterns: the Singleton and the Factory patterns.
At this point, I assume that these aren't foreign concepts to you, since they were reviewed in the first part. Just in case you don't feel very seasoned with patterns, you should start by reading my previous article, where I offered a friendly introduction to them.
If you're used to writing a lot of repetitive code to build your web forms, probably you've found the technique that I previously explained to create forms, based on an object-oriented approach, quite interesting. Due to the advantages inherent in this method, form generation can be translated into a flexible and straightforward process that strongly encourages code re-use.
Focusing again on the objective of this series, this second part is aimed specifically at implementing the Factory Pattern, by designing a form element factory, which will be tasked with building regular form components, in this way abstracting the rendering process for each element.
Essentially, the article is intended to provide a practical step-by-step guide to apply design patterns in real world conditions, such as form design an implementation, by attending the requirements that most developers must face on a frequent basis.
Thus, it's time to go deeper into the object-oriented form generation method. Let's go!