New Library classes can be very easily added and extending the factory class won’t affect the client code at all. For example, if we start adding water transportation and need to add vehicles like ships, and submarines. With this new implementation, the factory class can be extended as and when required. The client just needs to make calls to the factory class’ build method and pass the type it wants without worrying about the actual implementation of the creation of objects. The factory class is now responsible for deciding which object type to create based on the input provided by the client. In the above example, we have totally decoupled the selection of types for object creation from the Client. ISRO CS Syllabus for Scientist/Engineer Exam.ISRO CS Original Papers and Official Keys.GATE CS Original Papers and Official Keys.Top 10 System Design Interview Questions and Answers.Top 20 Puzzles Commonly Asked During SDE Interviews.Top 100 DSA Interview Questions Topic-wise.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |