Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Flyweight pattern
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Structure === [[File:w3sDesign Flyweight Design Pattern UML.jpg|frame|none|A sample UML class and [[sequence diagram]] for the Flyweight design pattern.<ref>{{cite web|title=The Flyweight design pattern - Structure and Collaboration|url=http://w3sdesign.com/?gr=s06&ugr=struct|website=w3sDesign.com|access-date=2017-08-12}}</ref>]] The above [[UML]] [[class diagram]] shows: * the <code>Client</code> class, which uses the flyweight pattern *the <code>FlyweightFactory</code> class, which [[Factory class|creates and shares <code>Flyweight</code> objects]] * the <code>Flyweight</code> [[Interface (computing)|interface]], which takes in extrinsic state and performs an operation *the <code>Flyweight1</code> class, which implements <code>Flyweight</code> and stores intrinsic state The sequence diagram shows the following [[Runtime (program lifecycle phase)|run-time]] interactions: # The <code>Client</code> object calls <code>getFlyweight(key)</code> on the <code>FlyweightFactory</code>, which returns a <code>Flyweight1</code> object. # After calling <code>operation(extrinsicState)</code> on the returned <code>Flyweight1</code> object, the <code>Client</code> again calls <code>getFlyweight(key)</code> on the <code>FlyweightFactory</code>. # The <code>FlyweightFactory</code> returns the already-existing <code>Flyweight1</code> object.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)