This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
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]http://www.freeimagehosting.net/uploads/cf4cb464ac.jpg" border="0" />[/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]http://www.freeimagehosting.net/uploads/0d7c3aadf9.jpg" border="0" />[/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?
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
posted
0
What is the purpose of the model you are doing?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Nachiket Patel
Ranch Hand
Joined: Sep 16, 2007
Posts: 110
posted
0
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
Before software can be reusable, it first has to be usable. - Ralph Johnson
Elham Ghaf
Greenhorn
Joined: Dec 14, 2008
Posts: 6
posted
0
Dear Nachiket, 1 and 2 are not my solutions! they are problems of my solution [ December 22, 2008: Message edited by: Elham Ghaf ]
Alan Mehio
Ranch Hand
Joined: Apr 04, 2005
Posts: 70
posted
0
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.
Regards,
Alan Mehio
London, UK
Akhilesh Trivedi
Ranch Hand
Joined: Jun 22, 2005
Posts: 1493
posted
0
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.
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
Joined: Jun 22, 2005
Posts: 1493
posted
0
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
Sheriff
Joined: Jul 11, 2001
Posts: 14112
posted
0
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.