Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to visualize Protocols and Extensions in UML?

It seems reasonable to use UML Interfaces to visualize Swift Protocols in UML. But how should I visualize an extension that provides a default implementation for a specific protocol? Should I just use a class like <<extension>>ProtocolName that inherits from that protocol?

like image 514
bamboofighter Avatar asked May 29 '16 12:05

bamboofighter


People also ask

What are protocol extensions?

Protocols let you describe what methods something should have, but don't provide the code inside. Extensions let you provide the code inside your methods, but only affect one data type – you can't add the method to lots of types at the same time.

Can we use extension for protocol types?

An extension can extend an existing type to make it adopt one or more protocols. To add protocol conformance, you write the protocol names the same way as you write them for a class or structure: extension SomeType: SomeProtocol, AnotherProtocol {

What is agent in UML diagram?

Agent UML is a graphical modeling language based on UML. Like UML, Agent UML provides several types of representation cover- ing the description of the system, the components, the dynamics of the system and the deployment. Multiagent system designers already use Agent UML to represent interaction protocols [13,2].


1 Answers

An extension exists in the scope of a certain class and just adds some functionality to it. So I would represent the extension as subclass (eventually packaging might be preferred). To show that it's an extension I would use a stereotype. The dependency on the class which is extended is somewhat optional since in the context it is a naming convention.

enter image description here

If the extension will additionally adhere to some protocol you just add realization relations to the according interface classes.

This is one way to express this. Since there is no native UML construct for an extension you are relatively free to invent you own idiom here.

like image 103
qwerty_so Avatar answered Sep 22 '22 14:09

qwerty_so