Class diagram
Class and Object similarities
Keep in mind that a Class is the blueprint to materialize the idea of something.
Look at
Dogand poorBobbyWe have a basic concept of what makes a dog
Dogin any sence, Bobby is created (constructed) using theDogblueprint, and now because it has what a dog should have, we can useBobbythe way we could use any otherDog.

Notation
Class is used to encapsulate state(attributes) and behavior (operaations).
Each operation has a signature, but the class name is the only mandatory info.

Components
Name
- Name of the class which is the first partition's content
Attributes
- The second Partition's content
- Type is shown after the colon
- These ones will be the class variables and property-s in implementation
Operations (Methods)
- The third partition's content
- These are the services the class provides
- When it has signature:
- The return type is shown after the colon in the end
- All parameter is listed, with their type colon separated
- Operations will be the class methods in implementation

Visibility
+Public- Available from anywhere with the right import
-Private- Can only be accessed in the class, not even the derivatives can write it
~Package-Private- Inside the package, it is public, but to anyone else, it is considered private
#Protected- Private from the outside, but the derived classes can access it

Parameter Directionality
in- The caller provides this value, but in the method, only a copy is available (not changing the real source)
out- The caller gives reference in order to ensure it will be modified (not by returning)
inout- The caller gives reference, but modification is only a possibility

Perspectives of the class diagram
Class diagram can appear in many scopes, whether it's:
- Conceptual
- Represends the concept in a domain
- Specification
- Focus on the interfaces and abstract data types
- Implementation
- Describes how it will be implemented

Note that Specification scope is not what we learned from GT, that's way too complicated for general use lmao
RelationShips between classes
Note that most part is language specific since some inheritance features are unavailable
e.g. Rust can not use inheritance or most functional languages have only Aggregation and Composition, since they have no classes

The example pictures uses
as the origin and
as the target of a relationship (just call 'em
xandy)
Inheritance
- Represents an "
xis ay" relationship - An abstract class name can be shown in italic
- The sublcasses are specifications (less general) representation for their superclass

Simple Association

Plenty of relation is an assotiation, so in association, I mean the simple assiciation
- A structural link between two peer classes
- There is an association between
xandy
This is the most basic, and it can be named after the reap world scenario it represents
Fun fact,
xis called <\> class, andyis a <\> class
Cardinality
For ones familiar with Relational Databases and corresponding query languages, these kind of connections are the same with the twist it is among classes, not some kind of abstract storage somewhere else
- One to one
- One to many
- Many to many

Aggregation

- Represents a "
xis part ofy" relationship - Many instances (
*) ofxcan be associated withy - Objects of
xandyhave separate lifetimes.
xhas one or morey(lists for example) butycan live withoutx(might be stored somewhere else too), not the love story of the year...
Composition

- Special type of aggregation where parts will be destroyed when the whole is destroyed
- Objects of
ywill live and die withx- This way
ycannot stand by itseft
- This way
Think about it like
xhas a list ofy, and becauseyonly present inx, whenxcomes to an end,ywill follow it into the dark realm of GC purgatory lmao
Dependency

x might use some methods of y, but not stored as a field or attribure
- Special type of association
- If something changes in
y, it can cause changes inx, but not the othe way around xdepends ony
Literally every import we do (and use!) is by definition a dependency. If you download a different version, there might be breaking changes, or it will produce different output (can occur internally too).
Oc. it should not be a problem if the Open-Closed principle isn't forgotten as my dreams are 😿.
Realization
xis said to realize the blueprint classy- Every kind of
interfaceimplementation is a realization

Full diagram examples


Yes, that is a note, what GT. was using everywhere to pus pseudo-code into the system. Like putting salt into my eyedrops, pathetic.
UML isn't what GT showed, it's much simple, such a beautiful creation to represent a complex problem and explain it like I'm 5
Ty for comming to my TED talk, se ya ✌
as the origin and
as the target of a relationship (just call 'em