Flyweight definition: Avoid the overhead of a large number of small classes that have the same content (such as memory consumption), so that you share a class (meta-Class). Why use shared mode/Enjoy meta mode the principle of object-oriented language is that everything is an object, but if you really use it, sometimes the number of objects may seem very large, for example, word processing software, if each text as an object, thousands of words, the nu
Flyweight definition: Avoid the overhead of a large number of small classes with the same content (such as memory consumption), so that you can share a class (meta Class).
Why use shared mode/enjoy meta mode
The principle of object-oriented language is that everything is an object, but if the real use, sometimes the number of objects may appear very large, such as word processing software, if each text as an object, thousands of words, the number of
Original: fanix
Flyweight definition:Avoid the overhead of a large number of small classes with the same content (such as memory consumption), so that everyone can share a class (Meta class ).
Why?The principle of object-oriented language is that everything is an object, but if it is used, sometimes the number of objects may appear very large. For example, if the word processing software uses every text as an object, there are thousands of words, and
Flyweight definition: Avoid the overhead of a large number of small classes that have the same content (such as memory consumption), so that you share a class (meta-Class).Why use shared mode/enjoy meta modeThe principle of object-oriented language is that everything is an object, but if you really use it, sometimes the number of objects may seem very large, for example, word processing software, if each text as an object, thousands of words, the numb
40 + inspired non-profit Website Design (II)
Connect with over 40 non-profit website designs (I)
Carbonica
Greater Maple Valley Community Center
Speak life
Bill Melinda Gates Foundation
Housing works
Ty thousand shirts
Global oneness Project
The traveling guys
Project rescue
The worldwide blogger Bake Off
Children's rights
What's your status?
Bridgeway Foundation
Cam International
Design Mode (12): flyweight)
Flyweight)
Definition
Use the sharing technology to effectively support a large number of fine-grained objects.
Overview
The object-oriented thinking solves the abstract problem well, and generally does not have performance problems.
Flyweight pattern: Use shared technology to effectively support a large number of fine-grained objects.Flyweight is a shared object that can be used in multiple scenarios (context) at the same time, and Flyweight can act as a standalone object in each scene-this is no different from an instance of a non-shared object. Flyweight cannot make any assumptions about t
Intent
Use sharing to support large numbers of fine-GrainedObjects efficiently.
TheMotifGUI strategy of replacing heavy-weightWidgetsWith light-weightGadgets.
Problem
Designing objects down to the lowest levels of system"Granularity"ProvidesOptimal Flexibility, But can be unacceptably expensive in terms of performance and memory usage.Discussion
The Flyweight pattern describes how to share objects to allow their use at fine granularities without pr
Flyweight definition:Avoid the overhead of a large number of small classes with the same content (such as memory consumption), so that everyone can share a class (Meta class ).
Why?The principle of object-oriented language is that everything is an object, but if it is used, sometimes the number of objects may appear very large. For example, if the word processing software uses every text as an object, there are thousands of words, and the number of ob
Flyweight definition:
Avoid the overhead of a large number of small classes with the same content (such as memory consumption), so that you can share a class (meta Class).
Why use?
The principle of object-oriented language is that everything is an object, but if the real use, sometimes the number of objects may appear very large, such as word processing software, if each text as an object, thousands of words, the number of objects is thousands of,
Flyweight Definition:Avoid the overhead of a large number of small classes that have the same content (such as memory-intensive), so that you share a class (meta-Class). why use?The principle of object-oriented language is that everything is an object, but if you really use it, sometimes the number of objects may seem very large, for example, word processing software, if each text as an object, thousands of words, the number of objects is thousands of
Definition of a patternThe Flyweight pattern is an important implementation of Stoke technology, which is defined as follows:Use sharing to support large numbers of fine-grained objects efficiently.Use shared objects to effectively support a large number of fine-grained objects.The definition of the enjoy meta-mode presents two requirements: fine-grained objects and shared objects. Allocating too many objects will compromise the performance of the pro
Flyweight definition:Avoid the overhead of a large number of small classes with the same content (such as memory consumption), so that everyone can share a class (Meta class ).Why?The principle of object-oriented language is that everything is an object, but if it is used, sometimes the number of objects may appear very large. For example, if the word processing software uses every text as an object, there are thousands of words, and the number of obj
not changed as the environment changes. Therefore, a share can be intrinsic and shareable.? A foreign State is changed with the change of the environment and cannot be shared. The outer state of the object must be saved by the client, and then passed in to the inside of the object when it is needed after the object is created. The external state can not affect the intrinsic state of the object of the enjoyment, they are independent of each other.The "Enjoy meta" mode can be divided into simple
This article mainly introduces the metadata sharing mode in the php design mode. if you are interested, refer to it.
I. intentionUse sharing technology to effectively support a large number of fine-grained objects
The metadata mode changes the storage overhead of objects.
II. structure of the metadata mode
III. primary roles in the metadata modeAbstract Flyweight role:This role is a superclass of all the specific metadata classes, and defines the p
GOF: The use of shared technology to effectively support a large number of fine-grained objects.
Explain the concept: that is, if you have multiple identical objects in a system, then just share one copy, and you don't have to instantiate an object for each. For example (refer to the example in Gof book) a text system, each letter to set an object, then the large lowercase letter is 52, then you need to define 52 objects. If there is a 1M text, then the letter is so much, if each letter defines
Flyweight definition:Avoid the overhead of a large number of small classes that have the same content (such as memory-intensive), so that you share a class (meta-Class).
why use?The principle of object-oriented language is that everything is an object, but if you really use it, sometimes the number of objects may seem very large, for example, word processing software, if each text as an object, thousands of words, the number of objects is thousands of
Flyweight mode causes:creating objects is the most common operation in an object-oriented system design implementation. There is a problem here: If an application uses too many objects, it can cause significant storage overhead. Especially for a large number of lightweight (fine-grained) objects, such as in the design process of the document editor, if we create an object for the absence of letters, the system may waste storage overhead due to a large
Implementation Method of the index intent structure participant applicability effect-related mode (1): Use FlyweightFactory to manage Flyweight objects. Intention to use the sharing technology to effectively support a large number of fine-grained objects. Use sharing to support large numbers of fine-grained objects efficiently. The object diagram below the structure shows how to share Flyweight: the partici
Document directory
Flyweight Mode
The string in C # is not in the Flyweight mode.
String and Flyweight modes in C #
More Thoughts
I wrote this article mainly because there are many misunderstandings about the C # string and the metadata mode on the Internet.Flyweight Mode
Let's talk about this name first. fly is a fly. Yes, it does not mean fly. It means
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.