Advertisement

06.19.2008 at 01:41PM PDT, ID: 23500467
[x]
Attachment Details

Achitectural question - what is the best object model for this?

Asked by Perplexity in Enterprise Java Beans (EJB), Software/Systems Design, J2EE

Tags: Java

I am deliberating about design issues on a project right now, and I'd be interested in hearing how someone else might tackle this.  Just as background, I am using EJB3, Hibernate, and JSF at the moment.  I am going to offer a somewhat abstract example that is actually pretty close to what I am trying to do.

I need to accommodate some object that represent different shapes.  They are defined as a series of points on a grid.  For example, there could be a square, a circle, or a polygon with an arbitrary number of sides.

In my mind, each shape could be pretty easily defined as a list of pairs of coordinates.  (Although the circle would need a single point and a radius, or something similar.)  Aside from that on exception, it's just an ordinal list of coordinate pairs.

Going forward - I am going to need to have a mechanism for each shape to be checked against a given point, to see if that point falls within any of the shapes on the grid.

My initial thoughts had been to have an abstract shape class to define the basic operations (get id, set id, getCollectionOfPoints, setCollectionOfPoints, etc.) and have each shape extend that class and provide it's own method to see if a set of provided coordinates fall within it's bounds.  A simple true or false response will be a sufficient answer, and the equation to check each shape type will never change.  The check method on the entity would then just be called from a session bean.

There is a part of me that doesn't like this idea though, because it feels like I am putting some degree of logic into an entity.  Is there a good way to accommodate these different types and still keep the actual work in a session bean?  (Please assume that entirely new shapes could be added to the system in the future, so rather than just adding a new entity with it's own method to check, the session bean would probably also need to be modified, which would be nice to avoid if possible.)

Does anyone have any thoughts or a better solution?Start Free Trial
 
Loading Advertisement...
 
[+][-]06.19.2008 at 09:07PM PDT, ID: 21828371

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.19.2008 at 10:55PM PDT, ID: 21828716

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.20.2008 at 02:30AM PDT, ID: 21829490

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Enterprise Java Beans (EJB), Software/Systems Design, J2EE
Tags: Java
Sign Up Now!
Solution Provided By: Nellios
Participating Experts: 3
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628