Re: Is this correct?!!!



Hi

Thanks for the answer. But, how will you define my example in UML?

Thanks again.

Regards
Mojtaba


H. S. Lahman wrote:

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

.



Relevant Pages

  • Re: Insert with response
    ... FooBar, there's no way and no need to put them in synch. ... column in the foo table to 250 calumns in the bar table. ... set statistics time off ...
    (microsoft.public.sqlserver.programming)
  • Re: Magic function
    ... processing objects created in root at depth 3 ... root obj2 at depth 3 ... processing objects created in foo at depth 2 ... processing objects created in bar at depth 0 ...
    (comp.lang.python)
  • Re: pkgdb -F questions
    ... Which is the dependent, foo or bar? ... upgrade bar as well ... and now the old dependency listed in foo no longer ...
    (comp.unix.bsd.freebsd.misc)
  • Re: from __future__ import absolute_import ?
    ... foo not in bar ... Unfortunately this is a side effect of using the os's directory structure to represent a python "package" structure. ...
    (comp.lang.python)
  • Re: from __future__ import absolute_import ?
    ... foo not in bar ... A path below the package level is generally a good means to shoot ... to represent a python "package" structure. ...
    (comp.lang.python)