OOP - problem with undestand the real and the implementation

Imagine this bellow model. (data model)

[custumer]--1--*--[order] --1*--[itemlist]--*1--[Item]

Based in this model (not so good with "bad smell" <Martin Fowler>) of data.

I would like to know how the classes diagram will be (with any operations, just to me understand the concerns of mapping).

And a psedo code also can help (just the struct of theses classes)

First I imagine that a data model is diferent of classes diagram.

Second I belive that classes diagram show the relantionship but not implents this.

sample:

classes diagram

[itemlist ]--1-*--[Item]

| -atribu || -a1 |

|_||_|

implementation. (pseudo)

public class ItemList{

int atribu;

List itens;

}

public class Item

{

int a1;

}

Is correct:

show on classes diagrama atributes like. List item; ?

how much classes and which classes the data model (on top) will generate ?

(the dubt is listItem is an object ,, or manyTomany change to object?)

[1058 byte] By [dreampeppers99a] at [2007-11-27 3:52:02]
# 1
I find that one thing that's missing from ERDs, that needs tobe factoring into the class diagramming is navigation. Does the customer hold references to its orders?Does the order refer to its customer?etc...
DrLaszloJamfa at 2007-7-12 8:56:03 > top of Java-index,Java Essentials,New To Java...
# 2
In your first diagram for itemlist -> item, you have many to 1, and in the second you have 1 to many. Is that right?
hunter9000a at 2007-7-12 8:56:03 > top of Java-index,Java Essentials,New To Java...
# 3

> I find that one thing that's missing from ERDs, that

> needs to

> be factoring into the class diagramming is

> navigation.

>

> Does the customer hold references to its orders?

> Does the order refer to its customer?

> etc...

The customer hold references to orders.

Thanks

dreampeppers99a at 2007-7-12 8:56:03 > top of Java-index,Java Essentials,New To Java...
# 4
> The customer hold references to orders.I'm not looking for the answers so much as pointing out that youneed to ask yourself a pair of questions like that for every relationshipin the original diagram.
DrLaszloJamfa at 2007-7-12 8:56:03 > top of Java-index,Java Essentials,New To Java...
# 5
> In your first diagram for itemlist -> item, you have> many to 1, and in the second you have 1 to many. Is> that right?Yes [order] 1* [listItens]*-1[item]One order has OneOrMany listItems andA listitems has ManyOrOne
dreampeppers99a at 2007-7-12 8:56:03 > top of Java-index,Java Essentials,New To Java...
# 6

> > The customer hold references to orders.

>

> I'm not looking for the answers so much as pointing

> out that you

> need to ask yourself a pair of questions like that

> for every relationship

> in the original diagram.

ok let me try again.

Model data

custumer

#id

name

born

order

#id

##idcostumer

totalitens

totalprice

listitem

##idorder

##iditem

#id

qtditens

price

item

#id

description

price

qty

And how can I make a diagram classes e implements this classes ... it sounds like mapping.

thanks

dreampeppers99a at 2007-7-12 8:56:03 > top of Java-index,Java Essentials,New To Java...
# 7

on oo model one relationship ManyToMany will be a class?

Or just a atribute inside one side of Many relationship?

Like this?

oneA

-int a2

-int a1

-List b

-List a

oneB

-int a1

-int a2

or this?

oneA

-int a2

-int a1

oneB

-int a1

-int a2

manyC// manytomany relationship

-oneA a

-oneB b

dreampeppers99a at 2007-7-12 8:56:03 > top of Java-index,Java Essentials,New To Java...
# 8

I didn't understand that last post, but if you have a many-to-many relationship between X and Y, say, and you want to navigate both ways, you can maintain a Set of Y references in class X and maintain a set of X references in class Y.

You should first decide if you will break the many-to-many into a pair of one-to-many relations.

DrLaszloJamfa at 2007-7-12 8:56:03 > top of Java-index,Java Essentials,New To Java...
# 9
consider #primary key##foreign keythanks
dreampeppers99a at 2007-7-12 8:56:03 > top of Java-index,Java Essentials,New To Java...
# 10

> I didn't understand that last post,

I know was very unformated text.

> but if you have a

> many-to-many relationship between X and Y, say, and

> you want to navigate both ways, you can maintain a

> Set of Y references in class X and maintain a set of

> X references in class Y.

>

And my model oo will have just two classes X and Y (one reference a list of another [two way to navigate])?

> You should first decide if you will break the

> many-to-many into a pair of one-to-many relations.

If yes and if not, what it implicates ?

Create a more two classes (aditional) ?

thanks

and sorry for my 'ugly' english

dreampeppers99a at 2007-7-12 8:56:03 > top of Java-index,Java Essentials,New To Java...
# 11

> And my model oo will have just two classes X and Y (one reference a list of another [two way to navigate])?

Yes

> If yes and if not, what it implicates ?

> Create a more two classes (aditional) ?

Consider your initial data model. ListItem was added to decompose the

many-to-many relationship between Order and Item.

You should look for an article or even a book about this. I don't think a

forum thread can cover the whole topic.

For example: http://www.agiledata.org/essays/mappingObjects.html

Google is a useful tool!

DrLaszloJamfa at 2007-7-12 8:56:03 > top of Java-index,Java Essentials,New To Java...
# 12

> > And my model oo will have just two classes X and Y

> (one reference a list of another [two way to

> navigate])?

>

> Yes

>

> > If yes and if not, what it implicates ?

> > Create a more two classes (aditional) ?

>

> Consider your initial data model. ListItem was added

> to decompose the

> many-to-many relationship between Order and Item.

>

> You should look for an article or even a book about

> this. I don't think a

> forum thread can cover the whole topic.

>

> For example:

> http://www.agiledata.org/essays/mappingObjects.html

> Google is a useful tool!

You allright

Thanks you so much

dreampeppers99a at 2007-7-12 8:56:03 > top of Java-index,Java Essentials,New To Java...