From 4bc53642eefc1312d0ec55ef162cae7f88998464 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilkka=20Sepp=C3=A4l=C3=A4?= Date: Tue, 29 Nov 2022 21:16:34 +0200 Subject: [PATCH] refactor: minor update --- .gitignore | 4 + ambassador/README.md | 2 +- component/etc/component.urm.puml | 74 +++++++++++++++++ presentation-model/etc/presentation.urm.puml | 82 +++++++++++++++++++ .../etc/serialized-entity.urm.puml | 49 +++++++++++ 5 files changed, 210 insertions(+), 1 deletion(-) create mode 100644 component/etc/component.urm.puml create mode 100644 presentation-model/etc/presentation.urm.puml create mode 100644 serialized-entity/etc/serialized-entity.urm.puml diff --git a/.gitignore b/.gitignore index db9a01616..431eba612 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,7 @@ build/ #################### VS Code #################### .vscode/ + +#################### Java Design Patterns ####### +etc/Java Design Patterns.urm.puml +serialized-entity/output.txt diff --git a/ambassador/README.md b/ambassador/README.md index 66d918a03..4215f4e3d 100644 --- a/ambassador/README.md +++ b/ambassador/README.md @@ -199,4 +199,4 @@ service. ## Credits * [Ambassador pattern](https://docs.microsoft.com/en-us/azure/architecture/patterns/ambassador) -* [Designing Distributed Systems: Patterns and Paradigms for Scalable, Reliable Services](https://books.google.co.uk/books?id=6BJNDwAAQBAJ&pg=PT35&lpg=PT35&dq=ambassador+pattern+in+real+world&source=bl&ots=d2e7GhYdHi&sig=Lfl_MDnCgn6lUcjzOg4GXrN13bQ&hl=en&sa=X&ved=0ahUKEwjk9L_18rrbAhVpKcAKHX_KA7EQ6AEIWTAI#v=onepage&q=ambassador%20pattern%20in%20real%20world&f=false) +* [Designing Distributed Systems: Patterns and Paradigms for Scalable, Reliable Services](https://www.amazon.com/s?k=designing+distributed+systems&sprefix=designing+distri%2Caps%2C156&linkCode=ll2&tag=javadesignpat-20&linkId=a12581e625462f9038557b01794e5341&language=en_US&ref_=as_li_ss_tl) diff --git a/component/etc/component.urm.puml b/component/etc/component.urm.puml new file mode 100644 index 000000000..612eff22a --- /dev/null +++ b/component/etc/component.urm.puml @@ -0,0 +1,74 @@ +@startuml +package com.iluwatar.component.component.physiccomponent { + class ObjectPhysicComponent { + - LOGGER : Logger {static} + + ObjectPhysicComponent() + + update(gameObject : GameObject) + } + interface PhysicComponent { + + update(GameObject) {abstract} + } +} +package com.iluwatar.component.component.inputcomponent { + class DemoInputComponent { + - LOGGER : Logger {static} + - WALK_ACCELERATION : int {static} + + DemoInputComponent() + + update(gameObject : GameObject, e : int) + } + interface InputComponent { + + update(GameObject, int) {abstract} + } + class PlayerInputComponent { + - LOGGER : Logger {static} + - WALK_ACCELERATION : int {static} + + PlayerInputComponent() + + update(gameObject : GameObject, e : int) + } +} +package com.iluwatar.component.component.graphiccomponent { + interface GraphicComponent { + + update(GameObject) {abstract} + } + class ObjectGraphicComponent { + - LOGGER : Logger {static} + + ObjectGraphicComponent() + + update(gameObject : GameObject) + } +} +package com.iluwatar.component { + class App { + - LOGGER : Logger {static} + + App() + + main(args : String[]) {static} + } + class GameObject { + - coordinate : int + - graphicComponent : GraphicComponent + - inputComponent : InputComponent + - name : String + - physicComponent : PhysicComponent + - velocity : int + + GameObject(inputComponent : InputComponent, physicComponent : PhysicComponent, graphicComponent : GraphicComponent, name : String) + + createNpc() : GameObject {static} + + createPlayer() : GameObject {static} + + demoUpdate() + + getCoordinate() : int + + getGraphicComponent() : GraphicComponent + + getInputComponent() : InputComponent + + getName() : String + + getPhysicComponent() : PhysicComponent + + getVelocity() : int + + update(e : int) + + updateCoordinate() + + updateVelocity(acceleration : int) + } +} +GameObject --> "-inputComponent" InputComponent +GameObject --> "-graphicComponent" GraphicComponent +GameObject --> "-physicComponent" PhysicComponent +ObjectGraphicComponent ..|> GraphicComponent +DemoInputComponent ..|> InputComponent +PlayerInputComponent ..|> InputComponent +ObjectPhysicComponent ..|> PhysicComponent +@enduml \ No newline at end of file diff --git a/presentation-model/etc/presentation.urm.puml b/presentation-model/etc/presentation.urm.puml new file mode 100644 index 000000000..23d1942b1 --- /dev/null +++ b/presentation-model/etc/presentation.urm.puml @@ -0,0 +1,82 @@ +@startuml +package com.iluwatar.presentationmodel { + class Album { + - artist : String + - composer : String + - isClassical : boolean + - title : String + + Album(title : String, artist : String, isClassical : boolean, composer : String) + + getArtist() : String + + getComposer() : String + + getTitle() : String + + isClassical() : boolean + + setArtist(artist : String) + + setClassical(isClassical : boolean) + + setComposer(composer : String) + + setTitle(title : String) + } + class App { + - LOGGER : Logger {static} + - App() + + main(args : String[]) {static} + } + class DisplayedAlbums { + - LOGGER : Logger {static} + - albums : List + + DisplayedAlbums() + + addAlbums(title : String, artist : String, isClassical : boolean, composer : String) + + getAlbums() : List + } + class PresentationModel { + - LOGGER : Logger {static} + - data : DisplayedAlbums + - selectedAlbum : Album + - selectedAlbumNumber : int + + PresentationModel(dataOfAlbums : DisplayedAlbums) + + albumDataSet() : DisplayedAlbums {static} + + getAlbumList() : String[] + + getArtist() : String + + getComposer() : String + + getIsClassical() : boolean + + getTitle() : String + + setArtist(value : String) + + setComposer(value : String) + + setIsClassical(value : boolean) + + setSelectedAlbumNumber(albumNumber : int) + + setTitle(value : String) + } + class View { + ~ HEIGHT : int {static} + ~ HEIGHT_TXT : int {static} + ~ LOCATION_X : int {static} + ~ LOCATION_Y : int {static} + - LOGGER : Logger {static} + ~ WIDTH : int {static} + ~ WIDTH_TXT : int {static} + - albumList : JList + - apply : JButton + - cancel : JButton + - chkClassical : JCheckBox + - model : PresentationModel + - txtArtist : TextField + - txtComposer : TextField + - txtTitle : TextField + + View() + + createView() + + getAlbumList() : JList + + getApply() : JButton + + getCancel() : JButton + + getChkClassical() : JCheckBox + + getModel() : PresentationModel + + getTxtArtist() : TextField + + getTxtComposer() : TextField + + getTxtTitle() : TextField + + loadFromPMod() + + saveToPMod() + } +} +DisplayedAlbums --> "-albums" Album +View --> "-model" PresentationModel +PresentationModel --> "-data" DisplayedAlbums +PresentationModel --> "-selectedAlbum" Album +@enduml \ No newline at end of file diff --git a/serialized-entity/etc/serialized-entity.urm.puml b/serialized-entity/etc/serialized-entity.urm.puml new file mode 100644 index 000000000..24a455436 --- /dev/null +++ b/serialized-entity/etc/serialized-entity.urm.puml @@ -0,0 +1,49 @@ +@startuml +package com.iluwatar.serializedentity { + class App { + - DB_URL : String {static} + - LOGGER : Logger {static} + - App() + - createDataSource() : DataSource {static} + - createSchema(dataSource : DataSource) {static} + - deleteSchema(dataSource : DataSource) {static} + + main(args : String[]) {static} + } + class Country { + - code : int + - continents : String + - language : String + - name : String + + serialVersionUID : long {static} + + Country(code : int, name : String, continents : String, language : String) + # canEqual(other : Object) : boolean + + equals(o : Object) : boolean + + getCode() : int + + getContinents() : String + + getLanguage() : String + + getName() : String + + hashCode() : int + + setCode(code : int) + + setContinents(continents : String) + + setLanguage(language : String) + + setName(name : String) + + toString() : String + } + interface CountryDao { + + insertCountry() : int {abstract} + + selectCountry() : int {abstract} + } + class CountrySchemaSql { + + CREATE_SCHEMA_SQL : String {static} + + DELETE_SCHEMA_SQL : String {static} + - LOGGER : Logger {static} + - country : Country + - dataSource : DataSource + + CountrySchemaSql(country : Country, dataSource : DataSource) + + insertCountry() : int + + selectCountry() : int + } +} +CountrySchemaSql --> "-country" Country +CountrySchemaSql ..|> CountryDao +@enduml \ No newline at end of file