Solved

Connecting concreate class to abstract class

Posted on 2010-11-10
5
539 Views
Last Modified: 2012-05-10
Hello

In below diagram where is the correct place for Parameter class. Should I connect it to an abstract class?

 uml diagram
Kind regards.
0
Comment
Question by:vileda
  • 2
  • 2
5 Comments
 
LVL 16

Expert Comment

by:kris_per
ID: 34101030
I guess you want to use the Parameter class in getParameter method. Then it is related to AbstractContainer.

If AbstractContainer class has a list of Parameter objects, then it is aggregation.

If Parameter class is used only in getParameter method, then I think it is not necessary to show Parameter class in the diagram; if you want, you can relate it to AbstractContainer with a dotted line, just for a note as the design is already clear with other classes.

0
 

Author Comment

by:vileda
ID: 34101920

Should I create a AbstractParameter class that connected to AbstractContainer class.

I don't want to connect it to AbstractContainer class. Because the package which includes my Abstract Container class is highly stable. When I add a concrete class to this package it becomes more instable so that the other packages depends on this package will become relatively more stable.

This means breaking the Stable Abstraction Principle:
http://c2.com/cgi/wiki?StableAbstractionsPrinciple

What should I do now?
0
 
LVL 4

Accepted Solution

by:
greyfairer earned 250 total points
ID: 34102579
The AbstractContainer.getParameter(...) returns an int, so the Parameter object is not coupled directly to  the Abstraction.

The Parameter object is  probably only used inside methods in ConcreteContainer, so I would only link it there. Creating an AbstractParameter is also totally useless. The Concrete container and the Parameter Object should be in a concrete package.
0
 
LVL 16

Assisted Solution

by:kris_per
kris_per earned 250 total points
ID: 34103034
My understanding of what is meant by 'stable' in your comment and in the link is 'frequency of change'. I think what it means is that less changing, contract-finalized (stable) packages should be 'abstract'.

It looks like the getParameter method in AbstractContainer doesn't use Parameter class currently. I think you are trying to change it to use Parameter class. i.e. You are trying to make the 'abstract' to be 'unstable'. If you dont want this to happen, then leave the getParamter method as it is now and hence you dont need to link to the AbstractContainer.  Then Parameter class is more an internal detail (could be used inside ConcreteContainer). Then you dont need to specify the Parameter class in the diagram at all.  

You wouldn't need AbstractParameter class either. I think you should view this as a helper class rather than like a main class in the design.
0
 
LVL 4

Expert Comment

by:greyfairer
ID: 34126840
FYI: Definition of 'stability' in OOP: http://en.wikipedia.org/wiki/Software_package_metrics

0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction This article discusses the Chain of Responsibility pattern, explaining What it is;Why it is; andHow it is At the end of this article, I hope you will be able to describe the use and benefits of Chain of Responsibility.  Backgrou…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now