UPPMAX / programming_formalisms

Repository for the Programming Formalisms course
https://uppmax.github.io/programming_formalisms/
0 stars 9 forks source link

Improve class design theory #38

Open richelbilderbeek opened 2 months ago

richelbilderbeek commented 2 months ago
classDiagram
    Move *-- set_speed
    Move *-- set_direction
    Move *-- change_position

This suggests that a Move object is composed of a set_speed, set_direction and change_position object

classDiagram
  class Person{
    + name
    + personnummer
  }

or

classDiagram
  note "Not all strings are names"
  class Name{
    + name
    + set_name(str)
    + get_number()
  }

or

classDiagram
  note "Not all strings are names\nNot all numbers are personnummers"

  class Person{
    + name
    + personnummer
  }
  class Name{
    + name
    + set_name(str)
    + get_number()
  }
  class Personnummer{
    + number
    + set_number(int)
    + get_number()
  }
  Person *-- Name
  Person *-- Personnummer
LarsEklund commented 2 months ago

Valid point the chosen example was written as a response to learners creation of behavior, and is using the class diagram instead of the object diagram that was under consideration a better diagram here is to use the flowchart TD diagram as not to confuse it with a class or true object. but rather to show that a behavior could be nested by and broken down into simpler behaviors which compose the more complex behavior as to preserve one function one result and showing how one can partition the behavior into smaller part. Needs to be moved and clarified in the text. As this was the topic being discussed at that time.

richelbilderbeek commented 1 month ago

Great! I took the liberty to assign you this Issue :-)