Software Construction: Object States

Cards to learn object states

Cards to learn object states


P. M.
Diese Lernkarten behandeln fortgeschrittene Konzepte der Softwarekonstruktion, insbesondere den Zustand von Objekten, und richten sich an Studierende. Sie definieren zentrale Begriffe wie Objektzustand, Zustandsspeicher und Zustanddiagramme und erklären deren Bedeutung für die Softwareentwicklung. Die Karteikarten zeigen, wie man den Zustand von Objekten minimiert und partitioniert, um die Komplexität zu reduzieren. Sie bieten praktische Beispiele und Designprinzipien, die Entwicklern helfen, robuste und effiziente Software zu erstellen.
Karten
13
Lernende
0
Sprache
Deutsch
Kategorie
Informatik
Stufe
Universität
Erstellt / Aktualisiert
01.01.2020 / 10.01.2020

Lernkarten

Static perspective on a Software System

Dynamic perspective on a Software System

Object State (Definition)

The state of an object refers to:

  • the pieces of information the object represents at a given moment
  • the actions that the object can perform at a given moment

Object State Definitions (3)

State Space: Set of all possible states for an object.

Concrete State: Value(s) stored at a given moment.

Abstract State: Arbitrarily-defined subset of the state space.

State Space Partitioning (Definition)

The software design task of state space partitioning is to define abstract states that correspond to characteristics that will help construct a clean solution.

State Diagrams (Definition)

State diagrams allow us to self-evaluate the impact of design decisions on the complexity of the abstract state space that must be considered when working with an object.

Here the abstract state space would consist of State A & B.

Example state diagram for an instance of deck (with separate initialization and shuffling)

Design Principle for State Space

Minimize the state space of objects to what is absolutely necessary for the object to fulfill its responsibilities.

Unnecessary Stateful Information

Temporary FIeld is anti-pattern (don't do this!)

?? In this example the temporary value aSize is unnecessary, as the same information is in aCards.size ??

Nullability (Definition)

The state or property of being nullable.

I.e. if we don't want a reference to be null, we need to ensure this!

Final Fields & Variables (Definition)

Java final variable: If you make any variable as final, you cannot change the value of final variable (It will be constant). A blank (null) final variable can only be initialized in the constructor!

Java final method: If you make any method as final, you cannot override it. A constructor can never be declared final (because it's never inherited)!

Java final class (object): If you make any class as final, you cannot extend itFinal fields do not make the referenced objects immutable! (i.e. only the reference pointer is immutable, but not the object itself)

Object Identity, Equality, & Uniqueness

The direct object reference is equal to it's pointer, not the object itself! If we want to compare 2 object by class / type we need to use ObjName.getClass()!

Example of object comparison code

Lernen