Designa en webbplats som denna med
Kom igång

Classes to code

In my previous posts i have talked a lot about object oriented design with UML diagrams. Once you have a design solution for your application ready to be implemented into code, you then have to consider which programming language is most appropriate. There are many different languages to choose from which offer different functional advantages and disadvantages.

Bildresultat för code
by Marco Troisi

Most programming languages can be classified and differentiated by a couple of different paradigms. Two popular examples are functional programming ​​and object-oriented programming.

Functional Programming(FP) is a declarative type of programming style that involves creating a series of smaller mathematical functions, each one completing their own specific computation. These functions can then be combined in different ways to complete larger and more complex tasks. This style of coding is used in for example in JavaScript and Python.

It has the following Core Concepts:

  • Higher Order Functions –
  • Pure Functions
  • Recursion
  • Strict & Non-Strict Evaluation
  • Type Systems
  • Referential Transparency

Read more about these concepts here

In Object-Oriented Programming(OOP) you create classes that can be instantiated into objects. Each Class defines the attributes and methods that can be called on the object. They can also be used for static methods as well. In order to initialize an object the data defined by the class has to be provided.

Core Concepts

  • Abstraction
  • Inheritance
  • Polymorphism
  • Encapsulation

Read more about these concepts here

If you are using class diagrams which I’ve talked about a lot in my previous post then the most suitable language would be an object oriented language as the purpose of the design is modelling objects, not functions. With languages such as Java and C++ you can easily convert the classes of the diagram into code. The attributes at the top of each entity is usually the main variables that each class will store, and underneath you can see the names of the methods with parentheses at the end. By reading the names you have an idea of what kind of function or method should be implemented. Then you also have arrows which indicate for example: aggregations inheritance, dependencies and associations.

Bildresultat för arrows in class diagrams
Arrows in Class diagram by Wikipedia

With most object oriented languages the implementation would be similar. The languages might compile the code in different ways and use different syntax but luckily most languages today are well documented.

Can ULM diagrams be used with a”non object-oriented” language?

I think you can implement some UML designs for some non OO languages. State (Transition), Use Case and Sequence diagrams could probably be used as these diagrams aren’t really defining structures, they’re are defining behavior and functional requirements for a system, like what it does or should do.


Lämna en kommentar

Fyll i dina uppgifter nedan eller klicka på en ikon för att logga in:

Du kommenterar med ditt Logga ut /  Ändra )


Du kommenterar med ditt Twitter-konto. Logga ut /  Ändra )


Du kommenterar med ditt Facebook-konto. Logga ut /  Ändra )

Ansluter till %s

%d bloggare gillar detta: