Re: Is this correct?!!!
- From: "H. S. Lahman" <h.lahman@xxxxxxxxxxx>
- Date: Sat, 24 Jun 2006 22:15:13 GMT
Responding to Mojtaba_danai...
Is the following correct?
Dependency
UML
Bart------>Fooo
Implementation in C++
class Foo { ... };
class Bar
{
public:
void doSomething(void);
};
void Bar::doSomething(void)
{
Foo foo;
Foo * foo1 = new Foo;
// ...
delete foo1;
}
Does the above implementation correspond to UML (dependecy). If not,
what is correct UML for the code?
No. A dependency would exist if a change to Foo affected Bar. An example would be
void Bar::doSomething (Foo* foo)
{
int x;
x = foo->doIt();
this.attr1 = 5 * x;
}
Now if you change the definition of what Foo::doIt does, you change the returned value of x. That, in turn affects the results of invoking Bar::doSomething (i.e., the value stored in Bar::attr1 is different).
A somewhat looser view of dependency applies to physical coupling. That is, if the definition of Foo changes -- represented by a change to Foo's header file, then Bar needs to be at least recompiled even if Bar does not directly access the affected portion of Foo's definition. That's because in languages like C++ the mapping of address offsets can be affected in curious ways behind the scenes. So dependency in this view comes down to what Bar needs to know about Foo. IOW, Bar is dependent on Foo if Foo's header file is in Bar's includes.
However, this loose view really isn't very practical. One is probably better off using a "hard" view like my example where the dependence is behavioral (i.e., on the specification of Foo's behavior). But then it is usually pretty easy to eliminate such dependencies by redefining collaborations, in which case one doesn't need to define them.
FWIW, I don't think one should worry about dependencies in UML. They are really mostly a concern for OOPL code maintainability, which is more properly an issue for OOP.
*************
There is nothing wrong with me that could
not be cured by a capful of Drano.
H. S. Lahman
hsl@xxxxxxxxxxxxxxxxx
Pathfinder Solutions -- Put MDA to Work
http://www.pathfindermda.com
blog: http://pathfinderpeople.blogs.com/hslahman
Pathfinder is hiring: http://www.pathfindermda.com/about_us/careers_pos3.php.
(888)OOA-PATH
.
- Follow-Ups:
- Re: Is this correct?!!!
- From: mojtaba_danai@xxxxxxxxx
- Re: Is this correct?!!!
- References:
- Is this correct?!!!
- From: mojtaba_danai@xxxxxxxxx
- Is this correct?!!!
- Prev by Date: Re: OO versus RDB
- Next by Date: Re: Let's put this to rest
- Previous by thread: Is this correct?!!!
- Next by thread: Re: Is this correct?!!!
- Index(es):
Relevant Pages
|