Business Object Model Design

Hello Evryone,

I'm designing a new application for Incident Management.

There is an existing Incident System But, our application is targeted to end user facility.

So, we have to use the existing Incident Management system to store and get data, so that Incident can be loaded on booth side.

We access that datastore using WebServices with DAO Pattern.

In the existing system, they have Incident Attribute like Status, Alert, Priority,... with Integer as main identifier.

publicclass IncidentStatus{

privateint status;

private String statusStr;

public IncidentStatus (){

}

}

In my application, i would like to have a good OO Model.

So, my idea is to use the Design Pattern "State" and/or "Strategy" for such a attribute.

So that i would have class/interface such as

- IncidentStatus (interface)

- IncidentOpened (impl)

- IncidentResolved (impl)

and so on ...

This involve a class for each case but, isn't it more OO oriented ?

any comment ?

Regards,

Sebastien Degardin

[1420 byte] By [sdegardina] at [2007-11-26 20:45:41]
# 1
Does IncidentStatus have any state, or is it just an identifier? I'dseriously consider using enumerated types...
es5f2000a at 2007-7-10 2:07:12 > top of Java-index,Other Topics,Patterns & OO Design...
# 2
Incident status is the interface implemented by Objects which represents the status of the Incident.the advantage I see with this design is the ability to dynamicaly add new kind of Status.
sdegardina at 2007-7-10 2:07:12 > top of Java-index,Other Topics,Patterns & OO Design...
# 3

but do these IncidentStatus objects do anything other than represent the status? if not, I'd be inclined to agree with the other poster about enumerated types. if adding new ones dynamically is your bag, you could opt for having a single IncidentStatus class, and have instances which represent different statuses, described by (for instance) a String

another question to ask yourself is "how likely is it that I'll need to add a new IncidentStatus?". probably not very often. in any case, if the purpose of the IncidentStatus is merely to indicate status, I'd be looking to have just one class to represent them, and a config file which describes the individual statuses. adding a new one wouldn't even need to involve a programmer

georgemca at 2007-7-10 2:07:12 > top of Java-index,Other Topics,Patterns & OO Design...
# 4

Hi georgemc,

I'm not planning to use those Objects as "Strategy", it means, nothing else than representing the status.

So, i think the solutino to only use one class alogn with a configuration file would be suitable and preferable in my case.

new status are not going to be added often.

It's just because i'm trying to create a "scalable" model and i need to find the right balance ... :D

Regards,

Sebastien Degardin

sdegardina at 2007-7-10 2:07:12 > top of Java-index,Other Topics,Patterns & OO Design...
# 5
if they're just representing status, all those classes are overkill, yeh. I'd use my solution although the enumerated type way suggested above is just as validbear [url= http://en.wikipedia.org/wiki/You_Ain't_Gonna_Need_It]this[/url] principle in mind :-)
georgemca at 2007-7-10 2:07:12 > top of Java-index,Other Topics,Patterns & OO Design...
# 6
Thanks everybody !!I now have to choose between the two solutions.Maybe, the enumerated values are best if i follow, the "KISS" and "YAGNI" principles :DRegards,Sebastien Degardin
sdegardina at 2007-7-10 2:07:13 > top of Java-index,Other Topics,Patterns & OO Design...
# 7
Here is the way i'm going to work. http://www.javapractices.com/Topic1.cjp#LegacyThanks againRegards,Sebastien DegardinMessage was edited by: sdegardin
sdegardina at 2007-7-10 2:07:13 > top of Java-index,Other Topics,Patterns & OO Design...
# 8

> Here is the way i'm going to work.

>

> http://www.javapractices.com/Topic1.cjp#Legacy

>

> Thanks again

>

> Regards,

> Sebastien Degardin

>

> Message was edited by:

> sdegardin

you're not on java 1.5+ yet, then?

georgemca at 2007-7-10 2:07:13 > top of Java-index,Other Topics,Patterns & OO Design...
# 9
me yes.My customer no !You know how it is in large banking industry.Regards,Sebastien Degardin
sdegardina at 2007-7-10 2:07:13 > top of Java-index,Other Topics,Patterns & OO Design...
# 10

> me yes.

>

> My customer no !

>

> You know how it is in large banking industry.

>

> Regards,

> Sebastien Degardin

indeed! a word of warning, then. if you decide to roll an entire enum implementation yourself, don't use the words enum or Enum for anything. enum is now a reserved word, and Enum is a class in the JDK. we've fallen foul of one of our vendors doing that on numerous occasions!

georgemca at 2007-7-10 2:07:13 > top of Java-index,Other Topics,Patterns & OO Design...
# 11
Yes, Thanks for the info.I got this information from a Session at javaone.Actually i'm using name such as "IncidentStatus", "IncidentType".Regards,Sebastien Degardin
sdegardina at 2007-7-10 2:07:13 > top of Java-index,Other Topics,Patterns & OO Design...
# 12
I was more concerned about if you'd decided to roll a re-usable enum implementation, as people often do. names specific to your problem won't be any trouble ;-)
georgemca at 2007-7-10 2:07:13 > top of Java-index,Other Topics,Patterns & OO Design...
# 13
Ok, I got it !Didn't think about a re-usable implementation.As you can see, my spceific implementation is quite simple.Now, I'm working on Serialization for such "Type".Regards,sebastien Degardin
sdegardina at 2007-7-10 2:07:13 > top of Java-index,Other Topics,Patterns & OO Design...