In this video Emmanuel Henri explains the flyweight pattern with an example.
- [Instructor] The Flyweight pattern…is a method to minimize recreating the same items twice,…and therefore minimize the memory impact in our systems.…You have to understand that whenever we create new items…with our applications,…we stack these items into the memory of a browser.…Your browsers use the Flyweight pattern to save images,…for example, in memory, so they don't load twice.…And guess what, the Flyweight pattern…uses a similar approach to the Singleton.…So we're actually making sure…that we're not recreating another instance of the car…and then we're passing the doors and so on and so forth.…
And if we have created it,…then we're using the instance that we already created,…and then passing it to the new object.…So this is one way of doing it,…but you could also put all kinds of conditionals…into your constructor to make sure…that you're not repeating the same information.…So this is how the Flyweight pattern works…and you can take a look at more examples on the web,…by searching for Flyweight.…
- What's a pattern?
- What's the role of callbacks?
- Creational patterns, including Singleton and Factory
- Structural patterns, including model-view-controller
- Behavioral patterns, including Memento and Mediator
Skill Level Intermediate
2. Creational Patterns
3. Structural Patterns
4. Behavioral Patterns
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.