mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-14 06:58:54 +00:00
refactor: minor update
This commit is contained in:
@@ -53,3 +53,7 @@ build/
|
||||
|
||||
#################### VS Code ####################
|
||||
.vscode/
|
||||
|
||||
#################### Java Design Patterns #######
|
||||
etc/Java Design Patterns.urm.puml
|
||||
serialized-entity/output.txt
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
@@ -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<Album>
|
||||
+ DisplayedAlbums()
|
||||
+ addAlbums(title : String, artist : String, isClassical : boolean, composer : String)
|
||||
+ getAlbums() : List<Album>
|
||||
}
|
||||
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<String>
|
||||
- apply : JButton
|
||||
- cancel : JButton
|
||||
- chkClassical : JCheckBox
|
||||
- model : PresentationModel
|
||||
- txtArtist : TextField
|
||||
- txtComposer : TextField
|
||||
- txtTitle : TextField
|
||||
+ View()
|
||||
+ createView()
|
||||
+ getAlbumList() : JList<String>
|
||||
+ 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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user