Solved

Connecting concreate class to abstract class

Posted on 2010-11-10
5
554 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Many of the most common information processing tasks require sorting data sets.  For example, you may want to find the largest or smallest value in a collection.  Or you may want to order the data set in numeric or alphabetical order. …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

810 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