Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In UML, do you have to show the concrete implementation of an abstract method?

I'm drawing some UML in which a concrete class inherits from an abstract class which defines a pure virtual method. Is it required to show this method in the concrete class as well? It's implied by inheriting from the abstract class.

like image 539
Jack BeNimble Avatar asked May 16 '09 01:05

Jack BeNimble


People also ask

Does a concrete class have to implement all abstract methods?

A concrete class is a subclass of an abstract class, which implements all its abstract method. Abstract methods cannot have body. Abstract class can have static fields and static method, like other classes.

How do you represent an abstract method in UML?

Abstract methods are displayed by italic text (UML has a boolean value for this). The notation you are using is called Keyword (simple way) or Stereotype (more complex).

Can abstract methods have concrete methods?

Abstract class can have both an abstract as well as concrete methods. A concrete class can only have concrete methods. Even a single abstract method makes the class abstract. Abstract class can not be instantiated using new keyword.

Can an abstract method have an implementation?

An abstract method doesn't have any implementation (method body). A class containing abstract methods should also be abstract. We cannot create objects of an abstract class. To implement features of an abstract class, we inherit subclasses from it and create objects of the subclass.


1 Answers

Nope, you don't need to. in fact, in general, don't put any more in the UML than you must have to clarify what you're saying, unless you're (god forbid) trying to generate code from it.

The best guide I know of for UML is UML Distilled by Martin Fowler.

like image 185
Charlie Martin Avatar answered Oct 19 '22 07:10

Charlie Martin