PB007

Advanced

slides.com/veeenex/pb007

Seminar #01

Introduction

Xuan Linh Phamová - Linh

Student of Master’s degree programme Software Systems Development Management. In the spring semester, I am a seminar tutor of PV260 Software Quality.

Daniel Plakinger
- Dano

Student of Bachelor’s degree programme Bioinformatics. Seminartutor of PV281, PB138 and PB007. Currently freelance DevOps, Project Manager, Consultant

Your tutors

No, we’re not a couple.

Motivation

  • Algorithms vs Architecture
  • System abstraction
  • Universal language
  • Quick start
  • But almost nobody use it

Average client

Why is this group different?

  • Feedback from other years
  • Missing knowledge on other courses
  • Motivation to create enjoyable course

Organisation of Lectures

  • Initially online via Zoom (subject of change)
  • General introduction to every UML diagram
  • Highly recommended to attend

Organisation of Seminars

  • Czech & Slovak
  • Communication -> Discord*
  • Discussion forum
  • ROPOTS
  • Attendance
  • Slides
    • Diagram (Official)
    • Advanced
  • Gitlab
  • Custom group naming

* Main reason to create Discord server is for doxxing students, we do not take any responsibility for joining server

Plant what?

  • Open-source
  • Easy to copy-paste
  • Collaboration
  • ...
@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response

Alice -> Bob: Another authentication Request
Alice <-- Bob: Another authentication Response
@enduml

Grading

Seminars

  • 5 points - Activities during the semester
  • 20 points - Mini-ROPOT at the begging of the seminar

EXam

  • 35 points - Diagram
  • 35 points - Quiz part multichoice

During semester

...On making groups

Feedback

Q&A

Brainstorming

reDiscover for Turists in random groups on coggle

The pandemic forced the owners to close their shops and stores and thus loosing their income. The gastronomic and tourist industries suffered the greatest impact. The municipalities of several cities have decided to change the situation with a vision to create a game that would help bring life back on track and support tourism by helping small and medium-sized businesses in cities and regions.

Idea

The aim of the reDiscover project is to create an affordable application that would reward users for supporting tourism and at the same time would attract tourists to lesser-known places and thus support the economic growth of regions and places. Within the application, users collects points and badges to redeem awards, which can later be used in businesses, events and for various attractions.

What about Semester project?

  • Make groups
  • Read the assesment
    • Find users
    • Find requirements
    • Think as user and stakeholder
  • Understand requirements
  • Ask stakeholder!

#attendLectures

Example

Seminar #02

Use case diagram

Plan

  1. Setup team repository
  2. Setup VSCode & Extension
  3. Learn about use-case diagram
  4. Make use-case diagram
  5. Upload use-case diagrams

author: Daminán Paranič

Setup

  • Repository
  • VSCode
  • PlantUML Extension

Functional Requirements

  • Ask what might happen?
  • How does it happen?
  • Who does the action?

Non-Functional Requirements

  • Know your team
    • Technologies
    • Job market
  • Know your target users
    • Health, Age, Social status
  • Know your budget
    • Security
    • Hosting

Diagram

@startuml
skinparam packageStyle rect

' Define actors
actor "Teacher" as teacher
actor "Student" as student
actor "Internal Teacher" as internal_teacher
actor "External Teacher" as external_teacher

' Define system boundaries and usecases
rectangle "Study system" as system {
  usecase "LogIn" as LogIn
  usecase "LogOut" as LogOut
  usecase "CourseManagement" as CourseManagement
  usecase "ReportSubmittal" as ReportSubmittal
  usecase "Notify" as Notify
  usecase "CourseDropping" as CourseDropping
  usecase "FullTimeCourseSearch" as FullTimeCourseSearch
  usecase "DistanceStudyCourseSearch" as DistanceStudyCourseSearch
}

' Connections between actors and usecases
teacher -r- LogIn
teacher -r- LogOut
teacher -r- Notify
teacher -r- CourseManagement

external_teacher -- ReportSubmittal

@enduml

Searching for actors

  1. Who uses the system?
  2. Who installs the system?
  3. Who starts up the system?
  4. Who maintains the system?
  5. Who shuts down the system?
  6. What other systems use this system?
  7. Who gets information from this system?
  8. Who provides information to the system?
  9. Does anything happen automatically at a present time?

Searching for use cases

  1. What functions will the actor want from the system?
  2. Does the system store information? What actors will create, read, update or delete this information?
  3. Does the system need to notify an actor about changes in the internal state?
  4. Are there any external events the system must know about? What actor informs the system of those events?

Best practises

  • The left side of the diagram is meant for end-users, right side for bots, admins...
  • Place initial use-cases on the top eg. Login, Logout, Register...

Deadline Tuesday 23:59:59

Don't forget to check:

Katalóg chýb

Seminar #03

Use case diagram + USER STORIES

LEt's take a look on Actors

Generalization

Relations

...And usecases

Good Example

Bad Example

Once upon a time

Gherkin

Feature: Google Searching
  As a web surfer, I want to search Google, so that I can learn new things.
  
  Scenario: Simple Google search
    Given a web browser is on the Google page
    When the search phrase "panda" is entered
    Then results for "panda" are shown
@startuml
skinparam packageStyle rect

' Define actors
actor "Teacher" as teacher
actor "Student" as student
actor "Internal Teacher" as internal_teacher
actor "External Teacher" as external_teacher

rectangle "Study system" as system {
  usecase "CourseManagement" as CourseManagement
  
  usecase/ CourseEnrollment as "CourseEnrollment\n---\n**Extension Point**\nExceededCapacity"
  usecase "ReportSubmittal" as ReportSubmittal
  usecase "Notify" as Notify
  usecase/ "CourseSearch" as CourseSearch
  usecase "CourseDropping" as CourseDropping
  usecase "FullTimeCourseSearch" as FullTimeCourseSearch
  usecase "DistanceStudyCourseSearch" as DistanceStudyCourseSearch

}

Notify ..> CourseEnrollment : <<extends>>
CourseManagement ..> CourseSearch : <<include>>
CourseEnrollment ..> CourseSearch : <<include>>
CourseDropping ..> CourseSearch : <<include>>

teacher <|-right- internal_teacher
teacher <|-right- external_teacher

CourseSearch <|-- FullTimeCourseSearch
CourseSearch <|-- DistanceStudyCourseSearch

@enduml
## Use Case ID

1

## Brief description

UC1 allows student to be electronically enrolled in the course.

## Primary Actors

Student

## Secondary Actors

Teacher

## Preconditions

Student is logged in the system

## Main flow

- 1 UC is evoked, once Student selects "Course Enrollment" in the menu.
- 2 INCLUDE(CourseSearch)
- 3 IF at least one course was found
- 3.1 FOR EACH (course found, which has not reached full capacity yet)
  - 3.1.1 System displays actual number of enrolled students and offers "Enroll in the course"
- 3.2 IF Student selects "Enroll in the course"
  - 3.2.1 System enrolls Student in the course

EXTENSION POINT(FullCapacityReached)

- 3.2.2 System confirms successful enrollment in the course and updates
  number of enrolled students in the course.

## Post conditions

List of enrolled students in the course is updated.

## Alternative flow

Student may leave the page anytime by selecting "Back to the previous
page" or by logging out of the system.

Deadline Tuesday 23:59:59

Don't forget to check:

Katalóg chýb

Seminar #04

Activity diagram

During DEVELOPMENT

  • Focus on MVP (Minimum Valuable Project)

Activity diagram

Deadline Tuesday 23:59:59

Don't forget to check:

Katalóg chýb

Seminar #05

Class DIAGRAM (ANALYSIS)

Plan

  • ROPOT
  • Analytical Class diagram
  • Fix Milestone 1
  • Open new Milestone 2

What it is

  • concept not implementation

  • domain oriented - one time, next time

  • relations, business objects
  • it's not only OOP based!

WHAT IT IS NOT

  • no n:m relations
  • no datatypes
  • constructors
  • getters and setters
  • controllers, managers, services, aggregates, commands, queries, resolvers, repositories...

Focus on

  • meaningful name

  • business functions (2-10)

  • keep number of relations low

  • focus on relations between objects

@startuml
' hide the spot
hide circle

class Car

Driver "1" - "1..*" Car : drives >
Car "*" - "4" Wheel : have >
Car "0..*" -- "0..*" Person : < owns

@enduml

Relations

  • Generalisation
  • Association
  • Dependency/Use

Association

  • based on domain

  • reference to other object in that class

  • contains

    • navigability (who owns refference)

    • name

    • multiplicity

  • multiplicities

    • 1:1

    • 1:N
    • M:N

M:N

@startuml
class Student {
  Name
}
Student "0..*" - "1..*" Course
(Student, Course) .. Enrollment

class Enrollment {
  drop()
  cancel()
}
@enduml

<<use>>

  • <<use>> use is not an attribute of class order
  • PayGate only uses class Order

use camelCase() methods

Deadline Tuesday 23:59:59

Don't forget to check:

Katalóg chýb

Seminar #06

Class DIAGRAM (ANALYSIS)

Wrapping it up

Light DDD Introduction

On one slide

  • independed on language or framework
  • collection of ideas and processes on domain
  • focus on main features and aspects of domain
  • translates real world problems to code
  • easier testing and integration of other services

https://martinfowler.com/bliki/DomainDrivenDesign.html

Domain

Space with boundries

Domain Language

Dobropis

Ráfik

Margin call

Výdajka

Rohový kop

Ubiquitus language

Commision Rate

Contributor

MR vs PR

Spread

https://martinfowler.com/bliki/UbiquitousLanguage.html

Context

Finding BOUNDARIES

Model

Activity

In TEAM

  • Find 5

    • domain rules

    • WORDS
  • ​FIND 2 CONTEXTS

Your

own?

Time to do some fixin'

And what?

  • Check use-case diagram, do you support all cases?
  • Do we cover all real world problems?
    • ​Company cannot exist without BussinessId
  • Navigability, multiplicity

Anemic model

https://martinfowler.com/bliki/AnemicDomainModel.html

DDD

Aggregate

https://martinfowler.com/bliki/DDD_Aggregate.html

Example

To be continued...

  • Survey

Deadline Tuesday 23:59:59

Don't forget to check:

Katalóg chýb

Seminar #07

ER Diagram

Entity-relationship diagram

Common mistakes

Examples

https://plantuml.com/ie-diagram

@startuml

' hide the spot
hide circle

' avoid problems with angled crows feet
skinparam linetype ortho

entity "Entity01" as e01 {
  *e1_id : number <<generated>>
  --
  *name : text
  description : text
}

entity "Entity02" as e02 {
  *e2_id : number <<generated>>
  --
  *e1_id : number <<FK>>
  other_details : text
}

entity "Entity03" as e03 {
  *e3_id : number <<generated>>
  --
  e1_id : number <<FK>>
  other_details : text
}

e01 ||..o{ e02
e01 |o..o{ e03

@enduml

https://devdojo.com/tnylea/understanding-polymorphic-relationships

Instagram vs 9gag

ORM

Eloquent, Doctrine, ActiveRecord, TypeORM

Active record pattern

<?php
namespace App\Models;

class Post extends Model
{
    /**
     * One to Many relation
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function user()
    {
        return $this->belongsTo(User::class);
    }

    /**
     * One to Many relation
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function comments()
    {
        return $this->hasMany(Comment::class);
    }
}
class Post {
    /**
     * @var string
     *
     * @ORM\Column(type="string")
     * @Assert\NotBlank
     */
    private $title;

    /**
     * @var string
     *
     * @ORM\Column(type="string")
     */
    private $slug;
}
part = new Post()
part.name = "Sample post"
part.slug = "sample-post"
part.save()

NoSQL vs *SQL

UUID vs ID

https://stackoverflow.com/a/30462400

https://devforth.io/blog/why-your-software-should-use-uuids

Normálové formičky

1NF

2NF

3NF

I want mooore!

Airbnb

Twitter

Deadline Tuesday 23:59:59

Don't forget to check:

Katalóg chýb

Seminar #08

Design Diagram

Implementation

  • visibility of classes, methods, attributes
  • getters setters
  • constructors
  • return types
  • enums, interfaces

Relations

Aggregation

  • Celok môže, ale aj nemusí existovať bez svojich súčastí
  • Časti môžu existovať nezávisle na celku.
  • Celok je v určitom zmysle neúplný ak niektoré časti chýbajú.
  • Časť môže byť teoreticky zdielaná viacerými celkami.
  • Agregácia je tranzitívna a asymetrická (bez cyklov).
class Car:
    def __init__(self, engine):
        self.engine = engine

class Engine:
    def __init__(self):
        pass
engine = Engine()
car = Car(engine) # Ak zmazeme Auto, motor môze stále existovať

Composition

  • V danom čase časť patrí vždy práve jednému celku (nemôžu existovať samostatne).
  • Celok je zodpovedný za vytváranie a mazanie častí.
  • Ak je celok zrušený, musí buď zrušiť všetky svoje časti, alebo presunúť za ne zodpovednosť inému objektu.
  • Kompozícia je tranzitívna a asymetrická (bez cyklov).
class Book:
    def __init__(self):
       page1 = Page('This is content for page 1')
       page2 = Page('This is content for page 2')
       self.pages = [page1, page2]

class Page:
    def __init__(self, content):
        self.content = content

book = Book() # Ak zmazeme knihu zmazeme aj Page
  • Kosoštvorček na stranu triedy, ktorá vytvára danú entitu, prípadne tvorí jej väčšiu podčasť

Revízia asociácií 1:1

Revízia asociácií M:1

Rozklad asociácií M:N

Interface

Rozhranie (Interface) je špeciálny typ, ktorý definuje množinu verejných metód, atribútov a vzťahov, ale neobsahuje ich implementáciu. Používa sa na definíciu kontraktu.

Advanced

CQRS, Event Sourcing

Manager classes

Deadline Tuesday 23:59:59

Don't forget to check:

Katalóg chýb

Seminar #09

State Diagram

Common Problems

  • We are still in Milestone 2
class Project(authGuard: AuthGuard):

	def edit(name: string, visibility: bool):
		if this.authGuard.user.role != 'autor':
			raise UnAuthorizedOperation('Get the...')

		this.name = name
		this.visibility = visibility

Let's be stateful

Made of

  • states
  • events
  • transitions

Syntax: udalosť [podmienka] / akcia

Stavový diagram nemusí reprezentovať kód

Prečo tu riešime pickup date?

používa sa neskôr pri nejakom prechode takže nás zaujíma, čo sa s ním deje

From Design diagram to State diagram

Aktivita?

Parallel

Region

Composed

Notice: Nemusíme mať final node

In hunt of states

  • Stav reprezentuje dôležitý bod v dómene
  • Na stav chcete zaregovať, niečo spraviť, poslať notifikáciu niečo zmeniť

Dobré stavy

Zlé stavy

  • Nová objednávka
  • Zakúpený lístok
  • Odstránený člen
  • Vytváranie objednávky
  • Prezeranie lístka
  • Odstránenie užívateľa
@startuml
scale 600 width

[*] -> State1
State1 --> State2 : Succeeded
State1 --> [*] : Aborted
State2 --> State3 : Succeeded
State2 --> [*] : Aborted
state State3 {
  state "Accumulate Enough Data\nLong State Name" as long1
  long1 : Just a test
  [*] --> long1
  long1 --> long1 : New Data
  long1 --> ProcessData : Enough Data
}
State3 --> State3 : Failed
State3 --> [*] : Succeeded / Save Result
State3 --> [*] : Aborted

@enduml

Seminar #10

Sequence and Communication diagrams

Intro

Common mistakes

Interakcie

In language of diagrams

Communication diagram

Something like black images shown previously

Sequence diagram

Focus on time similar to flame graph, communication between classes

Communication diagram

LinkedIn is like a reverse dating site. Girls write to you and you ignore them. Just show them you know CQRS, they melt

Aktivita

@startuml
skinparam linestyle ortho
rectangle "A" as one
rectangle "B" as two
rectangle "C" as three
rectangle "D" as four

one -right-> two: message 1-->2
two -right-> three: message 2-->3
two --> four: message 2-->4
three -[hidden]- four
@enduml

Tasks

Seminar #11

Sequence diagram

Just a recap

  • Different view on communication
  • Time and lifeline is important

Fragments

Loop, conditions, parallelism

Ukážka

@startuml
autonumber 1.1.1
Alice -> Bob: Authentication request
Bob --> Alice: Response

autonumber inc A
'Now we have 2.1.1
Alice -> Bob: Another authentication request
Bob --> Alice: Response

autonumber inc B
'Now we have 2.2.1
Alice -> Bob: Another authentication request
Bob --> Alice: Response

autonumber inc A
'Now we have 3.1.1
Alice -> Bob: Another authentication request
autonumber inc B
'Now we have 3.2.1
Bob --> Alice: Response
@enduml

Seminar #12

Package, Deployment, Component

Seminar #12

Package, Deployment, Component

  • ROPOT (Package, Deployment, Component)
  • Points from seminar
  • Seminar
  • Last ten minutes (ROPOT from everything)

For halp

  • 1 - za všetky diagramy (a uzatvorenie Milestones)
  • 1 - za skoré odovzdanie (pred Vianocami)
  • 0.5 - za opravu diagramu podľa code review inej skupiny
  • 0.5 - za C4 diagram (Extra aktivita)
  • 0.5 - za pekný diagram alebo extra diagramy
  • 0.5 - za code review inej skupiny
  • 1 - akákoľvek extra aktivita, snaha

Package diagram

+ Triedy, ktoré sme pridali v Návrhovom

Riešime závislosti a logické celky na úrovni kódu

ČAsti Package Diagramu

Kompaktný mód

Náš mód

Problém: Cyklická zÁvislosť

Component Diagram

Riešime architektonické časti systému

Deployment diagram

Riešime nasadenie komponentov

Analysis diagram

FINAL

CVICENIE

Odpovedník

20 otázok, každá po 0.5 boda 20min/30min teiresias.

Body

Zdroje

PB007 - Seminars

By VeeeneX

PB007 - Seminars

Slides k cvičeniam PB007

  • 873