• Post Reply Bookmark Topic Watch Topic
  • New Topic

Design Provision  RSS feed

 
Peter Norton
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically, I need to develop engine that will processed a lot of jobs. I am thinking to develop JMS queue implementation where first I divide job in to multiple task and put different kind of tasks of job in queue. The consumer will pick the message and processed that task accordingly. Using this approach, my design can be vertical and horizontal scalable.

Now the problem is that due to time constraint, I could not implement JMS implementation in current release. However, I need to make sure that design provision must present in the code so that later the JMS implementation can be done easily.

Please guide how/what type of dummy implementation I can implement right now to ensure design provision?
 
Rob Spoor
Sheriff
Posts: 21133
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the factory pattern. In short:
- You create abstract classes / interfaces for your objects. You'll use references of these types.
- You create an abstract factory class that will be responsible for creating instances of implementing classes of the above classes / interfaces.
- You create a concrete factory class for the current implementation.
- You create a concrete factory class for the new implementation when you have time for it.
- When the latter concrete class is ready, switch factories.

If the abstract factory class gets a static getDefaultInstance() method or something similar, and that's the one you use to get references to your factory, then all you need to do to start using the new factory and therefore the new classes is change that one single method. Alternatively, the concrete factory class can be a system property, defaulting to one of the two.

This approach is also used in a few places in the Java API. Check out DocumentBuilder and DocumentBuilderFactory; DocumentBuilderFactory is an abstract factory class for creating DocumentBuilder instances (with static newInstance methods), and DocumentBuilder in turn is an abstract factory class for creating Document instances (which in turn is again an abstract factory interface for creating Elements, Nodes, etc).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!