From the course: Design Patterns: Creational

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Challenge: Design a factory

Challenge: Design a factory

From the course: Design Patterns: Creational

Start my 1-month free trial

Challenge: Design a factory

(upbeat music) - [Instructor] Take a look at these classes. We have a client, a browser application which organizes all the elements in a browser page using a document. The document has a method, createElement, that takes a string representing the tag name of the element you want to create, and creates an element of that type. So if you want to create a development, you pass the string div to createElement, and get back a divElement. And likewise, if you to create a buttonElement, you pass the string button to createElement, and get back a button element. Take a few minutes and look at this diagram. How would you organize this diagram into a design that uses a factory pattern for creating different kinds of HTML element objects? This challenge should take you about five to 10 minutes.

Contents