The purpose of this summary should give you an idea about the use of UML and how to implement it with C++ and Java. Sometimes there are more than one way to implement a thing, one example will be provided.
This document is not intended to be a programming or UML tutorial. It is more to show you the bridge between UML and C++, Java respectively.
Since this document deals with object oriented paradigma, procedural aproaches, like the programming language C, are not covered.
public class Foo
{
private int count;
protected int size;
public Foo() { ... }
public int getCount() { ... }
}
Not supported, besides you use a pure virtual base class (no attributes, no private or protected methods, no implementations of methods).
class Foo
{
public:
virtual void doSomething(void) = 0;
virtual int doSomethingOther(void) = 0;
};
class Bar : public Foo
{
public:
virtual void doSomething(void);
virtual int doSomethingOther(void);
};
void Bar::doSomething(void) { ... }:
int Bar::doSomethingOther(void) { ... };
public interface Foo
{
public void doSomething();
public int doSomethingOther();
}
public class Bar implements Foo
{
public void doSomething() { ... }
public int doSomethingOther() { ... }
}
Not supported in Java. The lifetime of a composite object depends completely on the garbage collector.
class Foo { ... };
class Bar
{
public:
void doSomething(void);
};
void Bar::doSomething(void)
{
Foo foo;
Foo * foo1 = new Foo;
// ...
delete foo1;
}
public class Foo { ... }
public class Bar
{
private Foo [] foo = new Foo[3];
private Vector foos = new Vector(); // contains Foo objects
}
Not supported.
public class Foo { ... }
public class Bar
{
private Vector foos = new Vector(); // contains Foo objects
}
template< class T > class Foo { ... };
template< class T > class Bar
{
private:
T data;
};
class SpecialBar : public Bar< int > { ... };
template< class T, int size > class Array
{
private:
T data[size];
};
Supported by Java 1.5 and newer.