none
Flyweight design pattern

所有回覆

  • Can somebody please respond to this post.

    Cheers

    Thompson

    2012年2月10日 上午 09:39
  • Hi,

    Flyweight as per dofactory: A fine-grained instance used for efficient sharing. So what I can make out from this is [considering fat server and dumy client]:  Rather than providing the complete object (which will be heavy for the client to use) to the client(s), the server will provide only part of the object which would not be heavy for client to handle. This undoubtly helps in performance of client(s), helps in sharing of object(s).

    A typical scenario could be: your server is holding a dataset sales leads and your client only needs a specific lead details from the complete set, so in this case rather cosuming complete dataset the client can make use of the specific lead datatable which is comparatively light and less resource frugal.

    A relative example of such approach could be usage of JSON

    let us know this helps you.


    Manish Patil http://patilmanishrao.wordpress.com Posting is provided AS IS with no warranties, and confers no rights.

    Manish Patil's Blog

    ↑ Grab this Headline Animator

    2012年3月7日 上午 11:26
  • An example of the Flyweight pattern is how fonts are handled in a graphic engine. The basic idea is that you have a single immutable instance of a character that is retrieved from a shared repository or collection.


    2012年3月14日 下午 11:32
  • when you use

    string s = "Hai";

    string s2 = "Hai";

    Though the instances are different, both s1 and s2 are pointing to same memory location. This can be checked by looking at the hashcode s.GetHashCode(). However when s2 is changed to something else, it changes its reference to point to new memory location.

    you can even store the string in a pool using String.Intern method..

    I thing this mechanism is one of the implementation of flyweight pattern


     

    2012年3月15日 上午 09:37