We have already touched on design a lot
Today we will cover
Today we will cover
The usual: visual representation + live explanation
Success rate: questionable
The suggestion: design the design / architecture presentation properly
A good place to start:
the C4 model
c4model.com/
Great introductory video in the handout - here quick summary
Here is the call-graph of a simple TCP client Request call
A few other useful diagram types
Functional diagrams showcase a system's functional processes and how they interact (it does not have to reflect architecture)
For our field, these are usually 1-to-1 with control and data flow diagrams
A few other useful diagram types
Describes not only what occurs but also in what order
Today we will cover
Design decisions on different levels have different consequences
Example: A solar-system dynamics simulation tool
Level 1 Context example - where do I get my data?
Level 1 Context example - where do I get my data?
Level 1 Context example - where do I get my data?
Instead include the Kernel parsing as a component
Pros vs Cons?
Level 1 Context example - where do I get my data?
Level 2 Container example - How do I view the results?
Level 2 Container example - How do I view the results?
Level 2 Container example - How do I view the results?
Level 3 Component example - How do I visualize the data?
Level 4 Code example - How do I represent the data?
class Position3D:
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
class Velocity3D:
def __init__(self, vx, vy, vz):
self.vx = vx
self.vy = vy
self.vz = vz
class State:
def __init__(self, pos: Position3D, vel: Velocity3D, identifier):
self.position = pos
self.velocity = vel
self.identifier = identifier
self.next = None
class Simulation:
def __init__(self, file):
self.head = None
current = None
for identifier, state in read_simulation(file):
s = State(
Position3D(state[0], state[1], state[2]),
Velocity3D(state[3], state[4], state[5]),
identifier,
)
if current is not None:
current.next = s
current = s
if self.head is None:
self.head = s
Versus
Level 4 Code example - How do I represent the data?
from dataclasses import dataclass, field
import numpy as np
import numpy.typing as npt
@dataclass
class States:
positions: npt.NDArray[np.float64]
velocities: npt.NDArray[np.float64]
ids: npt.NDArray[np.dtype("U8")]
objects: dict[np.dtype("U8"), int] = field(init=False)
def __post_init__(self):
self.objects = {obj: ind for ind, obj in enumerate(self.ids)}
def load_simulation(file) -> States:
states, ids = read_simulation(file)
return States(
positions=states[:3, :],
velocities=states[3:, :],
ids=ids,
)
Why? See this and previous handouts
My definition is
How the software system will function and what it shall
do
(can be multiple architectures that fulfill requirements)
C4 Level 1-3
Multiple implementations that solve the same problem
(i.e. "free variables", not obvious which is the best)
C4 Level 4
My definition is
We saw example before of these
An example: a table with schedule data used in processing
pandas DataFramenumpy vectorsEverything we need can be done in both
An example: a table with schedule data used in processing
Everything we need can be done in both
pandas used elsewhere?Boring answer: everything that matters
Boring answer: depends on the situation
My suggestion?
Try to predict the consequences and let those that
matter guide you
Some factors to consider:
Some factors to consider:
These come from a master thesis I supervised a while ago
The Efficiency of Good Software Practices: A Case Study on a Radar Meteor Analysis Software Rewrite
TL;DR Conclusions
good software practices do matter and improve the factors
and the suggested
factors are important (depending on the project)
Today we will cover
Today we will cover
See handouts