Design Patterns : Performance

  • use the flyweight pattern to reduce object creation [The flyweight pattern uses a factory instead of ‘new’ to reuse objects rather than always create new ones].
  • The Singleton pattern and the Flyweight (object factory) pattern are useful to limit numbers of objects of various types and to assist with object reuse and reduce garbage collection.
  • Use the Data Access Object pattern to decouple business logic from data access logic, allowing for optimizations to be made in how data is managed.
  • Use the Fast-Lane Reader pattern to accelerate read-only data access by not using enterprise beans.
  • Use the Front Controller pattern to centralize incoming client requests, allowing optimizations to be made in aggregating the resulting view.
  • Use the Front Controller pattern to channel all client requests through a single decision point, which allows the application to be balanced at runtime.
  • Use the Page-by-Page Iterator pattern to efficiently access a large, remote list by retrieving its elements one sublist of value objects at a time.
  • Use the Session Facade pattern to provide a unified, workflow-oriented interface to a set of enterprise beans, thus minimizing client calls to server EJBs.
  • Use a Session Facade to provide a simple interface to a complex subsystem of enterprise beans, and to reduce network communication requirements
  • Use the Value Object pattern to efficiently transfer remote, fine-grained data by sending a coarse-grained view of the data.
  • Use the factory pattern to enable reuse or cloning of objects
  • The Abstract Factory design pattern uses a single class to create more than one kind of object.
  • An alternative to the Flyweight pattern is the Prototype pattern, which allows polymorphic copies of existing objects. The Object.clone() method signature provides support for the Prototype pattern.
  • Prototypes are useful when object initialization is expensive, and you anticipate few variations on the initialization parameters. Then you could keep already-initialized objects in a table, and clone an existing object instead of expensively creating a new one from scratch.
  • Immutable objects can be returned directly when using Prototyping, avoiding the copying overhead.
  • Combine multiple remote calls for state information into one call using a value object to wrap the data (the Value Object pattern, superceded by local interfaces in EJB 2.0).
  • Where long lists of data are returned by queries, use the Page-by-Page Iterator pattern: a server-side object that holds data on the server and supplies batches of results to the client.
  • When the client would request many small data items which would require many remote calls to satisfy, combine the multiple calls into one call which results in a single Value Object which holds all the data required to be transferred. Use the Value Object to send a single coarse-grained object from the server to the client(s).
  • For read-only access to a set of data that does not change rapidly, use the Fast Lane Reader pattern which bypasses the EJBs and uses a (possibly non-transactional) data access object which encapsulates access to the data. Use the Fast Lane Reader to read data from the server and display all of them in one shot.
  • Wrap multiple entity beans in a session bean to change multiple EJB remote calls into one session bean remote call and several local calls (pattern called SessionFacade).
  • Cache EJBHome references to avoid JNDI lookup overhead (pattern called ServiceLocator).
  • The ServiceLocator/EJBHomeFactory Pattern reduces the expensive JNDI lookup process by caching EJBHome objects.
  • The SessionFacade Pattern reduces network calls by combining accesses to multiple Entity beans into one access to the facade object.
  • The MessageFacade/ServiceActivator Pattern moves method calls into a separate object which can execute asynchronously.
  • The ValueObject Pattern combines remote data into one serializable object, thus reducing the number of network transfers required to access multiple items of remote data.
  • The ValueObjectFactory/ValueObjectAssembler Pattern combines remote data from multiple remote objects into one serializable object, thus reducing the number of network transfers required to access multiple items of remote data.
  • The ValueListHandler Pattern: avoids using multiple Entity beans to access the database, using Data Access Objects which explicitly query the database; and returns the data to the client in batches (which can be terminated) rather than in one big chunk, according to the Page-by-Page Iterator pattern.
  • The CompositeEntity Pattern reduces the number of actual entity beans by wrapping multiple java objects (which could otherwise be Entity beans) into one Entity bean.
  • The Recycler pattern fixes only the broken parts of a failed object, to minimize the replacement cost.
  • Use a factory class instead of directly calling the “new” operator, to allow easier reuse of objects.
  • Instead of making lots of remote requests for data attributes of an object, combine the attributes into another object and send the object to the client. Then the attributes can be queried efficiently locally (this is called the Value Object pattern). Consider caching the value objects where appropriate.
  • The Proxy design pattern
    • Using a proxy, you can delay image loading until the image is required.
    • The Proxy pattern often instantiates its real object, the Decorator pattern (which can also use proxy objects) rarely does.
    • The java.lang.reflect package provides three classes to support the Proxy and Decorator patterns: Proxy, Method, and InvocationHandler.
Advertisements

6 Responses

  1. nice! thank you

  2. When I initially commented I seem to have clicked on the -Notify me
    when new comments are added- checkbox and from now on whenever a comment is added I get four
    emails with the same comment. There has to be an easy method you are able
    to remove me from that service? Kudos!

  3. There is certainly a lot to learn about this subject.
    I love all of the points you made.

  4. Hello very nice site!! Guy .. Excellent .. Amazing ..
    I’ll bookmark your blog and take the feeds also?

    I am happy to seek out so many useful information here in the post, we need work out extra techniques
    on this regard, thanks for sharing. . . . . .

  5. Uzun süredir web sitenizi takip ediyorum teşekkürler

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: