• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

My Class Diagram Problem

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suppose I have a class named A. This class has a attribute which is a class itself, but it maybe various classes, sometimes B1,sometimes B2 and �.
So,I thought the best model might be like this:
[/img]
It�s good, because if another class like B3 needed to be added, It�s simple just inherit it from C class.
But the subject is B1, B2 and B3 are not type of C naturally .So what is problem?
Suppose we have similar situation for Z class. it has a attribute which is a class, and might be various class, sometimes B1,Sometimes D1,�..Like this:
[/img]
It means B1 is inherited from C and E.
Here we have 2 problems:
1-I had to model multi inheritance, that not supporting in my implementing environment and I have to use trick and pattern to do it, and it made more complex.
2-when I want to convert my class diagram to Data model:
I will have a C table with CID for Primary key. And I have B1 and B2 tables too. Related class of them inherited from C class, and then CID is primary key for B1 and B2 tables too.
This story goes for E table and, B1 and D1 Tables too. But in this case B1 table have 2 primaries key CID and EID.

What should I do?
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the purpose of the model you are doing?
 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Elham,

2-when I want to convert my class diagram to Data model:
I will have a C table with CID for Primary key. And I have B1 and B2 tables too. Related class of them inherited from C class, and then CID is primary key for B1 and B2 tables too.
This story goes for E table and, B1 and D1 Tables too. But in this case B1 table have 2 primaries key CID and EID.



I think, your solution 2 will be more complex then your suggested solution 1.

And For your solution 1, which pattern you are talking about??? I don't know any pattern which is intended for multiple inheritance problem..

And i think, there is more simple and more robust solution to this, interface.

Use interface.

Cheers,
Nachiket
 
Elham Ghaf
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Nachiket,
1 and 2 are not my solutions! they are problems of my solution
[ December 22, 2008: Message edited by: Elham Ghaf ]
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Again what is the purpose of this model? why do you want to use inheritance ? what about interfaces so you can decouple the classes.
 
Ranch Hand
Posts: 1609
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Would be great if you can brief out why A is a class, why B1 and B2 are part of it at times? Why Z is Z and not X or Y? why there is inheritance expected between E and B1, between E and D1?

Originally posted by Elham Gh:
... 1 and 2 are not my solutions! they are problems of my solution

[ December 22, 2008: Message edited by: Elham Ghaf ]



Class Diagrams are designed to model a problem after analysis, and then derive solutions. I personally feel you are modeling a solution (with no base)and deriving problems from it.
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Akhilesh Trivedi:

Class Diagrams are designed to model a problem after analysis, and then derive solutions.



Actually, all they are designed to do is modeling classes and their relationships. There is a myriad of different ways to put them to good use.
 
Akhilesh Trivedi
Ranch Hand
Posts: 1609
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for correcting me. Did I overlook "class" diagrams as "uml" diagrams?

Originally posted by Ilja Preuss:


...There is a myriad of different ways to put them to good use.



You mean code generators?
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Akhilesh Trivedi:

You mean code generators?



That's just one froma thousands of ways.

Remember that the L in UML stands for "language". And it is nothing more than that - a tool for communication. You can use it to communicate many different things, for many different purposes, to many different people.

Just take a look at http://martinfowler.com/bliki/UmlMode.html for a start.
 
Akhilesh Trivedi
Ranch Hand
Posts: 1609
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks again, there is much more behind the sketches.
 
reply
    Bookmark Topic Watch Topic
  • New Topic