Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any point in drawing an UML class diagram in functional programming?

I have been asked on a school project to show the UML diagrams I used - if I did - to realise the project. But the project I was working on was in C and has been functionally programmed. Thus I want to justify that using a class diagram when not using object oriented langage was pointless, but I am afraid that this is not true and haven't been able to confirm this hypothesis. It seems pointless to me but I'd like to know if it is the case, since may be thinking the code in a OOP way could help understanding how it works.

Is there any benefits regarding the way to think and build a functionnal program in using a class diagram ?

like image 263
Badda Avatar asked Jun 19 '17 09:06

Badda


People also ask

Can you use UML for functional programming?

UML isn't only class diagrams. Most of the other diagram types (Use case diagrams, activity diagrams, sequence diagrams...) are perfectly applicable for a purely functional programming style.

Is UML class diagram useful?

Class diagrams are one of the most useful types of diagrams in UML as they clearly map out the structure of a particular system by modeling its classes, attributes, operations, and relationships between objects.

What type of UML diagram is best for showing a functional overview?

Use Case Diagram As the most known diagram type of the behavioral UML types, Use case diagrams give a graphic overview of the actors involved in a system, different functions needed by those actors and how these different functions interact.

Why do we draw UML diagrams?

It helps software developers visualize, construct, and document new software systems and blueprints. UML is used to create static structure diagrams based on a variety of engineering practices that have proven to be successful in the creation of complex systems.


1 Answers

Of course, yes. The use of class diagram is not so extensive as in classical OOP, where very often having a class diagram means only automatic coding routine is left, but still it is very useful for:

  1. Planning of data structures (We still should understand data and their interconnections)
  2. Creating the hierarchy of methods. (Grouping of methods up to their data and tasks)
  3. Tying together methods and some special data. (What method works with what classes of data)
  4. If the language supports OOP, you can use a class diagram translating it into code.

And even if you haven't any OOP features supported, you can always profit from at least the first point.

Really, the only possible use of the class diagram, that is forbidden by functional programming, is creation of methods with side effects on instances. And that is not much connected to the class diagrams. On the contrary, class diagrams are not mentioned for modelling of that. Rather the Composite Structure Diagrams are.

like image 98
Gangnus Avatar answered Sep 20 '22 04:09

Gangnus