├── HouseCleaning1 ├── .gitignore ├── run.sh ├── README.md ├── pom.xml └── src │ └── main │ └── java │ └── dja │ └── housecleaning │ ├── client │ └── Client.java │ └── Harry.java ├── HouseCleaning2 ├── .gitignore ├── run.sh ├── src │ └── main │ │ └── java │ │ └── dja │ │ └── housecleaning │ │ ├── OrderForm.java │ │ ├── Ronald.java │ │ ├── Garage.java │ │ ├── Harry.java │ │ └── client │ │ └── Client.java ├── pom.xml └── README.md ├── HouseCleaning3 ├── .gitignore ├── HouseCleaning3-assets │ ├── .gitignore │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── dja │ │ │ └── housecleaning │ │ │ └── assets │ │ │ ├── package-info.java │ │ │ ├── Garage.java │ │ │ └── Storage.java │ └── pom.xml ├── HouseCleaning3-client │ ├── .gitignore │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── dja │ │ └── housecleaning │ │ └── client │ │ └── Client.java ├── HouseCleaning3-company │ ├── .gitignore │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── dja │ │ │ └── housecleaning │ │ │ └── company │ │ │ ├── package-info.java │ │ │ ├── Andrey.java │ │ │ └── Harry.java │ └── pom.xml ├── HouseCleaning3-front │ ├── .gitignore │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── dja │ │ │ └── housecleaning │ │ │ └── front │ │ │ ├── package-info.java │ │ │ ├── OrderForm.java │ │ │ └── Ronald.java │ └── pom.xml ├── run.sh ├── pom.xml └── README.md ├── HouseCleaning4 ├── .gitignore ├── HouseCleaning4-client │ ├── .gitignore │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── dja │ │ └── housecleaning │ │ └── client │ │ └── Client.java ├── HouseCleaning4-company │ ├── .gitignore │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── dja │ │ │ └── housecleaning │ │ │ ├── package-info.java │ │ │ ├── Garage.java │ │ │ └── Harry.java │ └── pom.xml ├── HouseCleaning4-backoffice │ ├── .gitignore │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── dja │ │ │ └── housecleaning │ │ │ └── backoffice │ │ │ ├── package-info.java │ │ │ ├── Storage.java │ │ │ └── Andrey.java │ └── pom.xml ├── HouseCleaning4-frontoffice │ ├── .gitignore │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── dja │ │ │ └── housecleaning │ │ │ └── frontoffice │ │ │ ├── package-info.java │ │ │ ├── OrderForm.java │ │ │ └── Ronald.java │ └── pom.xml ├── run.sh └── pom.xml ├── HouseCleaning6 ├── status ├── HouseCleaning6-client │ ├── .gitignore │ ├── src │ │ └── main │ │ │ └── java │ │ │ ├── module-info.java │ │ │ └── dja │ │ │ └── housecleaning │ │ │ └── client │ │ │ └── Client.java │ └── pom.xml ├── HouseCleaning6-company │ ├── .gitignore │ ├── src │ │ └── main │ │ │ └── java │ │ │ ├── dja │ │ │ └── housecleaning │ │ │ │ └── company │ │ │ │ ├── shared │ │ │ │ ├── package-info.java │ │ │ │ ├── CleaningInstructions.java │ │ │ │ ├── CleaningInstruction.java │ │ │ │ └── InsufficientAmountException.java │ │ │ │ ├── processes │ │ │ │ ├── package-info.java │ │ │ │ ├── CleanHouseProcess.java │ │ │ │ ├── NewOrderProcess.java │ │ │ │ ├── PrepareForCleaningProcess.java │ │ │ │ └── TransportProcess.java │ │ │ │ ├── jobpositions │ │ │ │ ├── package-info.java │ │ │ │ ├── Accountant.java │ │ │ │ ├── Cleaner.java │ │ │ │ ├── Receptionist.java │ │ │ │ └── Assistant.java │ │ │ │ └── internal │ │ │ │ ├── assets │ │ │ │ ├── package-info.java │ │ │ │ ├── Vehicles.java │ │ │ │ ├── Software.java │ │ │ │ └── Storage.java │ │ │ │ ├── shared │ │ │ │ ├── package-info.java │ │ │ │ ├── PricingPolicy.java │ │ │ │ ├── InternalCleaningInstruction.java │ │ │ │ └── InternalCleaningInstructions.java │ │ │ │ └── staff │ │ │ │ ├── package-info.java │ │ │ │ ├── Staff.java │ │ │ │ ├── Harry.java │ │ │ │ ├── Ronald.java │ │ │ │ └── Andrey.java │ │ │ └── module-info.java │ └── pom.xml ├── HouseCleaning6-usecases │ ├── .gitignore │ ├── src │ │ └── main │ │ │ └── java │ │ │ ├── dja │ │ │ └── housecleaning │ │ │ │ └── usecases │ │ │ │ ├── package-info.java │ │ │ │ ├── CleaningRequest.java │ │ │ │ └── CustomerUsecases.java │ │ │ └── module-info.java │ └── pom.xml ├── HouseCleaning6-frontoffice │ ├── .gitignore │ ├── src │ │ └── main │ │ │ └── java │ │ │ ├── dja │ │ │ └── housecleaning │ │ │ │ └── frontoffice │ │ │ │ ├── package-info.java │ │ │ │ ├── internal │ │ │ │ ├── package-info.java │ │ │ │ └── FrontOfficeCleaningRequest.java │ │ │ │ ├── OrderForm.java │ │ │ │ └── FrontOffice.java │ │ │ └── module-info.java │ └── pom.xml └── run.sh ├── HouseCleaning7 ├── status ├── HouseCleaning7-client │ ├── .gitignore │ ├── src │ │ └── main │ │ │ └── java │ │ │ ├── module-info.java │ │ │ └── dja │ │ │ └── housecleaning │ │ │ └── client │ │ │ └── Client.java │ └── pom.xml ├── HouseCleaning7-company │ ├── .gitignore │ ├── src │ │ └── main │ │ │ └── java │ │ │ ├── dja │ │ │ └── housecleaning │ │ │ │ └── company │ │ │ │ ├── shared │ │ │ │ ├── package-info.java │ │ │ │ ├── CleaningInstructions.java │ │ │ │ ├── CleaningInstruction.java │ │ │ │ └── InsufficientAmountException.java │ │ │ │ ├── processes │ │ │ │ ├── package-info.java │ │ │ │ ├── CleanHouseProcess.java │ │ │ │ ├── TransportProcess.java │ │ │ │ ├── NewOrderProcess.java │ │ │ │ └── PrepareForCleaningProcess.java │ │ │ │ ├── jobpositions │ │ │ │ ├── package-info.java │ │ │ │ ├── Accountant.java │ │ │ │ ├── Cleaner.java │ │ │ │ ├── Receptionist.java │ │ │ │ └── Assistant.java │ │ │ │ └── internal │ │ │ │ ├── assets │ │ │ │ ├── package-info.java │ │ │ │ ├── Vehicles.java │ │ │ │ ├── Software.java │ │ │ │ └── Storage.java │ │ │ │ ├── shared │ │ │ │ ├── package-info.java │ │ │ │ ├── PricingPolicy.java │ │ │ │ ├── InternalCleaningInstruction.java │ │ │ │ └── InternalCleaningInstructions.java │ │ │ │ ├── staff │ │ │ │ ├── package-info.java │ │ │ │ ├── Staff.java │ │ │ │ ├── Harry.java │ │ │ │ ├── Ronald.java │ │ │ │ └── Andrey.java │ │ │ │ └── processes │ │ │ │ ├── package-info.java │ │ │ │ ├── InternalCleanHouseProcess.java │ │ │ │ ├── InternalNewOrderProcess.java │ │ │ │ ├── InternalPrepareForCleaningProcess.java │ │ │ │ └── InternalTransportProcess.java │ │ │ └── module-info.java │ └── pom.xml ├── HouseCleaning7-usecases │ ├── .gitignore │ ├── src │ │ └── main │ │ │ └── java │ │ │ ├── dja │ │ │ └── housecleaning │ │ │ │ └── usecases │ │ │ │ ├── package-info.java │ │ │ │ └── CleaningRequest.java │ │ │ └── module-info.java │ └── pom.xml ├── HouseCleaning7-frontoffice │ ├── .gitignore │ ├── src │ │ └── main │ │ │ └── java │ │ │ ├── dja │ │ │ └── housecleaning │ │ │ │ └── frontoffice │ │ │ │ ├── package-info.java │ │ │ │ ├── internal │ │ │ │ ├── package-info.java │ │ │ │ └── FrontOfficeCleaningRequest.java │ │ │ │ ├── OrderForm.java │ │ │ │ └── FrontOffice.java │ │ │ └── module-info.java │ └── pom.xml ├── HouseCleaning7-uber-transport │ ├── .gitignore │ ├── src │ │ └── main │ │ │ └── java │ │ │ ├── module-info.java │ │ │ └── dja │ │ │ └── housecleaning │ │ │ └── company │ │ │ └── internal │ │ │ └── processes │ │ │ └── uber │ │ │ └── transport │ │ │ └── UberTransportProcess.java │ └── pom.xml └── run.sh ├── HouseCleaning8 ├── status ├── HouseCleaning8-client │ ├── .gitignore │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── dja │ │ └── housecleaning │ │ └── client │ │ └── Client.java ├── HouseCleaning8-company │ ├── .gitignore │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── dja │ │ │ └── housecleaning │ │ │ └── company │ │ │ ├── internal │ │ │ ├── assets │ │ │ │ ├── package-info.java │ │ │ │ ├── Vehicles.java │ │ │ │ ├── Software.java │ │ │ │ └── Storage.java │ │ │ ├── shared │ │ │ │ ├── package-info.java │ │ │ │ ├── PricingPolicy.java │ │ │ │ ├── InternalCleaningInstruction.java │ │ │ │ └── InternalCleaningInstructions.java │ │ │ ├── staff │ │ │ │ ├── package-info.java │ │ │ │ ├── Staff.java │ │ │ │ ├── Harry.java │ │ │ │ ├── Ronald.java │ │ │ │ └── Andrey.java │ │ │ └── processes │ │ │ │ ├── package-info.java │ │ │ │ ├── InternalCleanHouseProcess.java │ │ │ │ ├── InternalNewOrderProcess.java │ │ │ │ ├── InternalPrepareForCleaningProcess.java │ │ │ │ └── InternalTransportProcess.java │ │ │ ├── shared │ │ │ ├── package-info.java │ │ │ ├── CleaningInstructions.java │ │ │ ├── CleaningInstruction.java │ │ │ └── InsufficientAmountException.java │ │ │ ├── jobpositions │ │ │ ├── package-info.java │ │ │ ├── Accountant.java │ │ │ ├── Cleaner.java │ │ │ ├── Receptionist.java │ │ │ └── Assistant.java │ │ │ └── processes │ │ │ ├── package-info.java │ │ │ ├── CleanHouseProcess.java │ │ │ ├── NewOrderProcess.java │ │ │ ├── TransportProcess.java │ │ │ └── PrepareForCleaningProcess.java │ └── pom.xml ├── HouseCleaning8-usecases │ ├── .gitignore │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── dja │ │ │ └── housecleaning │ │ │ └── usecases │ │ │ ├── package-info.java │ │ │ └── CleaningRequest.java │ └── pom.xml ├── HouseCleaning8-frontoffice │ ├── .gitignore │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── dja │ │ │ └── housecleaning │ │ │ └── frontoffice │ │ │ ├── internal │ │ │ ├── package-info.java │ │ │ └── FrontOfficeCleaningRequest.java │ │ │ ├── package-info.java │ │ │ ├── OrderForm.java │ │ │ └── FrontOffice.java │ └── pom.xml ├── HouseCleaning8-uber-transport │ ├── .gitignore │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── dja │ │ └── housecleaning │ │ └── company │ │ └── internal │ │ └── processes │ │ └── uber │ │ └── transport │ │ └── UberTransportProcess.java ├── HouseCleaning8-other-things-bundle │ ├── .gitignore │ ├── bnd.bnd │ └── pom.xml ├── run.sh └── HouseCleaning8-run │ └── housecleaning-client.bndrun ├── things ├── .gitignore ├── src │ └── main │ │ └── java │ │ └── other │ │ └── things │ │ ├── package-info.java │ │ ├── CleaningSupplyStore.java │ │ ├── BookkeepingSystem.java │ │ ├── CleaningTool.java │ │ ├── CleaningSupply.java │ │ └── Van.java └── pom.xml ├── HouseCleaning5 ├── HouseCleaning5-client │ ├── .gitignore │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── dja │ │ └── housecleaning │ │ └── client │ │ └── Client.java ├── HouseCleaning5-company │ ├── .gitignore │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── dja │ │ │ └── housecleaning │ │ │ └── company │ │ │ ├── assets │ │ │ ├── package-info.java │ │ │ ├── Vehicles.java │ │ │ ├── Software.java │ │ │ └── Storage.java │ │ │ ├── shared │ │ │ ├── package-info.java │ │ │ ├── PricingPolicy.java │ │ │ ├── InsufficientAmountException.java │ │ │ └── CleaningInstructions.java │ │ │ ├── staff │ │ │ ├── package-info.java │ │ │ ├── Staff.java │ │ │ ├── Ronald.java │ │ │ ├── Harry.java │ │ │ └── Andrey.java │ │ │ ├── processes │ │ │ ├── package-info.java │ │ │ ├── CleanHouseProcess.java │ │ │ ├── TransportProcess.java │ │ │ ├── NewOrderProcess.java │ │ │ └── PrepareForCleaningProcess.java │ │ │ └── jobpositions │ │ │ ├── package-info.java │ │ │ ├── Accountant.java │ │ │ ├── Cleaner.java │ │ │ ├── Receptionist.java │ │ │ └── Assistant.java │ └── pom.xml ├── HouseCleaning5-usecases │ ├── .gitignore │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── dja │ │ │ └── housecleaning │ │ │ └── usecases │ │ │ ├── package-info.java │ │ │ ├── CleaningRequest.java │ │ │ └── CustomerUsecases.java │ └── pom.xml ├── HouseCleaning5-frontoffice │ ├── .gitignore │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── dja │ │ │ └── housecleaning │ │ │ └── frontoffice │ │ │ ├── package-info.java │ │ │ ├── OrderForm.java │ │ │ ├── FrontOfficeCleaningRequest.java │ │ │ └── FrontOffice.java │ └── pom.xml └── run.sh ├── .gitignore ├── java_version.sh └── run_functions.sh /HouseCleaning1/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning2/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning3/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning4/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning6/status: -------------------------------------------------------------------------------- 1 | van.functional = true -------------------------------------------------------------------------------- /HouseCleaning7/status: -------------------------------------------------------------------------------- 1 | van.functional = true -------------------------------------------------------------------------------- /HouseCleaning8/status: -------------------------------------------------------------------------------- 1 | van.functional = true -------------------------------------------------------------------------------- /things/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /target/ 3 | -------------------------------------------------------------------------------- /HouseCleaning3/HouseCleaning3-assets/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning3/HouseCleaning3-client/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning3/HouseCleaning3-company/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning3/HouseCleaning3-front/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning4/HouseCleaning4-client/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning4/HouseCleaning4-company/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-client/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-company/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-usecases/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-client/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-usecases/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-client/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-usecases/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-client/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-usecases/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning4/HouseCleaning4-backoffice/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning4/HouseCleaning4-frontoffice/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-frontoffice/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-frontoffice/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-frontoffice/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-uber-transport/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-frontoffice/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-uber-transport/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-other-things-bundle/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-other-things-bundle/bnd.bnd: -------------------------------------------------------------------------------- 1 | Export-Package: other.things -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/.classpath 2 | **/.project 3 | **/.settings/* 4 | **/target/* 5 | **/stats/* 6 | -------------------------------------------------------------------------------- /HouseCleaning4/HouseCleaning4-company/src/main/java/dja/housecleaning/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning; -------------------------------------------------------------------------------- /HouseCleaning3/HouseCleaning3-front/src/main/java/dja/housecleaning/front/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.front; -------------------------------------------------------------------------------- /HouseCleaning3/HouseCleaning3-assets/src/main/java/dja/housecleaning/assets/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.assets; -------------------------------------------------------------------------------- /HouseCleaning3/HouseCleaning3-company/src/main/java/dja/housecleaning/company/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.company; -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-usecases/src/main/java/dja/housecleaning/usecases/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.usecases; -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-usecases/src/main/java/dja/housecleaning/usecases/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.usecases; -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-usecases/src/main/java/dja/housecleaning/usecases/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.usecases; -------------------------------------------------------------------------------- /HouseCleaning4/HouseCleaning4-backoffice/src/main/java/dja/housecleaning/backoffice/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.backoffice; -------------------------------------------------------------------------------- /things/src/main/java/other/things/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | /** 5 | * @author milen 6 | * 7 | */ 8 | package other.things; -------------------------------------------------------------------------------- /HouseCleaning4/HouseCleaning4-frontoffice/src/main/java/dja/housecleaning/frontoffice/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.frontoffice; -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-company/src/main/java/dja/housecleaning/company/assets/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.company.assets; -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-company/src/main/java/dja/housecleaning/company/shared/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.company.shared; -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-company/src/main/java/dja/housecleaning/company/staff/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.company.staff; -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-frontoffice/src/main/java/dja/housecleaning/frontoffice/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.frontoffice; -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/shared/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.company.shared; -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-frontoffice/src/main/java/dja/housecleaning/frontoffice/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.frontoffice; -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/shared/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.company.shared; -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-frontoffice/src/main/java/dja/housecleaning/frontoffice/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.frontoffice; -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-company/src/main/java/dja/housecleaning/company/processes/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.company.processes; -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/processes/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.company.processes; -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/processes/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.company.processes; -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-company/src/main/java/dja/housecleaning/company/jobpositions/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.company.jobpositions; -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/jobpositions/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.company.jobpositions; -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/jobpositions/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.company.jobpositions; -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/internal/assets/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.company.internal.assets; -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/internal/shared/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.company.internal.shared; -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/internal/staff/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.company.internal.staff; -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/internal/assets/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.company.internal.assets; -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/internal/shared/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.company.internal.shared; -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/internal/staff/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.company.internal.staff; -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-frontoffice/src/main/java/dja/housecleaning/frontoffice/internal/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.frontoffice.internal; -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/internal/assets/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.company.internal.assets; -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/internal/shared/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.company.internal.shared; -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/internal/staff/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.company.internal.staff; -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-frontoffice/src/main/java/dja/housecleaning/frontoffice/internal/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.frontoffice.internal; -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/internal/processes/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.company.internal.processes; -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/internal/processes/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package dja.housecleaning.company.internal.processes; -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-client/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module dja.housecleaning.client { 2 | 3 | requires dja.housecleaning.frontoffice; 4 | requires jline; 5 | } -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-frontoffice/src/main/java/dja/housecleaning/frontoffice/internal/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | /** 5 | * @author milen 6 | * 7 | */ 8 | package dja.housecleaning.frontoffice.internal; -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-frontoffice/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | 2 | module dja.housecleaning.frontoffice { 3 | exports dja.housecleaning.frontoffice; 4 | 5 | requires dja.housecleaning.usecases; 6 | requires joda.money; 7 | } -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-frontoffice/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | module dja.housecleaning.frontoffice { 4 | exports dja.housecleaning.frontoffice; 5 | 6 | requires dja.housecleaning.usecases; 7 | requires joda.money; 8 | } -------------------------------------------------------------------------------- /things/src/main/java/other/things/CleaningSupplyStore.java: -------------------------------------------------------------------------------- 1 | package other.things; 2 | 3 | public class CleaningSupplyStore { 4 | 5 | public static CleaningSupply purchase(String name) { 6 | return new CleaningSupply(name); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-client/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module dja.housecleaning.client { 2 | 3 | requires dja.housecleaning.frontoffice; 4 | requires jline; 5 | // requires dja.housecleaning.company; 6 | // requires things; 7 | } -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-usecases/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | 2 | module dja.housecleaning.usecases { 3 | exports dja.housecleaning.usecases; 4 | 5 | requires dja.housecleaning.company; 6 | requires joda.money; 7 | requires things; 8 | 9 | } -------------------------------------------------------------------------------- /HouseCleaning8/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../java_version.sh 4 | . ../run_functions.sh 5 | 6 | modules=( 7 | './HouseCleaning8-run/target/housecleaning-client.jar' 8 | ) 9 | mainClass="aQute.launcher.pre.EmbeddedLauncher" 10 | 11 | run $1 12 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-company/src/main/java/dja/housecleaning/company/assets/Vehicles.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.assets; 2 | 3 | import other.things.Van; 4 | 5 | public class Vehicles { 6 | 7 | public static final Van companyVan = new Van(); 8 | } 9 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/shared/package-info.java: -------------------------------------------------------------------------------- 1 | @Export 2 | @Version("1.0.0") 3 | package dja.housecleaning.company.shared; 4 | 5 | import org.osgi.annotation.versioning.Version; 6 | import aQute.bnd.annotation.Export; 7 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-frontoffice/src/main/java/dja/housecleaning/frontoffice/package-info.java: -------------------------------------------------------------------------------- 1 | @Version("1.0.0") 2 | @Export 3 | package dja.housecleaning.frontoffice; 4 | 5 | import org.osgi.annotation.versioning.Version; 6 | 7 | import aQute.bnd.annotation.Export; 8 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/internal/assets/Vehicles.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.assets; 2 | 3 | import other.things.Van; 4 | 5 | public class Vehicles { 6 | 7 | public static final Van companyVan = new Van(); 8 | } 9 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/internal/assets/Vehicles.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.assets; 2 | 3 | import other.things.Van; 4 | 5 | public class Vehicles { 6 | 7 | public static final Van companyVan = new Van(); 8 | } 9 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/internal/assets/Vehicles.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.assets; 2 | 3 | import other.things.Van; 4 | 5 | public class Vehicles { 6 | 7 | public static final Van companyVan = new Van(); 8 | } 9 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/jobpositions/package-info.java: -------------------------------------------------------------------------------- 1 | @Export 2 | @Version("1.0.0") 3 | package dja.housecleaning.company.jobpositions; 4 | 5 | import org.osgi.annotation.versioning.Version; 6 | import aQute.bnd.annotation.Export; 7 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-company/src/main/java/dja/housecleaning/company/jobpositions/Accountant.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.jobpositions; 2 | 3 | import org.joda.money.Money; 4 | 5 | public interface Accountant { 6 | 7 | void recordIncome(Money money); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-company/src/main/java/dja/housecleaning/company/shared/PricingPolicy.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.shared; 2 | 3 | import org.joda.money.Money; 4 | 5 | public interface PricingPolicy { 6 | 7 | public Money sevicePrice = Money.parse("EUR 100"); 8 | } 9 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/jobpositions/Accountant.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.jobpositions; 2 | 3 | import org.joda.money.Money; 4 | 5 | public interface Accountant { 6 | 7 | void recordIncome(Money money); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/jobpositions/Accountant.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.jobpositions; 2 | 3 | import org.joda.money.Money; 4 | 5 | public interface Accountant { 6 | 7 | void recordIncome(Money money); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/jobpositions/Accountant.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.jobpositions; 2 | 3 | import org.joda.money.Money; 4 | 5 | public interface Accountant { 6 | 7 | void recordIncome(Money money); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /HouseCleaning1/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | modules=( 4 | './target/HouseCleaning1-0.0.1-SNAPSHOT.jar' 5 | "$HOME/.m2/repository/org/jline/jline/3.7.0/jline-3.7.0.jar" 6 | '../things/target/things-0.0.1-SNAPSHOT.jar' 7 | ) 8 | 9 | . ../java_version.sh 10 | . ../run_functions.sh 11 | 12 | run $1 -------------------------------------------------------------------------------- /HouseCleaning2/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | modules=( 4 | './target/HouseCleaning2-0.0.1-SNAPSHOT.jar' 5 | "$HOME/.m2/repository/org/jline/jline/3.7.0/jline-3.7.0.jar" 6 | '../things/target/things-0.0.1-SNAPSHOT.jar' 7 | ) 8 | 9 | . ../java_version.sh 10 | . ../run_functions.sh 11 | 12 | run $1 -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/internal/shared/PricingPolicy.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.shared; 2 | 3 | import org.joda.money.Money; 4 | 5 | public interface PricingPolicy { 6 | 7 | public Money sevicePrice = Money.parse("EUR 100"); 8 | } 9 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | 2 | module dja.housecleaning.company { 3 | exports dja.housecleaning.company.jobpositions; 4 | exports dja.housecleaning.company.processes; 5 | exports dja.housecleaning.company.shared; 6 | 7 | requires joda.money; 8 | requires things; 9 | } -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/internal/shared/PricingPolicy.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.shared; 2 | 3 | import org.joda.money.Money; 4 | 5 | public interface PricingPolicy { 6 | 7 | public Money sevicePrice = Money.parse("EUR 100"); 8 | } 9 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/internal/shared/PricingPolicy.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.shared; 2 | 3 | import org.joda.money.Money; 4 | 5 | public interface PricingPolicy { 6 | 7 | public Money sevicePrice = Money.parse("EUR 100"); 8 | } 9 | -------------------------------------------------------------------------------- /java_version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | JAVA_HOME=$JAVA_HOME 4 | PATH=$PATH 5 | 6 | function setJavaVersion () { 7 | VERSION=$1; 8 | # Mac OS only! Please atapt for your own OS 9 | JAVA_HOME="`/usr/libexec/java_home -v $VERSION`"; 10 | PATH="`/usr/libexec/java_home -v $VERSION`/bin:$PATH"; 11 | } 12 | 13 | 14 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-company/src/main/java/dja/housecleaning/company/assets/Software.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.assets; 2 | 3 | import other.things.BookkeepingSystem; 4 | 5 | public class Software { 6 | public static final BookkeepingSystem companyBookkepingsystem = new BookkeepingSystem(); 7 | 8 | } 9 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-usecases/src/main/java/dja/housecleaning/usecases/package-info.java: -------------------------------------------------------------------------------- 1 | @Version("1.0.0") 2 | //@Version("1.1.0") 3 | //@Version("2.0.0") 4 | @Export 5 | package dja.housecleaning.usecases; 6 | 7 | import org.osgi.annotation.versioning.Version; 8 | 9 | import aQute.bnd.annotation.Export; 10 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/internal/assets/Software.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.assets; 2 | 3 | import other.things.BookkeepingSystem; 4 | 5 | public class Software { 6 | public static final BookkeepingSystem companyBookkepingsystem = new BookkeepingSystem(); 7 | 8 | } 9 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/internal/assets/Software.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.assets; 2 | 3 | import other.things.BookkeepingSystem; 4 | 5 | public class Software { 6 | public static final BookkeepingSystem companyBookkepingsystem = new BookkeepingSystem(); 7 | 8 | } 9 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/internal/assets/Software.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.assets; 2 | 3 | import other.things.BookkeepingSystem; 4 | 5 | public class Software { 6 | public static final BookkeepingSystem companyBookkepingsystem = new BookkeepingSystem(); 7 | 8 | } 9 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/processes/package-info.java: -------------------------------------------------------------------------------- 1 | @Version("1.0.0") 2 | //@Version("1.0.1") 3 | //@Version("1.1.0") 4 | @Export 5 | package dja.housecleaning.company.processes; 6 | 7 | import org.osgi.annotation.versioning.Version; 8 | 9 | import aQute.bnd.annotation.Export; 10 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-company/src/main/java/dja/housecleaning/company/jobpositions/Cleaner.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.jobpositions; 2 | 3 | import dja.housecleaning.company.shared.CleaningInstructions; 4 | 5 | public interface Cleaner { 6 | 7 | public void cleanHouse (CleaningInstructions instructions); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/jobpositions/Cleaner.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.jobpositions; 2 | 3 | import dja.housecleaning.company.shared.CleaningInstructions; 4 | 5 | public interface Cleaner { 6 | 7 | public void cleanHouse (CleaningInstructions instructions); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/jobpositions/Cleaner.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.jobpositions; 2 | 3 | import dja.housecleaning.company.shared.CleaningInstructions; 4 | 5 | public interface Cleaner { 6 | 7 | public void cleanHouse (CleaningInstructions instructions); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/jobpositions/Cleaner.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.jobpositions; 2 | 3 | import dja.housecleaning.company.shared.CleaningInstructions; 4 | 5 | public interface Cleaner { 6 | 7 | public void cleanHouse (CleaningInstructions instructions); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/shared/CleaningInstructions.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.shared; 2 | 3 | import java.util.List; 4 | 5 | public interface CleaningInstructions { 6 | 7 | public String getAddress(); 8 | 9 | public List getInstructions(); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/shared/CleaningInstructions.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.shared; 2 | 3 | import java.util.List; 4 | 5 | public interface CleaningInstructions { 6 | 7 | public String getAddress(); 8 | 9 | public List getInstructions(); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/shared/CleaningInstructions.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.shared; 2 | 3 | import java.util.List; 4 | 5 | public interface CleaningInstructions { 6 | 7 | public String getAddress(); 8 | 9 | public List getInstructions(); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /things/src/main/java/other/things/BookkeepingSystem.java: -------------------------------------------------------------------------------- 1 | package other.things; 2 | 3 | public class BookkeepingSystem { 4 | 5 | public void recordIncome (double income) { 6 | System.out.println("📗 : Recorded income" ); 7 | } 8 | 9 | public void recordExpense (double expense) { 10 | System.out.println("📕 : Recorded expense" ); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /things/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | other 4 | things 5 | 0.0.1-SNAPSHOT 6 | -------------------------------------------------------------------------------- /HouseCleaning4/HouseCleaning4-company/src/main/java/dja/housecleaning/Garage.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning; 2 | 3 | import other.things.Van; 4 | 5 | class Garage { 6 | 7 | private Van myVan = new Van(); 8 | 9 | static final Garage PLACE = new Garage(); 10 | 11 | private Garage() { 12 | } 13 | 14 | Van getVan() { 15 | return myVan; 16 | } 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /things/src/main/java/other/things/CleaningTool.java: -------------------------------------------------------------------------------- 1 | package other.things; 2 | 3 | public class CleaningTool { 4 | 5 | String name; 6 | 7 | public String getName() { 8 | return name; 9 | } 10 | 11 | public CleaningTool(String name) { 12 | this.name = name; 13 | } 14 | 15 | @Override 16 | public String toString() { 17 | return getName(); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-run/housecleaning-client.bndrun: -------------------------------------------------------------------------------- 1 | -runfw: org.apache.felix.framework;version='[5,6)' 2 | -runee: JavaSE-1.8 3 | 4 | -runrequires:\ 5 | osgi.identity;filter:='(osgi.identity=HouseCleaning8-client)',\ 6 | osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.jline)',\ 7 | osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.command)' 8 | -------------------------------------------------------------------------------- /HouseCleaning3/HouseCleaning3-assets/src/main/java/dja/housecleaning/assets/Garage.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.assets; 2 | 3 | import other.things.Van; 4 | 5 | public class Garage { 6 | 7 | private Van myVan = new Van(); 8 | 9 | public static final Garage PLACE = new Garage(); 10 | 11 | private Garage() { 12 | } 13 | 14 | public Van getVan() { 15 | return myVan; 16 | } 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-uber-transport/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | import dja.housecleaning.company.internal.processes.uber.transport.UberTransportProcess; 2 | import dja.housecleaning.company.processes.TransportProcess; 3 | 4 | module dja.housecleaning.uber.transport { 5 | 6 | requires dja.housecleaning.company; 7 | requires things; 8 | 9 | provides TransportProcess with UberTransportProcess; 10 | 11 | } -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/processes/CleanHouseProcess.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.processes; 2 | 3 | import dja.housecleaning.company.jobpositions.Cleaner; 4 | import dja.housecleaning.company.shared.CleaningInstructions; 5 | 6 | public interface CleanHouseProcess { 7 | 8 | void cleanHouse(Cleaner cleaner, CleaningInstructions cleaningInstructions); 9 | 10 | } -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-usecases/src/main/java/dja/housecleaning/usecases/CleaningRequest.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.usecases; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | 7 | public interface CleaningRequest { 8 | 9 | String getAddress (); 10 | 11 | Money getPayment(); 12 | 13 | List getInstructions (); 14 | 15 | void fixPayment(Money expected, Money received); 16 | } 17 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-usecases/src/main/java/dja/housecleaning/usecases/CleaningRequest.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.usecases; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | 7 | public interface CleaningRequest { 8 | 9 | String getAddress (); 10 | 11 | Money getPayment(); 12 | 13 | List getInstructions (); 14 | 15 | void fixPayment(Money expected, Money received); 16 | } 17 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-usecases/src/main/java/dja/housecleaning/usecases/CleaningRequest.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.usecases; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | 7 | public interface CleaningRequest { 8 | 9 | String getAddress (); 10 | 11 | Money getPayment(); 12 | 13 | List getInstructions (); 14 | 15 | void fixPayment(Money expected, Money received); 16 | } 17 | -------------------------------------------------------------------------------- /things/src/main/java/other/things/CleaningSupply.java: -------------------------------------------------------------------------------- 1 | package other.things; 2 | 3 | public class CleaningSupply { 4 | 5 | String name; 6 | 7 | public CleaningSupply(String name) { 8 | this.name = name; 9 | } 10 | 11 | public String getName() { 12 | return name; 13 | } 14 | 15 | public boolean isEmpty () { 16 | return false; 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | return getName(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/shared/CleaningInstruction.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.shared; 2 | 3 | import java.util.List; 4 | 5 | public interface CleaningInstruction { 6 | 7 | public enum Room { 8 | KITCHEN, BEDROOM, LIVINGROOM, BATHROOM 9 | } 10 | 11 | public enum Service { 12 | vacuumTheFloor, washTheFloor, wipeTheDust 13 | } 14 | 15 | public Room getRoom(); 16 | public List getToDo(); 17 | } 18 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/shared/CleaningInstruction.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.shared; 2 | 3 | import java.util.List; 4 | 5 | public interface CleaningInstruction { 6 | 7 | public enum Room { 8 | KITCHEN, BEDROOM, LIVINGROOM, BATHROOM 9 | } 10 | 11 | public enum Service { 12 | vacuumTheFloor, washTheFloor, wipeTheDust 13 | } 14 | 15 | public Room getRoom(); 16 | public List getToDo(); 17 | } 18 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/shared/CleaningInstruction.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.shared; 2 | 3 | import java.util.List; 4 | 5 | public interface CleaningInstruction { 6 | 7 | public enum Room { 8 | KITCHEN, BEDROOM, LIVINGROOM, BATHROOM 9 | } 10 | 11 | public enum Service { 12 | vacuumTheFloor, washTheFloor, wipeTheDust 13 | } 14 | 15 | public Room getRoom(); 16 | public List getToDo(); 17 | } 18 | -------------------------------------------------------------------------------- /things/src/main/java/other/things/Van.java: -------------------------------------------------------------------------------- 1 | package other.things; 2 | 3 | import java.util.List; 4 | 5 | public class Van { 6 | 7 | 8 | public void drive (String place) { 9 | System.out.println("🚚 : Going to " + place); 10 | } 11 | 12 | public void load (List things) { 13 | System.out.println("🚚 : Loaded " + things ); 14 | } 15 | 16 | public void addPassenger (Object person) { 17 | System.out.println("🚚 : passenger " + person ); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-company/src/main/java/dja/housecleaning/company/processes/CleanHouseProcess.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.processes; 2 | 3 | import dja.housecleaning.company.jobpositions.Cleaner; 4 | import dja.housecleaning.company.shared.CleaningInstructions; 5 | 6 | public class CleanHouseProcess { 7 | 8 | 9 | public void cleanHouse (Cleaner cleaner, CleaningInstructions cleaningInstructions) { 10 | 11 | cleaner.cleanHouse(cleaningInstructions); 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/processes/CleanHouseProcess.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.processes; 2 | 3 | import dja.housecleaning.company.jobpositions.Cleaner; 4 | import dja.housecleaning.company.shared.CleaningInstructions; 5 | 6 | public class CleanHouseProcess { 7 | 8 | 9 | public void cleanHouse (Cleaner cleaner, CleaningInstructions cleaningInstructions) { 10 | 11 | cleaner.cleanHouse(cleaningInstructions); 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/processes/CleanHouseProcess.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.processes; 2 | 3 | import org.osgi.annotation.versioning.ProviderType; 4 | 5 | import dja.housecleaning.company.jobpositions.Cleaner; 6 | import dja.housecleaning.company.shared.CleaningInstructions; 7 | 8 | @ProviderType 9 | public interface CleanHouseProcess { 10 | 11 | void cleanHouse(Cleaner cleaner, CleaningInstructions cleaningInstructions); 12 | 13 | } -------------------------------------------------------------------------------- /HouseCleaning3/HouseCleaning3-assets/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | decomposing.java.apps 7 | HouseCleaning3 8 | 0.0.1-SNAPSHOT 9 | 10 | HouseCleaning3-assets 11 | -------------------------------------------------------------------------------- /HouseCleaning4/HouseCleaning4-backoffice/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | decomposing.java.apps 5 | HouseCleaning4 6 | 0.0.1-SNAPSHOT 7 | 8 | HouseCleaning4-backoffice 9 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | decomposing.java.apps 7 | HouseCleaning6 8 | 0.0.1-SNAPSHOT 9 | 10 | HouseCleaning6-company 11 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | decomposing.java.apps 7 | HouseCleaning7 8 | 0.0.1-SNAPSHOT 9 | 10 | HouseCleaning7-company 11 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-company/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | decomposing.java.apps 7 | HouseCleaning5 8 | 0.0.1-SNAPSHOT 9 | 10 | HouseCleaning5-company 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-usecases/src/main/java/dja/housecleaning/usecases/CleaningRequest.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.usecases; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | import org.osgi.annotation.versioning.ConsumerType; 7 | 8 | @ConsumerType 9 | public interface CleaningRequest { 10 | 11 | String getAddress (); 12 | 13 | Money getPayment(); 14 | 15 | List getInstructions (); 16 | 17 | void fixPayment(Money expected, Money received); 18 | 19 | // String getCustomerName(); 20 | } 21 | -------------------------------------------------------------------------------- /HouseCleaning2/src/main/java/dja/housecleaning/OrderForm.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning; 2 | 3 | public class OrderForm { 4 | 5 | String address; 6 | 7 | String instructions; 8 | 9 | 10 | public String getAddress() { 11 | return address; 12 | } 13 | 14 | public void setAddress(String address) { 15 | this.address = address; 16 | } 17 | 18 | public String getInstructions() { 19 | return instructions; 20 | } 21 | 22 | public void setInstructions(String instructions) { 23 | this.instructions = instructions; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/processes/TransportProcess.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.processes; 2 | 3 | import java.util.List; 4 | 5 | import dja.housecleaning.company.jobpositions.Cleaner; 6 | import other.things.CleaningSupply; 7 | import other.things.CleaningTool; 8 | 9 | public interface TransportProcess { 10 | 11 | boolean isCurrentlyAvailable(); 12 | 13 | void goTo(String address, Cleaner cleaner, List supplies, List tools); 14 | 15 | int priority (); 16 | } -------------------------------------------------------------------------------- /HouseCleaning3/HouseCleaning3-front/src/main/java/dja/housecleaning/front/OrderForm.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.front; 2 | 3 | public class OrderForm { 4 | 5 | String address; 6 | 7 | String instructions; 8 | 9 | 10 | public String getAddress() { 11 | return address; 12 | } 13 | 14 | public void setAddress(String address) { 15 | this.address = address; 16 | } 17 | 18 | public String getInstructions() { 19 | return instructions; 20 | } 21 | 22 | public void setInstructions(String instructions) { 23 | this.instructions = instructions; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /HouseCleaning4/HouseCleaning4-frontoffice/src/main/java/dja/housecleaning/frontoffice/OrderForm.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.frontoffice; 2 | 3 | public class OrderForm { 4 | 5 | String address; 6 | 7 | String instructions; 8 | 9 | 10 | public String getAddress() { 11 | return address; 12 | } 13 | 14 | public void setAddress(String address) { 15 | this.address = address; 16 | } 17 | 18 | public String getInstructions() { 19 | return instructions; 20 | } 21 | 22 | public void setInstructions(String instructions) { 23 | this.instructions = instructions; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/processes/NewOrderProcess.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.processes; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | 7 | import dja.housecleaning.company.shared.CleaningInstructions; 8 | import dja.housecleaning.company.shared.InsufficientAmountException; 9 | 10 | public interface NewOrderProcess { 11 | 12 | void checkPayment (Money money) throws InsufficientAmountException; 13 | 14 | CleaningInstructions prepareInstructions (String address, List clientInstructions); 15 | 16 | } -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/internal/shared/InternalCleaningInstruction.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.shared; 2 | 3 | import java.util.List; 4 | 5 | import dja.housecleaning.company.shared.CleaningInstruction; 6 | 7 | public class InternalCleaningInstruction implements CleaningInstruction { 8 | 9 | public Room room; 10 | 11 | public List todo; 12 | 13 | @Override 14 | public Room getRoom() { 15 | return room; 16 | } 17 | 18 | @Override 19 | public List getToDo() { 20 | return todo; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/internal/shared/InternalCleaningInstruction.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.shared; 2 | 3 | import java.util.List; 4 | 5 | import dja.housecleaning.company.shared.CleaningInstruction; 6 | 7 | public class InternalCleaningInstruction implements CleaningInstruction { 8 | 9 | public Room room; 10 | 11 | public List todo; 12 | 13 | @Override 14 | public Room getRoom() { 15 | return room; 16 | } 17 | 18 | @Override 19 | public List getToDo() { 20 | return todo; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/internal/shared/InternalCleaningInstruction.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.shared; 2 | 3 | import java.util.List; 4 | 5 | import dja.housecleaning.company.shared.CleaningInstruction; 6 | 7 | public class InternalCleaningInstruction implements CleaningInstruction { 8 | 9 | public Room room; 10 | 11 | public List todo; 12 | 13 | @Override 14 | public Room getRoom() { 15 | return room; 16 | } 17 | 18 | @Override 19 | public List getToDo() { 20 | return todo; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-company/src/main/java/dja/housecleaning/company/jobpositions/Receptionist.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.jobpositions; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | 7 | import dja.housecleaning.company.shared.CleaningInstructions; 8 | import dja.housecleaning.company.shared.InsufficientAmountException; 9 | 10 | public interface Receptionist { 11 | 12 | void recievePayment(Money money) throws InsufficientAmountException; 13 | 14 | CleaningInstructions prepareCleaningInstructions(String address, List instructions); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/jobpositions/Receptionist.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.jobpositions; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | 7 | import dja.housecleaning.company.shared.CleaningInstructions; 8 | import dja.housecleaning.company.shared.InsufficientAmountException; 9 | 10 | public interface Receptionist { 11 | 12 | void recievePayment(Money money) throws InsufficientAmountException; 13 | 14 | CleaningInstructions prepareCleaningInstructions(String address, List instructions); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/jobpositions/Receptionist.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.jobpositions; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | 7 | import dja.housecleaning.company.shared.CleaningInstructions; 8 | import dja.housecleaning.company.shared.InsufficientAmountException; 9 | 10 | public interface Receptionist { 11 | 12 | void recievePayment(Money money) throws InsufficientAmountException; 13 | 14 | CleaningInstructions prepareCleaningInstructions(String address, List instructions); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/jobpositions/Receptionist.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.jobpositions; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | 7 | import dja.housecleaning.company.shared.CleaningInstructions; 8 | import dja.housecleaning.company.shared.InsufficientAmountException; 9 | 10 | public interface Receptionist { 11 | 12 | void recievePayment(Money money) throws InsufficientAmountException; 13 | 14 | CleaningInstructions prepareCleaningInstructions(String address, List instructions); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /HouseCleaning3/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | modules=( 4 | './HouseCleaning3-client/target/HouseCleaning3-client-0.0.1-SNAPSHOT.jar' 5 | './HouseCleaning3-assets/target/HouseCleaning3-assets-0.0.1-SNAPSHOT.jar' 6 | './HouseCleaning3-front/target/HouseCleaning3-front-0.0.1-SNAPSHOT.jar' 7 | './HouseCleaning3-company/target/HouseCleaning3-company-0.0.1-SNAPSHOT.jar' 8 | "$HOME/.m2/repository/org/jline/jline/3.7.0/jline-3.7.0.jar" 9 | "$HOME/.m2/repository/org/joda/joda-money/0.12/joda-money-0.12.jar" 10 | '../things/target/things-0.0.1-SNAPSHOT.jar' 11 | ) 12 | 13 | . ../java_version.sh 14 | . ../run_functions.sh 15 | 16 | run $1 -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-company/src/main/java/dja/housecleaning/company/shared/InsufficientAmountException.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.shared; 2 | 3 | import org.joda.money.Money; 4 | 5 | public class InsufficientAmountException extends Exception { 6 | 7 | Money expected; 8 | 9 | Money received; 10 | 11 | public InsufficientAmountException(Money expected, Money received) { 12 | super(); 13 | this.expected = expected; 14 | this.received = received; 15 | } 16 | 17 | public Money getExpected() { 18 | return expected; 19 | } 20 | 21 | public Money getReceived() { 22 | return received; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/shared/InsufficientAmountException.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.shared; 2 | 3 | import org.joda.money.Money; 4 | 5 | public class InsufficientAmountException extends Exception { 6 | 7 | Money expected; 8 | 9 | Money received; 10 | 11 | public InsufficientAmountException(Money expected, Money received) { 12 | super(); 13 | this.expected = expected; 14 | this.received = received; 15 | } 16 | 17 | public Money getExpected() { 18 | return expected; 19 | } 20 | 21 | public Money getReceived() { 22 | return received; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/shared/InsufficientAmountException.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.shared; 2 | 3 | import org.joda.money.Money; 4 | 5 | public class InsufficientAmountException extends Exception { 6 | 7 | Money expected; 8 | 9 | Money received; 10 | 11 | public InsufficientAmountException(Money expected, Money received) { 12 | super(); 13 | this.expected = expected; 14 | this.received = received; 15 | } 16 | 17 | public Money getExpected() { 18 | return expected; 19 | } 20 | 21 | public Money getReceived() { 22 | return received; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-usecases/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | import dja.housecleaning.company.processes.CleanHouseProcess; 2 | import dja.housecleaning.company.processes.NewOrderProcess; 3 | import dja.housecleaning.company.processes.PrepareForCleaningProcess; 4 | import dja.housecleaning.company.processes.TransportProcess; 5 | 6 | module dja.housecleaning.usecases { 7 | exports dja.housecleaning.usecases; 8 | 9 | requires dja.housecleaning.company; 10 | requires joda.money; 11 | requires things; 12 | 13 | uses NewOrderProcess; 14 | uses CleanHouseProcess; 15 | uses TransportProcess; 16 | uses PrepareForCleaningProcess; 17 | } -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/shared/InsufficientAmountException.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.shared; 2 | 3 | import org.joda.money.Money; 4 | 5 | public class InsufficientAmountException extends Exception { 6 | 7 | Money expected; 8 | 9 | Money received; 10 | 11 | public InsufficientAmountException(Money expected, Money received) { 12 | super(); 13 | this.expected = expected; 14 | this.received = received; 15 | } 16 | 17 | public Money getExpected() { 18 | return expected; 19 | } 20 | 21 | public Money getReceived() { 22 | return received; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /HouseCleaning5/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | modules=( 4 | './HouseCleaning5-client/target/HouseCleaning5-client-0.0.1-SNAPSHOT.jar' 5 | './HouseCleaning5-frontoffice/target/HouseCleaning5-frontoffice-0.0.1-SNAPSHOT.jar' 6 | './HouseCleaning5-usecases/target/HouseCleaning5-usecases-0.0.1-SNAPSHOT.jar' 7 | './HouseCleaning5-company/target/HouseCleaning5-company-0.0.1-SNAPSHOT.jar' 8 | "$HOME/.m2/repository/org/jline/jline/3.7.0/jline-3.7.0.jar" 9 | "$HOME/.m2/repository/org/joda/joda-money/0.12/joda-money-0.12.jar" 10 | '../things/target/things-0.0.1-SNAPSHOT.jar' 11 | ) 12 | 13 | . ../java_version.sh 14 | . ../run_functions.sh 15 | 16 | run $1 -------------------------------------------------------------------------------- /HouseCleaning6/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | modules=( 4 | './HouseCleaning6-client/target/HouseCleaning6-client-0.0.1-SNAPSHOT.jar' 5 | './HouseCleaning6-frontoffice/target/HouseCleaning6-frontoffice-0.0.1-SNAPSHOT.jar' 6 | './HouseCleaning6-usecases/target/HouseCleaning6-usecases-0.0.1-SNAPSHOT.jar' 7 | './HouseCleaning6-company/target/HouseCleaning6-company-0.0.1-SNAPSHOT.jar' 8 | "$HOME/.m2/repository/org/jline/jline/3.7.0/jline-3.7.0.jar" 9 | "$HOME/.m2/repository/org/joda/joda-money/0.12/joda-money-0.12.jar" 10 | '../things/target/things-0.0.1-SNAPSHOT.jar' 11 | ) 12 | 13 | . ../java_version.sh 14 | . ../run_functions.sh 15 | 16 | run $1 -------------------------------------------------------------------------------- /HouseCleaning4/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | modules=( 4 | './HouseCleaning4-client/target/HouseCleaning4-client-0.0.1-SNAPSHOT.jar' 5 | './HouseCleaning4-backoffice/target/HouseCleaning4-backoffice-0.0.1-SNAPSHOT.jar' 6 | './HouseCleaning4-frontoffice/target/HouseCleaning4-frontoffice-0.0.1-SNAPSHOT.jar' 7 | './HouseCleaning4-company/target/HouseCleaning4-company-0.0.1-SNAPSHOT.jar' 8 | "$HOME/.m2/repository/org/jline/jline/3.7.0/jline-3.7.0.jar" 9 | "$HOME/.m2/repository/org/joda/joda-money/0.12/joda-money-0.12.jar" 10 | '../things/target/things-0.0.1-SNAPSHOT.jar' 11 | ) 12 | 13 | . ../java_version.sh 14 | . ../run_functions.sh 15 | 16 | run $1 -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-company/src/main/java/dja/housecleaning/company/shared/CleaningInstructions.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.shared; 2 | 3 | import java.util.LinkedList; 4 | import java.util.List; 5 | 6 | public class CleaningInstructions { 7 | 8 | public String address; 9 | 10 | public List instructions = new LinkedList<>(); 11 | 12 | public static class Instruction { 13 | public enum Room { 14 | KITCHEN, BEDROOM, LIVINGROOM, BATHROOM 15 | } 16 | public enum Service { 17 | vacuumTheFloor, washTheFloor, wipeTheDust 18 | } 19 | public Room room; 20 | public List what; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/internal/processes/InternalCleanHouseProcess.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.processes; 2 | 3 | import dja.housecleaning.company.jobpositions.Cleaner; 4 | import dja.housecleaning.company.processes.CleanHouseProcess; 5 | import dja.housecleaning.company.shared.CleaningInstructions; 6 | 7 | public class InternalCleanHouseProcess implements CleanHouseProcess { 8 | 9 | 10 | @Override 11 | public void cleanHouse (Cleaner cleaner, CleaningInstructions cleaningInstructions) { 12 | 13 | cleaner.cleanHouse(cleaningInstructions); 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/processes/NewOrderProcess.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.processes; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | import org.osgi.annotation.versioning.ProviderType; 7 | 8 | import dja.housecleaning.company.shared.CleaningInstructions; 9 | import dja.housecleaning.company.shared.InsufficientAmountException; 10 | 11 | @ProviderType 12 | public interface NewOrderProcess { 13 | 14 | void checkPayment (Money money) throws InsufficientAmountException; 15 | 16 | CleaningInstructions prepareInstructions (String address, List clientInstructions); 17 | 18 | } -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/processes/TransportProcess.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.processes; 2 | 3 | import java.util.List; 4 | 5 | import org.osgi.annotation.versioning.ProviderType; 6 | 7 | import dja.housecleaning.company.jobpositions.Cleaner; 8 | import other.things.CleaningSupply; 9 | import other.things.CleaningTool; 10 | 11 | @ProviderType 12 | public interface TransportProcess { 13 | 14 | boolean isCurrentlyAvailable(); 15 | 16 | void goTo(String address, Cleaner cleaner, List supplies, List tools); 17 | 18 | int priority (); 19 | 20 | // int status (); 21 | 22 | } -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-frontoffice/src/main/java/dja/housecleaning/frontoffice/OrderForm.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.frontoffice; 2 | 3 | import java.util.LinkedList; 4 | import java.util.List; 5 | 6 | public class OrderForm { 7 | 8 | String address; 9 | 10 | List instructions = new LinkedList<>(); 11 | 12 | 13 | public String getAddress() { 14 | return address; 15 | } 16 | 17 | public void setAddress(String address) { 18 | this.address = address; 19 | } 20 | 21 | public List getInstructions() { 22 | return instructions; 23 | } 24 | 25 | public void addInstruction(String instruction) { 26 | this.instructions.add(instruction); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-frontoffice/src/main/java/dja/housecleaning/frontoffice/OrderForm.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.frontoffice; 2 | 3 | import java.util.LinkedList; 4 | import java.util.List; 5 | 6 | public class OrderForm { 7 | 8 | String address; 9 | 10 | List instructions = new LinkedList<>(); 11 | 12 | 13 | public String getAddress() { 14 | return address; 15 | } 16 | 17 | public void setAddress(String address) { 18 | this.address = address; 19 | } 20 | 21 | public List getInstructions() { 22 | return instructions; 23 | } 24 | 25 | public void addInstruction(String instruction) { 26 | this.instructions.add(instruction); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-frontoffice/src/main/java/dja/housecleaning/frontoffice/OrderForm.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.frontoffice; 2 | 3 | import java.util.LinkedList; 4 | import java.util.List; 5 | 6 | public class OrderForm { 7 | 8 | String address; 9 | 10 | List instructions = new LinkedList<>(); 11 | 12 | 13 | public String getAddress() { 14 | return address; 15 | } 16 | 17 | public void setAddress(String address) { 18 | this.address = address; 19 | } 20 | 21 | public List getInstructions() { 22 | return instructions; 23 | } 24 | 25 | public void addInstruction(String instruction) { 26 | this.instructions.add(instruction); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-frontoffice/src/main/java/dja/housecleaning/frontoffice/OrderForm.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.frontoffice; 2 | 3 | import java.util.LinkedList; 4 | import java.util.List; 5 | 6 | public class OrderForm { 7 | 8 | String address; 9 | 10 | List instructions = new LinkedList<>(); 11 | 12 | 13 | public String getAddress() { 14 | return address; 15 | } 16 | 17 | public void setAddress(String address) { 18 | this.address = address; 19 | } 20 | 21 | public List getInstructions() { 22 | return instructions; 23 | } 24 | 25 | public void addInstruction(String instruction) { 26 | this.instructions.add(instruction); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-company/src/main/java/dja/housecleaning/company/jobpositions/Assistant.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.jobpositions; 2 | 3 | import java.util.List; 4 | 5 | import dja.housecleaning.company.shared.CleaningInstructions; 6 | import other.things.CleaningSupply; 7 | import other.things.CleaningTool; 8 | 9 | public interface Assistant { 10 | 11 | List getNeededCleaningSupplies(CleaningInstructions instructions); 12 | 13 | List getNeededCleaningTools(CleaningInstructions instructions); 14 | 15 | void storeCleaningTools(List cleaningTools); 16 | 17 | void storeCleaningSupplies(List cleaningSupplies); 18 | } 19 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/jobpositions/Assistant.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.jobpositions; 2 | 3 | import java.util.List; 4 | 5 | import dja.housecleaning.company.shared.CleaningInstructions; 6 | import other.things.CleaningSupply; 7 | import other.things.CleaningTool; 8 | 9 | public interface Assistant { 10 | 11 | List getNeededCleaningSupplies(CleaningInstructions instructions); 12 | 13 | List getNeededCleaningTools(CleaningInstructions instructions); 14 | 15 | void storeCleaningTools(List cleaningTools); 16 | 17 | void storeCleaningSupplies(List cleaningSupplies); 18 | } 19 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/jobpositions/Assistant.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.jobpositions; 2 | 3 | import java.util.List; 4 | 5 | import dja.housecleaning.company.shared.CleaningInstructions; 6 | import other.things.CleaningSupply; 7 | import other.things.CleaningTool; 8 | 9 | public interface Assistant { 10 | 11 | List getNeededCleaningSupplies(CleaningInstructions instructions); 12 | 13 | List getNeededCleaningTools(CleaningInstructions instructions); 14 | 15 | void storeCleaningTools(List cleaningTools); 16 | 17 | void storeCleaningSupplies(List cleaningSupplies); 18 | } 19 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/processes/PrepareForCleaningProcess.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.processes; 2 | 3 | import java.util.List; 4 | 5 | import dja.housecleaning.company.jobpositions.Cleaner; 6 | import dja.housecleaning.company.shared.CleaningInstructions; 7 | import other.things.CleaningSupply; 8 | import other.things.CleaningTool; 9 | 10 | public interface PrepareForCleaningProcess { 11 | 12 | Cleaner selectCleaner(CleaningInstructions instructions); 13 | 14 | List getCleaningSupplies (CleaningInstructions instructions); 15 | 16 | List getCleaningTools (CleaningInstructions instructions); 17 | } 18 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/jobpositions/Assistant.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.jobpositions; 2 | 3 | import java.util.List; 4 | 5 | import dja.housecleaning.company.shared.CleaningInstructions; 6 | import other.things.CleaningSupply; 7 | import other.things.CleaningTool; 8 | 9 | public interface Assistant { 10 | 11 | List getNeededCleaningSupplies(CleaningInstructions instructions); 12 | 13 | List getNeededCleaningTools(CleaningInstructions instructions); 14 | 15 | void storeCleaningTools(List cleaningTools); 16 | 17 | void storeCleaningSupplies(List cleaningSupplies); 18 | } 19 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/internal/processes/InternalCleanHouseProcess.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.processes; 2 | 3 | import org.osgi.service.component.annotations.Component; 4 | 5 | import dja.housecleaning.company.jobpositions.Cleaner; 6 | import dja.housecleaning.company.processes.CleanHouseProcess; 7 | import dja.housecleaning.company.shared.CleaningInstructions; 8 | 9 | @Component 10 | public class InternalCleanHouseProcess implements CleanHouseProcess { 11 | 12 | @Override 13 | public void cleanHouse (Cleaner cleaner, CleaningInstructions cleaningInstructions) { 14 | 15 | cleaner.cleanHouse(cleaningInstructions); 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /HouseCleaning3/HouseCleaning3-client/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | decomposing.java.apps 7 | HouseCleaning3 8 | 0.0.1-SNAPSHOT 9 | 10 | HouseCleaning3-client 11 | 12 | 13 | decomposing.java.apps 14 | HouseCleaning3-front 15 | 0.0.1-SNAPSHOT 16 | 17 | 18 | -------------------------------------------------------------------------------- /HouseCleaning3/HouseCleaning3-front/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | decomposing.java.apps 7 | HouseCleaning3 8 | 0.0.1-SNAPSHOT 9 | 10 | HouseCleaning3-front 11 | 12 | 13 | decomposing.java.apps 14 | HouseCleaning3-company 15 | 0.0.1-SNAPSHOT 16 | 17 | 18 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-other-things-bundle/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | decomposing.java.apps 5 | HouseCleaning8 6 | 0.0.1-SNAPSHOT 7 | 8 | HouseCleaning8-other-things-bundle 9 | 10 | 11 | other 12 | things 13 | 0.0.1-SNAPSHOT 14 | 15 | 16 | -------------------------------------------------------------------------------- /HouseCleaning3/HouseCleaning3-company/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | decomposing.java.apps 7 | HouseCleaning3 8 | 0.0.1-SNAPSHOT 9 | 10 | HouseCleaning3-company 11 | 12 | 13 | decomposing.java.apps 14 | HouseCleaning3-assets 15 | 0.0.1-SNAPSHOT 16 | 17 | 18 | -------------------------------------------------------------------------------- /HouseCleaning7/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | modules=( 4 | './HouseCleaning7-client/target/HouseCleaning7-client-0.0.1-SNAPSHOT.jar' 5 | './HouseCleaning7-frontoffice/target/HouseCleaning7-frontoffice-0.0.1-SNAPSHOT.jar' 6 | './HouseCleaning7-usecases/target/HouseCleaning7-usecases-0.0.1-SNAPSHOT.jar' 7 | './HouseCleaning7-company/target/HouseCleaning7-company-0.0.1-SNAPSHOT.jar' 8 | # './HouseCleaning7-uber-transport/target/HouseCleaning7-uber-transport-0.0.1-SNAPSHOT.jar' 9 | "$HOME/.m2/repository/org/joda/joda-money/0.12/joda-money-0.12.jar" 10 | "$HOME/.m2/repository/org/jline/jline/3.7.0/jline-3.7.0.jar" 11 | '../things/target/things-0.0.1-SNAPSHOT.jar' 12 | ) 13 | 14 | . ../java_version.sh 15 | . ../run_functions.sh 16 | 17 | run $1 18 | -------------------------------------------------------------------------------- /HouseCleaning4/HouseCleaning4-client/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | decomposing.java.apps 5 | HouseCleaning4 6 | 0.0.1-SNAPSHOT 7 | 8 | HouseCleaning4-client 9 | 10 | 11 | decomposing.java.apps 12 | HouseCleaning4-frontoffice 13 | 0.0.1-SNAPSHOT 14 | 15 | 16 | -------------------------------------------------------------------------------- /HouseCleaning4/HouseCleaning4-company/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | decomposing.java.apps 7 | HouseCleaning4 8 | 0.0.1-SNAPSHOT 9 | 10 | HouseCleaning4-company 11 | 12 | 13 | decomposing.java.apps 14 | HouseCleaning4-backoffice 15 | 0.0.1-SNAPSHOT 16 | 17 | 18 | -------------------------------------------------------------------------------- /HouseCleaning4/HouseCleaning4-frontoffice/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | decomposing.java.apps 7 | HouseCleaning4 8 | 0.0.1-SNAPSHOT 9 | 10 | HouseCleaning4-frontoffice 11 | 12 | 13 | decomposing.java.apps 14 | HouseCleaning4-company 15 | 0.0.1-SNAPSHOT 16 | 17 | 18 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-usecases/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | decomposing.java.apps 7 | HouseCleaning5 8 | 0.0.1-SNAPSHOT 9 | 10 | HouseCleaning5-usecases 11 | 12 | 13 | 14 | decomposing.java.apps 15 | HouseCleaning5-company 16 | 0.0.1-SNAPSHOT 17 | 18 | 19 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-usecases/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | decomposing.java.apps 7 | HouseCleaning6 8 | 0.0.1-SNAPSHOT 9 | 10 | HouseCleaning6-usecases 11 | 12 | 13 | 14 | decomposing.java.apps 15 | HouseCleaning6-company 16 | 0.0.1-SNAPSHOT 17 | 18 | 19 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-usecases/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | decomposing.java.apps 7 | HouseCleaning7 8 | 0.0.1-SNAPSHOT 9 | 10 | HouseCleaning7-usecases 11 | 12 | 13 | 14 | decomposing.java.apps 15 | HouseCleaning7-company 16 | 0.0.1-SNAPSHOT 17 | 18 | 19 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-frontoffice/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | decomposing.java.apps 7 | HouseCleaning5 8 | 0.0.1-SNAPSHOT 9 | 10 | HouseCleaning5-frontoffice 11 | 12 | 13 | 14 | decomposing.java.apps 15 | HouseCleaning5-usecases 16 | 0.0.1-SNAPSHOT 17 | 18 | 19 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-frontoffice/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | decomposing.java.apps 7 | HouseCleaning6 8 | 0.0.1-SNAPSHOT 9 | 10 | HouseCleaning6-frontoffice 11 | 12 | 13 | 14 | decomposing.java.apps 15 | HouseCleaning6-usecases 16 | 0.0.1-SNAPSHOT 17 | 18 | 19 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-frontoffice/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | decomposing.java.apps 7 | HouseCleaning7 8 | 0.0.1-SNAPSHOT 9 | 10 | HouseCleaning7-frontoffice 11 | 12 | 13 | 14 | decomposing.java.apps 15 | HouseCleaning7-usecases 16 | 0.0.1-SNAPSHOT 17 | 18 | 19 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-uber-transport/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | decomposing.java.apps 7 | HouseCleaning7 8 | 0.0.1-SNAPSHOT 9 | 10 | HouseCleaning7-uber-transport 11 | 12 | 13 | decomposing.java.apps 14 | HouseCleaning7-company 15 | 0.0.1-SNAPSHOT 16 | 17 | 18 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/processes/PrepareForCleaningProcess.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.processes; 2 | 3 | import java.util.List; 4 | 5 | import org.osgi.annotation.versioning.ProviderType; 6 | 7 | import dja.housecleaning.company.jobpositions.Cleaner; 8 | import dja.housecleaning.company.shared.CleaningInstructions; 9 | import other.things.CleaningSupply; 10 | import other.things.CleaningTool; 11 | 12 | @ProviderType 13 | public interface PrepareForCleaningProcess { 14 | 15 | Cleaner selectCleaner(CleaningInstructions instructions); 16 | 17 | List getCleaningSupplies (CleaningInstructions instructions); 18 | 19 | List getCleaningTools (CleaningInstructions instructions); 20 | } 21 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/internal/shared/InternalCleaningInstructions.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.shared; 2 | 3 | import java.util.LinkedList; 4 | import java.util.List; 5 | 6 | import dja.housecleaning.company.shared.CleaningInstruction; 7 | import dja.housecleaning.company.shared.CleaningInstructions; 8 | 9 | public class InternalCleaningInstructions implements CleaningInstructions { 10 | 11 | public String address; 12 | 13 | public List instructions = new LinkedList<>(); 14 | 15 | @Override 16 | public String getAddress() { 17 | return address; 18 | } 19 | 20 | @Override 21 | public List getInstructions() { 22 | return instructions; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/internal/shared/InternalCleaningInstructions.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.shared; 2 | 3 | import java.util.LinkedList; 4 | import java.util.List; 5 | 6 | import dja.housecleaning.company.shared.CleaningInstruction; 7 | import dja.housecleaning.company.shared.CleaningInstructions; 8 | 9 | public class InternalCleaningInstructions implements CleaningInstructions { 10 | 11 | public String address; 12 | 13 | public List instructions = new LinkedList<>(); 14 | 15 | @Override 16 | public String getAddress() { 17 | return address; 18 | } 19 | 20 | @Override 21 | public List getInstructions() { 22 | return instructions; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/internal/shared/InternalCleaningInstructions.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.shared; 2 | 3 | import java.util.LinkedList; 4 | import java.util.List; 5 | 6 | import dja.housecleaning.company.shared.CleaningInstruction; 7 | import dja.housecleaning.company.shared.CleaningInstructions; 8 | 9 | public class InternalCleaningInstructions implements CleaningInstructions { 10 | 11 | public String address; 12 | 13 | public List instructions = new LinkedList<>(); 14 | 15 | @Override 16 | public String getAddress() { 17 | return address; 18 | } 19 | 20 | @Override 21 | public List getInstructions() { 22 | return instructions; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-company/src/main/java/dja/housecleaning/company/staff/Staff.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.staff; 2 | 3 | import dja.housecleaning.company.jobpositions.Accountant; 4 | import dja.housecleaning.company.jobpositions.Assistant; 5 | import dja.housecleaning.company.jobpositions.Cleaner; 6 | import dja.housecleaning.company.jobpositions.Receptionist; 7 | 8 | public class Staff { 9 | 10 | public static final Staff ALL = new Staff(); 11 | 12 | private Staff() { 13 | } 14 | 15 | public Receptionist getReceptionist() { 16 | return Ronald.PERSON; 17 | } 18 | 19 | public Accountant getAccountant() { 20 | return Harry.PERSON; 21 | } 22 | 23 | public Assistant getAssistant() { 24 | return Andrey.PERSON; 25 | } 26 | 27 | public Cleaner getCleaner() { 28 | return Harry.PERSON; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-company/src/main/java/dja/housecleaning/company/processes/TransportProcess.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.processes; 2 | 3 | import java.util.List; 4 | 5 | import dja.housecleaning.company.assets.Vehicles; 6 | import dja.housecleaning.company.jobpositions.Cleaner; 7 | import other.things.CleaningSupply; 8 | import other.things.CleaningTool; 9 | import other.things.Van; 10 | 11 | public class TransportProcess { 12 | 13 | private Van companyVan; 14 | 15 | public TransportProcess() { 16 | companyVan = Vehicles.companyVan; 17 | } 18 | 19 | public void goTo(String address, Cleaner cleaner, List supplies, List tools) { 20 | companyVan.load(supplies); 21 | companyVan.load(tools); 22 | companyVan.addPassenger(cleaner); 23 | companyVan.drive(address); 24 | } 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/internal/staff/Staff.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.staff; 2 | 3 | import dja.housecleaning.company.jobpositions.Accountant; 4 | import dja.housecleaning.company.jobpositions.Assistant; 5 | import dja.housecleaning.company.jobpositions.Cleaner; 6 | import dja.housecleaning.company.jobpositions.Receptionist; 7 | 8 | public class Staff { 9 | 10 | public static final Staff ALL = new Staff(); 11 | 12 | private Staff() { 13 | } 14 | 15 | public Receptionist getReceptionist() { 16 | return Ronald.PERSON; 17 | } 18 | 19 | public Accountant getAccountant() { 20 | return Harry.PERSON; 21 | } 22 | 23 | public Assistant getAssistant() { 24 | return Andrey.PERSON; 25 | } 26 | 27 | public Cleaner getCleaner() { 28 | return Harry.PERSON; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/internal/staff/Staff.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.staff; 2 | 3 | import dja.housecleaning.company.jobpositions.Accountant; 4 | import dja.housecleaning.company.jobpositions.Assistant; 5 | import dja.housecleaning.company.jobpositions.Cleaner; 6 | import dja.housecleaning.company.jobpositions.Receptionist; 7 | 8 | public class Staff { 9 | 10 | public static final Staff ALL = new Staff(); 11 | 12 | private Staff() { 13 | } 14 | 15 | public Receptionist getReceptionist() { 16 | return Ronald.PERSON; 17 | } 18 | 19 | public Accountant getAccountant() { 20 | return Harry.PERSON; 21 | } 22 | 23 | public Assistant getAssistant() { 24 | return Andrey.PERSON; 25 | } 26 | 27 | public Cleaner getCleaner() { 28 | return Harry.PERSON; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/internal/staff/Staff.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.staff; 2 | 3 | import dja.housecleaning.company.jobpositions.Accountant; 4 | import dja.housecleaning.company.jobpositions.Assistant; 5 | import dja.housecleaning.company.jobpositions.Cleaner; 6 | import dja.housecleaning.company.jobpositions.Receptionist; 7 | 8 | public class Staff { 9 | 10 | public static final Staff ALL = new Staff(); 11 | 12 | private Staff() { 13 | } 14 | 15 | public Receptionist getReceptionist() { 16 | return Ronald.PERSON; 17 | } 18 | 19 | public Accountant getAccountant() { 20 | return Harry.PERSON; 21 | } 22 | 23 | public Assistant getAssistant() { 24 | return Andrey.PERSON; 25 | } 26 | 27 | public Cleaner getCleaner() { 28 | return Harry.PERSON; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-client/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | decomposing.java.apps 7 | HouseCleaning5 8 | 0.0.1-SNAPSHOT 9 | 10 | HouseCleaning5-client 11 | 12 | 13 | decomposing.java.apps 14 | HouseCleaning5-frontoffice 15 | 0.0.1-SNAPSHOT 16 | 17 | 18 | org.jline 19 | jline 20 | 3.7.0 21 | 22 | 23 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-client/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | decomposing.java.apps 7 | HouseCleaning6 8 | 0.0.1-SNAPSHOT 9 | 10 | HouseCleaning6-client 11 | 12 | 13 | decomposing.java.apps 14 | HouseCleaning6-frontoffice 15 | 0.0.1-SNAPSHOT 16 | 17 | 18 | org.jline 19 | jline 20 | 3.7.0 21 | 22 | 23 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-client/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | decomposing.java.apps 7 | HouseCleaning7 8 | 0.0.1-SNAPSHOT 9 | 10 | HouseCleaning7-client 11 | 12 | 13 | decomposing.java.apps 14 | HouseCleaning7-frontoffice 15 | 0.0.1-SNAPSHOT 16 | 17 | 18 | org.jline 19 | jline 20 | 3.7.0 21 | 22 | 23 | -------------------------------------------------------------------------------- /run_functions.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | module="dja.housecleaning.client" 4 | mainClass="dja.housecleaning.client.Client" 5 | 6 | function buildClassPath () { 7 | classpath=$(IFS=: ; echo "${modules[*]}") 8 | } 9 | 10 | function run () { 11 | buildClassPath; 12 | OPTION=$1; 13 | case $OPTION in 14 | 15 | "j8") 16 | setJavaVersion "1.8" ; 17 | java -cp $classpath $mainClass 18 | ;; 19 | 20 | "j9c") 21 | setJavaVersion "9" ; 22 | java -cp $classpath $mainClass 23 | ;; 24 | 25 | "j9m") 26 | setJavaVersion "9" ; 27 | java -p $classpath -m $module/$mainClass 28 | ;; 29 | 30 | "j10c") 31 | setJavaVersion "10" ; 32 | java -cp $classpath $mainClass 33 | ;; 34 | 35 | "j10m") 36 | setJavaVersion "10" ; 37 | java -p $classpath -m $module/$mainClass 38 | ;; 39 | 40 | *) 41 | echo "please specify correct run option (j8, j9c, j9m, j10c or j10m)" 42 | esac; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /HouseCleaning1/README.md: -------------------------------------------------------------------------------- 1 | # House cleaning 1 2 | 3 | ## The company structure 4 | 5 | In this example, [Harry](src/main/java/dja/housecleaning/Harry.java) is a one person company. 6 | 7 | He owns a van and some cleaning tools and supplies and he does everything himself, from talks to customers through actual cleaning to bookkeeping. 8 | 9 | ## The PROs 10 | 11 | It's super simple. Harry is self sufficient. If something needs to change in the future, it's Harry. It's also convenient as there there is no clear distinction between Harry the person and Harry the company. So, for example, Harry can borrow his van and tools to his friends. 12 | 13 | ## The CONs 14 | 15 | This is not sustainable long term. If the company grows Harry would not be able to do everything by himself. Furthermore Harry is mixing company and personal activities. For example, if he borrows the van to a friend, his company is not functioning. 16 | 17 | -------------------------------------------------------------------------------- /HouseCleaning2/src/main/java/dja/housecleaning/Ronald.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning; 2 | 3 | import java.util.List; 4 | 5 | import other.things.CleaningTool; 6 | import other.things.Van; 7 | 8 | public class Ronald { 9 | 10 | public static final Ronald PERSON = new Ronald(); 11 | 12 | private Ronald() { 13 | } 14 | 15 | public void cleanMyHousePlease (OrderForm orderForm, double money) { 16 | System.out.println("Ronald: thank you for your order!"); 17 | Harry.PERSON.cleanHouseOrder(orderForm.getAddress(), orderForm.instructions, money); 18 | } 19 | 20 | public OrderForm getOrderForm () { 21 | return new OrderForm(); 22 | } 23 | 24 | public Van borrowVan (String who) { 25 | return Garage.PLACE.getVan(); 26 | } 27 | 28 | public List borrowTools (String who) { 29 | return Garage.PLACE.getCleaningTools(); 30 | } 31 | 32 | 33 | @Override 34 | public String toString() { 35 | return "Ronald"; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-client/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | decomposing.java.apps 7 | HouseCleaning8 8 | 0.0.1-SNAPSHOT 9 | 10 | HouseCleaning8-client 11 | 12 | 13 | 14 | decomposing.java.apps 15 | HouseCleaning8-frontoffice 16 | 0.0.1-SNAPSHOT 17 | 18 | 19 | 20 | 21 | 22 | 23 | biz.aQute.bnd 24 | bnd-baseline-maven-plugin 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-uber-transport/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | decomposing.java.apps 7 | HouseCleaning8 8 | 0.0.1-SNAPSHOT 9 | 10 | HouseCleaning8-uber-transport 11 | 12 | 13 | decomposing.java.apps 14 | HouseCleaning8-company 15 | 0.0.1-SNAPSHOT 16 | 17 | 18 | 19 | 20 | 21 | 22 | biz.aQute.bnd 23 | bnd-baseline-maven-plugin 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-uber-transport/src/main/java/dja/housecleaning/company/internal/processes/uber/transport/UberTransportProcess.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.processes.uber.transport; 2 | 3 | import java.util.List; 4 | 5 | import dja.housecleaning.company.jobpositions.Cleaner; 6 | import dja.housecleaning.company.processes.TransportProcess; 7 | import other.things.CleaningSupply; 8 | import other.things.CleaningTool; 9 | 10 | public class UberTransportProcess implements TransportProcess { 11 | 12 | @Override 13 | public void goTo(String address, Cleaner cleaner, List supplies, List tools) { 14 | 15 | System.out.println("🚗 : Order Uber Van!"); 16 | System.out.println("🚗 : Load supplies and tools"); 17 | System.out.println("🚗 : Go to " + address); 18 | 19 | } 20 | 21 | @Override 22 | public boolean isCurrentlyAvailable() { 23 | return true; 24 | } 25 | 26 | @Override 27 | public int priority() { 28 | return 100; 29 | } 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /HouseCleaning1/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | dja 6 | HouseCleaning1 7 | 0.0.1-SNAPSHOT 8 | 9 | 10 | 11 | other 12 | things 13 | 0.0.1-SNAPSHOT 14 | 15 | 16 | org.jline 17 | jline 18 | 3.7.0 19 | 20 | 21 | 22 | 23 | 24 | 25 | maven-compiler-plugin 26 | 3.7.0 27 | 28 | 1.8 29 | 1.8 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /HouseCleaning2/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | dja 6 | HouseCleaning2 7 | 0.0.1-SNAPSHOT 8 | 9 | 10 | 11 | other 12 | things 13 | 0.0.1-SNAPSHOT 14 | 15 | 16 | org.jline 17 | jline 18 | 3.7.0 19 | 20 | 21 | 22 | 23 | 24 | 25 | maven-compiler-plugin 26 | 3.7.0 27 | 28 | 1.8 29 | 1.8 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-usecases/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | decomposing.java.apps 7 | HouseCleaning8 8 | 0.0.1-SNAPSHOT 9 | 10 | HouseCleaning8-usecases 11 | 12 | 13 | 14 | 15 | 16 | decomposing.java.apps 17 | HouseCleaning8-company 18 | 0.0.1-SNAPSHOT 19 | 20 | 21 | 22 | 23 | 24 | 25 | biz.aQute.bnd 26 | bnd-baseline-maven-plugin 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-frontoffice/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | decomposing.java.apps 7 | HouseCleaning8 8 | 0.0.1-SNAPSHOT 9 | 10 | HouseCleaning8-frontoffice 11 | 12 | 13 | 14 | 15 | decomposing.java.apps 16 | HouseCleaning8-usecases 17 | 0.0.1-SNAPSHOT 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | biz.aQute.bnd 26 | bnd-baseline-maven-plugin 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-uber-transport/src/main/java/dja/housecleaning/company/internal/processes/uber/transport/UberTransportProcess.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.processes.uber.transport; 2 | 3 | import java.util.List; 4 | 5 | import org.osgi.service.component.annotations.Component; 6 | 7 | import dja.housecleaning.company.jobpositions.Cleaner; 8 | import dja.housecleaning.company.processes.TransportProcess; 9 | import other.things.CleaningSupply; 10 | import other.things.CleaningTool; 11 | 12 | @Component 13 | public class UberTransportProcess implements TransportProcess { 14 | 15 | @Override 16 | public void goTo(String address, Cleaner cleaner, List supplies, List tools) { 17 | 18 | System.out.println("🚗 : Order Uber Van!"); 19 | System.out.println("🚗 : Load supplies and tools"); 20 | System.out.println("🚗 : Go to " + address); 21 | 22 | } 23 | 24 | @Override 25 | public boolean isCurrentlyAvailable() { 26 | return true; 27 | } 28 | 29 | @Override 30 | public int priority() { 31 | return 100; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /HouseCleaning3/HouseCleaning3-front/src/main/java/dja/housecleaning/front/Ronald.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.front; 2 | 3 | import java.util.List; 4 | 5 | import dja.housecleaning.assets.Garage; 6 | import dja.housecleaning.assets.Storage; 7 | import dja.housecleaning.company.Harry; 8 | import other.things.CleaningTool; 9 | import other.things.Van; 10 | 11 | public class Ronald { 12 | 13 | public static final Ronald PERSON = new Ronald(); 14 | 15 | private Ronald() { 16 | } 17 | 18 | public void cleanMyHousePlease (OrderForm orderForm, double money) { 19 | System.out.println("Ronald: thank you for your order!"); 20 | Harry.PERSON.cleanHouseOrder(orderForm.getAddress(), orderForm.instructions, money); 21 | } 22 | 23 | public OrderForm getOrderForm () { 24 | return new OrderForm(); 25 | } 26 | 27 | public Van borrowVan (String who) { 28 | return Garage.PLACE.getVan(); 29 | } 30 | 31 | public List borrowTools (String who) { 32 | return Storage.PLACE.getCleaningTools(); 33 | } 34 | 35 | 36 | @Override 37 | public String toString() { 38 | return "Ronald"; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-frontoffice/src/main/java/dja/housecleaning/frontoffice/FrontOfficeCleaningRequest.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.frontoffice; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | 7 | import dja.housecleaning.usecases.CleaningRequest; 8 | 9 | public class FrontOfficeCleaningRequest implements CleaningRequest { 10 | 11 | String address; 12 | 13 | List instructions; 14 | 15 | Money payment; 16 | 17 | public FrontOfficeCleaningRequest(String address, List instructions, Money payment) { 18 | super(); 19 | this.address = address; 20 | this.instructions = instructions; 21 | this.payment = payment; 22 | } 23 | 24 | @Override 25 | public String getAddress() { 26 | return address; 27 | } 28 | 29 | @Override 30 | public Money getPayment() { 31 | return payment; 32 | } 33 | 34 | @Override 35 | public List getInstructions() { 36 | return instructions; 37 | } 38 | 39 | @Override 40 | public void fixPayment(Money expected, Money received) { 41 | 42 | System.out.println("Front office: Recived " + received + " but expected " + expected + "!"); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /HouseCleaning4/HouseCleaning4-frontoffice/src/main/java/dja/housecleaning/frontoffice/Ronald.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.frontoffice; 2 | 3 | import java.util.List; 4 | 5 | import dja.housecleaning.Harry; 6 | import dja.housecleaning.backoffice.Andrey; 7 | import other.things.CleaningTool; 8 | import other.things.Van; 9 | 10 | public class Ronald { 11 | 12 | public static final Ronald PERSON = new Ronald(); 13 | 14 | private Ronald() { 15 | } 16 | 17 | public void cleanMyHousePlease (OrderForm orderForm, double money) { 18 | System.out.println("Ronald: thank you for your order!"); 19 | Harry.PERSON.cleanHouseOrder(orderForm.getAddress(), orderForm.instructions, money); 20 | } 21 | 22 | public OrderForm getOrderForm () { 23 | return new OrderForm(); 24 | } 25 | 26 | public Van borrowVan(String who) { 27 | // return Garage.PLACE.getVan(); 28 | return Harry.PERSON.borrowVan(who); 29 | } 30 | 31 | public List borrowTools(String who) { 32 | // return Storage.PLACE.getCleaningTools(); 33 | return Andrey.PERSON.getCleaningTools(); 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return "Ronald"; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | decomposing.java.apps 7 | HouseCleaning8 8 | 0.0.1-SNAPSHOT 9 | 10 | HouseCleaning8-company 11 | 12 | 13 | 14 | 15 | 16 | other 17 | things 18 | 0.0.1-SNAPSHOT 19 | 20 | 21 | org.joda 22 | joda-money 23 | 0.12 24 | 25 | 26 | 27 | 28 | 29 | 30 | biz.aQute.bnd 31 | bnd-baseline-maven-plugin 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-company/src/main/java/dja/housecleaning/company/processes/NewOrderProcess.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.processes; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | 7 | import dja.housecleaning.company.jobpositions.Accountant; 8 | import dja.housecleaning.company.jobpositions.Receptionist; 9 | import dja.housecleaning.company.shared.CleaningInstructions; 10 | import dja.housecleaning.company.shared.InsufficientAmountException; 11 | import dja.housecleaning.company.staff.Staff; 12 | 13 | 14 | public class NewOrderProcess { 15 | 16 | private Staff staff = Staff.ALL; 17 | 18 | public void checkPayment(Money money) throws InsufficientAmountException { 19 | Receptionist receptionist = staff.getReceptionist(); 20 | receptionist.recievePayment(money); 21 | Accountant accountant = staff.getAccountant(); 22 | accountant.recordIncome(money); 23 | 24 | } 25 | 26 | public CleaningInstructions prepareInstructions(String address, List clientInstructions) { 27 | Receptionist receptionist = staff.getReceptionist(); 28 | return receptionist.prepareCleaningInstructions(address, clientInstructions); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-frontoffice/src/main/java/dja/housecleaning/frontoffice/internal/FrontOfficeCleaningRequest.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.frontoffice.internal; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | 7 | import dja.housecleaning.usecases.CleaningRequest; 8 | 9 | public class FrontOfficeCleaningRequest implements CleaningRequest { 10 | 11 | String address; 12 | 13 | List instructions; 14 | 15 | Money payment; 16 | 17 | public FrontOfficeCleaningRequest(String address, List instructions, Money payment) { 18 | super(); 19 | this.address = address; 20 | this.instructions = instructions; 21 | this.payment = payment; 22 | } 23 | 24 | @Override 25 | public String getAddress() { 26 | return address; 27 | } 28 | 29 | @Override 30 | public Money getPayment() { 31 | return payment; 32 | } 33 | 34 | @Override 35 | public List getInstructions() { 36 | return instructions; 37 | } 38 | 39 | @Override 40 | public void fixPayment(Money expected, Money received) { 41 | 42 | System.out.println("Front office: Recived " + received + " but expected " + expected + "!"); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | import dja.housecleaning.company.internal.processes.InternalCleanHouseProcess; 2 | import dja.housecleaning.company.internal.processes.InternalNewOrderProcess; 3 | import dja.housecleaning.company.internal.processes.InternalPrepareForCleaningProcess; 4 | import dja.housecleaning.company.internal.processes.InternalTransportProcess; 5 | import dja.housecleaning.company.processes.CleanHouseProcess; 6 | import dja.housecleaning.company.processes.NewOrderProcess; 7 | import dja.housecleaning.company.processes.PrepareForCleaningProcess; 8 | import dja.housecleaning.company.processes.TransportProcess; 9 | 10 | module dja.housecleaning.company { 11 | exports dja.housecleaning.company.jobpositions; 12 | exports dja.housecleaning.company.processes; 13 | exports dja.housecleaning.company.shared; 14 | 15 | requires joda.money; 16 | requires things; 17 | 18 | provides NewOrderProcess with InternalNewOrderProcess; 19 | provides TransportProcess with InternalTransportProcess; 20 | provides CleanHouseProcess with InternalCleanHouseProcess; 21 | provides PrepareForCleaningProcess with InternalPrepareForCleaningProcess; 22 | 23 | } -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-frontoffice/src/main/java/dja/housecleaning/frontoffice/internal/FrontOfficeCleaningRequest.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.frontoffice.internal; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | 7 | import dja.housecleaning.usecases.CleaningRequest; 8 | 9 | public class FrontOfficeCleaningRequest implements CleaningRequest { 10 | 11 | String address; 12 | 13 | List instructions; 14 | 15 | Money payment; 16 | 17 | public FrontOfficeCleaningRequest(String address, List instructions, Money payment) { 18 | super(); 19 | this.address = address; 20 | this.instructions = instructions; 21 | this.payment = payment; 22 | } 23 | 24 | @Override 25 | public String getAddress() { 26 | return address; 27 | } 28 | 29 | @Override 30 | public Money getPayment() { 31 | return payment; 32 | } 33 | 34 | @Override 35 | public List getInstructions() { 36 | return instructions; 37 | } 38 | 39 | @Override 40 | public void fixPayment(Money expected, Money received) { 41 | 42 | System.out.println("Front office: Recived " + received + " but expected " + expected + "!"); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-frontoffice/src/main/java/dja/housecleaning/frontoffice/internal/FrontOfficeCleaningRequest.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.frontoffice.internal; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | 7 | import dja.housecleaning.usecases.CleaningRequest; 8 | 9 | public class FrontOfficeCleaningRequest implements CleaningRequest { 10 | 11 | String address; 12 | 13 | List instructions; 14 | 15 | Money payment; 16 | 17 | public FrontOfficeCleaningRequest(String address, List instructions, Money payment) { 18 | super(); 19 | this.address = address; 20 | this.instructions = instructions; 21 | this.payment = payment; 22 | } 23 | 24 | @Override 25 | public String getAddress() { 26 | return address; 27 | } 28 | 29 | @Override 30 | public Money getPayment() { 31 | return payment; 32 | } 33 | 34 | @Override 35 | public List getInstructions() { 36 | return instructions; 37 | } 38 | 39 | @Override 40 | public void fixPayment(Money expected, Money received) { 41 | 42 | System.out.println("Front office: Recived " + received + " but expected " + expected + "!"); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-company/src/main/java/dja/housecleaning/company/processes/PrepareForCleaningProcess.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.processes; 2 | 3 | import java.util.List; 4 | 5 | import dja.housecleaning.company.jobpositions.Assistant; 6 | import dja.housecleaning.company.jobpositions.Cleaner; 7 | import dja.housecleaning.company.shared.CleaningInstructions; 8 | import dja.housecleaning.company.staff.Staff; 9 | import other.things.CleaningSupply; 10 | import other.things.CleaningTool; 11 | 12 | 13 | public class PrepareForCleaningProcess { 14 | 15 | private Staff staff = Staff.ALL; 16 | 17 | public Cleaner selectCleaner(CleaningInstructions instructions) { 18 | // some process here 19 | return staff.getCleaner(); 20 | } 21 | 22 | public List getCleaningSupplies(CleaningInstructions instructions) { 23 | Assistant assistant = staff.getAssistant(); 24 | return assistant.getNeededCleaningSupplies(instructions); 25 | } 26 | 27 | public List getCleaningTools(CleaningInstructions instructions) { 28 | Assistant assistant = staff.getAssistant(); 29 | return assistant.getNeededCleaningTools(instructions); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/processes/NewOrderProcess.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.processes; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | 7 | import dja.housecleaning.company.internal.staff.Staff; 8 | import dja.housecleaning.company.jobpositions.Accountant; 9 | import dja.housecleaning.company.jobpositions.Receptionist; 10 | import dja.housecleaning.company.shared.CleaningInstructions; 11 | import dja.housecleaning.company.shared.InsufficientAmountException; 12 | 13 | 14 | public class NewOrderProcess { 15 | 16 | private Staff staff = Staff.ALL; 17 | 18 | public void checkPayment(Money money) throws InsufficientAmountException { 19 | Receptionist receptionist = staff.getReceptionist(); 20 | receptionist.recievePayment(money); 21 | Accountant accountant = staff.getAccountant(); 22 | accountant.recordIncome(money); 23 | 24 | } 25 | 26 | public CleaningInstructions prepareInstructions(String address, List clientInstructions) { 27 | Receptionist receptionist = staff.getReceptionist(); 28 | return receptionist.prepareCleaningInstructions(address, clientInstructions); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/processes/PrepareForCleaningProcess.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.processes; 2 | 3 | import java.util.List; 4 | 5 | import dja.housecleaning.company.internal.staff.Staff; 6 | import dja.housecleaning.company.jobpositions.Assistant; 7 | import dja.housecleaning.company.jobpositions.Cleaner; 8 | import dja.housecleaning.company.shared.CleaningInstructions; 9 | import other.things.CleaningSupply; 10 | import other.things.CleaningTool; 11 | 12 | 13 | public class PrepareForCleaningProcess { 14 | 15 | private Staff staff = Staff.ALL; 16 | 17 | public Cleaner selectCleaner(CleaningInstructions instructions) { 18 | // some process here 19 | return staff.getCleaner(); 20 | } 21 | 22 | public List getCleaningSupplies(CleaningInstructions instructions) { 23 | Assistant assistant = staff.getAssistant(); 24 | return assistant.getNeededCleaningSupplies(instructions); 25 | } 26 | 27 | public List getCleaningTools(CleaningInstructions instructions) { 28 | Assistant assistant = staff.getAssistant(); 29 | return assistant.getNeededCleaningTools(instructions); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-frontoffice/src/main/java/dja/housecleaning/frontoffice/FrontOffice.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.frontoffice; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | 7 | import dja.housecleaning.company.assets.Storage; 8 | import dja.housecleaning.company.assets.Vehicles; 9 | import dja.housecleaning.usecases.CleaningRequest; 10 | import dja.housecleaning.usecases.CustomerUsecases; 11 | import other.things.CleaningTool; 12 | import other.things.Van; 13 | 14 | public class FrontOffice { 15 | 16 | public static final FrontOffice PLACE = new FrontOffice(); 17 | 18 | private FrontOffice() { 19 | } 20 | 21 | public void cleanMyHousePlease(OrderForm orderForm, String money) { 22 | Money payment = Money.parse(money); 23 | 24 | CleaningRequest cleaningRequest = new FrontOfficeCleaningRequest(orderForm.getAddress(), 25 | orderForm.getInstructions(), payment); 26 | 27 | CustomerUsecases.GET.cleanCustomerHouse(cleaningRequest); 28 | } 29 | 30 | public Van borrowVan(String who) { 31 | return Vehicles.companyVan; 32 | } 33 | 34 | public List borrowTools(String who) { 35 | return Storage.PLACE.getCleaningTools(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-frontoffice/src/main/java/dja/housecleaning/frontoffice/FrontOffice.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.frontoffice; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | 7 | import dja.housecleaning.frontoffice.internal.FrontOfficeCleaningRequest; 8 | import dja.housecleaning.usecases.CleaningRequest; 9 | import dja.housecleaning.usecases.CustomerUsecases; 10 | 11 | import other.things.CleaningTool; 12 | import other.things.Van; 13 | 14 | public class FrontOffice { 15 | 16 | public static final FrontOffice PLACE = new FrontOffice(); 17 | 18 | private FrontOffice() { 19 | } 20 | 21 | public void cleanMyHousePlease(OrderForm orderForm, String money) { 22 | Money payment = Money.parse(money); 23 | 24 | CleaningRequest cleaningRequest = new FrontOfficeCleaningRequest(orderForm.getAddress(), 25 | orderForm.getInstructions(), payment); 26 | 27 | CustomerUsecases.GET.cleanCustomerHouse(cleaningRequest); 28 | } 29 | 30 | public Van borrowVan(String who) { 31 | throw new UnsupportedOperationException(); 32 | } 33 | 34 | public List borrowTools(String who) { 35 | throw new UnsupportedOperationException(); 36 | } 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /HouseCleaning4/HouseCleaning4-backoffice/src/main/java/dja/housecleaning/backoffice/Storage.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.backoffice; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import other.things.CleaningSupply; 7 | import other.things.CleaningSupplyStore; 8 | import other.things.CleaningTool; 9 | 10 | class Storage { 11 | 12 | private List cleaningTools = new ArrayList<>(); 13 | private List cleaningSupplies = new ArrayList<>(); 14 | 15 | static final Storage PLACE = new Storage(); 16 | 17 | private Storage() { 18 | cleaningTools.add(new CleaningTool("vaccume cleaner")); 19 | cleaningTools.add(new CleaningTool("floor mop")); 20 | cleaningTools.add(new CleaningTool("glass wiper")); 21 | // ... 22 | cleaningSupplies.add(CleaningSupplyStore.purchase("carpet cleaner")); 23 | cleaningSupplies.add(CleaningSupplyStore.purchase("wood cleaner")); 24 | cleaningSupplies.add(CleaningSupplyStore.purchase("glass cleaner")); 25 | // ... 26 | } 27 | 28 | List getCleaningTools() { 29 | return cleaningTools; 30 | } 31 | 32 | List getCleaningSupplies() { 33 | return cleaningSupplies; 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /HouseCleaning3/HouseCleaning3-assets/src/main/java/dja/housecleaning/assets/Storage.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.assets; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import other.things.CleaningSupply; 7 | import other.things.CleaningSupplyStore; 8 | import other.things.CleaningTool; 9 | 10 | public class Storage { 11 | 12 | private List cleaningTools = new ArrayList<>(); 13 | private List cleaningSupplies = new ArrayList<>(); 14 | 15 | public static final Storage PLACE = new Storage(); 16 | 17 | private Storage() { 18 | cleaningTools.add(new CleaningTool("vaccume cleaner")); 19 | cleaningTools.add(new CleaningTool("floor mop")); 20 | cleaningTools.add(new CleaningTool("glass wiper")); 21 | // ... 22 | cleaningSupplies.add(CleaningSupplyStore.purchase("carpet cleaner")); 23 | cleaningSupplies.add(CleaningSupplyStore.purchase("wood cleaner")); 24 | cleaningSupplies.add(CleaningSupplyStore.purchase("glass cleaner")); 25 | // ... 26 | } 27 | 28 | public List getCleaningTools() { 29 | return cleaningTools; 30 | } 31 | 32 | public List getCleaningSupplies() { 33 | return cleaningSupplies; 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-company/src/main/java/dja/housecleaning/company/assets/Storage.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.assets; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import other.things.CleaningSupply; 7 | import other.things.CleaningSupplyStore; 8 | import other.things.CleaningTool; 9 | 10 | public class Storage { 11 | 12 | private List cleaningTools = new ArrayList<>(); 13 | private List cleaningSupplies = new ArrayList<>(); 14 | 15 | public static final Storage PLACE = new Storage(); 16 | 17 | private Storage() { 18 | cleaningTools.add(new CleaningTool("vaccume cleaner")); 19 | cleaningTools.add(new CleaningTool("floor mop")); 20 | cleaningTools.add(new CleaningTool("glass wiper")); 21 | // ... 22 | cleaningSupplies.add(CleaningSupplyStore.purchase("carpet cleaner")); 23 | cleaningSupplies.add(CleaningSupplyStore.purchase("wood cleaner")); 24 | cleaningSupplies.add(CleaningSupplyStore.purchase("glass cleaner")); 25 | // ... 26 | } 27 | 28 | public List getCleaningTools() { 29 | return cleaningTools; 30 | } 31 | 32 | public List getCleaningSupplies() { 33 | return cleaningSupplies; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/internal/assets/Storage.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.assets; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import other.things.CleaningSupply; 7 | import other.things.CleaningSupplyStore; 8 | import other.things.CleaningTool; 9 | 10 | public class Storage { 11 | 12 | private List cleaningTools = new ArrayList<>(); 13 | private List cleaningSupplies = new ArrayList<>(); 14 | 15 | public static final Storage PLACE = new Storage(); 16 | 17 | private Storage() { 18 | cleaningTools.add(new CleaningTool("vaccume cleaner")); 19 | cleaningTools.add(new CleaningTool("floor mop")); 20 | cleaningTools.add(new CleaningTool("glass wiper")); 21 | // ... 22 | cleaningSupplies.add(CleaningSupplyStore.purchase("carpet cleaner")); 23 | cleaningSupplies.add(CleaningSupplyStore.purchase("wood cleaner")); 24 | cleaningSupplies.add(CleaningSupplyStore.purchase("glass cleaner")); 25 | // ... 26 | } 27 | 28 | public List getCleaningTools() { 29 | return cleaningTools; 30 | } 31 | 32 | public List getCleaningSupplies() { 33 | return cleaningSupplies; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/internal/assets/Storage.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.assets; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import other.things.CleaningSupply; 7 | import other.things.CleaningSupplyStore; 8 | import other.things.CleaningTool; 9 | 10 | public class Storage { 11 | 12 | private List cleaningTools = new ArrayList<>(); 13 | private List cleaningSupplies = new ArrayList<>(); 14 | 15 | public static final Storage PLACE = new Storage(); 16 | 17 | private Storage() { 18 | cleaningTools.add(new CleaningTool("vaccume cleaner")); 19 | cleaningTools.add(new CleaningTool("floor mop")); 20 | cleaningTools.add(new CleaningTool("glass wiper")); 21 | // ... 22 | cleaningSupplies.add(CleaningSupplyStore.purchase("carpet cleaner")); 23 | cleaningSupplies.add(CleaningSupplyStore.purchase("wood cleaner")); 24 | cleaningSupplies.add(CleaningSupplyStore.purchase("glass cleaner")); 25 | // ... 26 | } 27 | 28 | public List getCleaningTools() { 29 | return cleaningTools; 30 | } 31 | 32 | public List getCleaningSupplies() { 33 | return cleaningSupplies; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/internal/assets/Storage.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.assets; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import other.things.CleaningSupply; 7 | import other.things.CleaningSupplyStore; 8 | import other.things.CleaningTool; 9 | 10 | public class Storage { 11 | 12 | private List cleaningTools = new ArrayList<>(); 13 | private List cleaningSupplies = new ArrayList<>(); 14 | 15 | public static final Storage PLACE = new Storage(); 16 | 17 | private Storage() { 18 | cleaningTools.add(new CleaningTool("vaccume cleaner")); 19 | cleaningTools.add(new CleaningTool("floor mop")); 20 | cleaningTools.add(new CleaningTool("glass wiper")); 21 | // ... 22 | cleaningSupplies.add(CleaningSupplyStore.purchase("carpet cleaner")); 23 | cleaningSupplies.add(CleaningSupplyStore.purchase("wood cleaner")); 24 | cleaningSupplies.add(CleaningSupplyStore.purchase("glass cleaner")); 25 | // ... 26 | } 27 | 28 | public List getCleaningTools() { 29 | return cleaningTools; 30 | } 31 | 32 | public List getCleaningSupplies() { 33 | return cleaningSupplies; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /HouseCleaning2/README.md: -------------------------------------------------------------------------------- 1 | # House cleaning 2 2 | 3 | ## The company structure 4 | 5 | In this example, [Harry](src/main/java/dja/housecleaning/Harry.java) gets a [smart garage](src/main/java/dja/housecleaning/Garage.java). Not that he really needs one, but that's what everyone else seams to have. He can now say "SELECT cleaning tools/supplies FROM garage WHERE tools LIKE provided instructions" and the garage will give him the tools/supplies needed. 6 | 7 | Harry also hires [Ronald](src/main/java/dja/housecleaning/Ronald.java) to handle customers' requests. Ronald comes up with standard [order form](src/main/java/dja/housecleaning/OrderForm.java) which customers need to fill in. Ronald then passes the relevant information to Harry. 8 | 9 | ## The PROs 10 | 11 | Now Harry and the garage can be isolated from the customers _(package private)_. Customers can only talk to Ronald and use the order form. 12 | 13 | ## The CONs 14 | 15 | Since Harry, Ronald and the garage are all in the same [place(package)](src/main/java/dja/housecleaning/), now Ronald has full access to the garage. There is no way to physically limit Ronald's access to the garage. Therefore Ronald can now borrow the van and the tools _(without Harry's knowledge)_ and the company may stop functioning. 16 | 17 | -------------------------------------------------------------------------------- /HouseCleaning4/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | decomposing.java.apps 6 | HouseCleaning4 7 | 0.0.1-SNAPSHOT 8 | pom 9 | 10 | 11 | 12 | other 13 | things 14 | 0.0.1-SNAPSHOT 15 | 16 | 17 | org.jline 18 | jline 19 | 3.7.0 20 | 21 | 22 | 23 | 24 | 25 | 26 | maven-compiler-plugin 27 | 3.7.0 28 | 29 | 1.8 30 | 1.8 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | HouseCleaning4-backoffice 39 | HouseCleaning4-client 40 | HouseCleaning4-frontoffice 41 | HouseCleaning4-company 42 | 43 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/internal/processes/InternalNewOrderProcess.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.processes; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | 7 | import dja.housecleaning.company.internal.staff.Staff; 8 | import dja.housecleaning.company.jobpositions.Accountant; 9 | import dja.housecleaning.company.jobpositions.Receptionist; 10 | import dja.housecleaning.company.processes.NewOrderProcess; 11 | import dja.housecleaning.company.shared.CleaningInstructions; 12 | import dja.housecleaning.company.shared.InsufficientAmountException; 13 | 14 | 15 | public class InternalNewOrderProcess implements NewOrderProcess { 16 | 17 | private Staff staff = Staff.ALL; 18 | 19 | @Override 20 | public void checkPayment(Money money) throws InsufficientAmountException { 21 | Receptionist receptionist = staff.getReceptionist(); 22 | receptionist.recievePayment(money); 23 | Accountant accountant = staff.getAccountant(); 24 | accountant.recordIncome(money); 25 | 26 | } 27 | 28 | @Override 29 | public CleaningInstructions prepareInstructions(String address, List clientInstructions) { 30 | Receptionist receptionist = staff.getReceptionist(); 31 | return receptionist.prepareCleaningInstructions(address, clientInstructions); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/processes/TransportProcess.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.processes; 2 | 3 | import java.io.FileInputStream; 4 | import java.io.IOException; 5 | import java.util.List; 6 | import java.util.Properties; 7 | 8 | import dja.housecleaning.company.internal.assets.Vehicles; 9 | import dja.housecleaning.company.jobpositions.Cleaner; 10 | import other.things.CleaningSupply; 11 | import other.things.CleaningTool; 12 | import other.things.Van; 13 | 14 | public class TransportProcess { 15 | 16 | private Van companyVan; 17 | 18 | public TransportProcess() { 19 | companyVan = Vehicles.companyVan; 20 | } 21 | 22 | public void goTo(String address, Cleaner cleaner, List supplies, List tools) { 23 | companyVan.load(supplies); 24 | companyVan.load(tools); 25 | companyVan.addPassenger(cleaner); 26 | companyVan.drive(address); 27 | } 28 | 29 | public boolean isVanFunctional() { 30 | boolean vanIsFunctional = false; 31 | Properties properties = new Properties(); 32 | try { 33 | properties.load(new FileInputStream(System.getProperty("user.dir") + "/status")); 34 | vanIsFunctional = Boolean.valueOf(properties.getProperty("van.functional", "false")); 35 | } catch (IOException e) { 36 | e.printStackTrace(); 37 | } 38 | return vanIsFunctional; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/internal/processes/InternalPrepareForCleaningProcess.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.processes; 2 | 3 | import java.util.List; 4 | 5 | import dja.housecleaning.company.internal.staff.Staff; 6 | import dja.housecleaning.company.jobpositions.Assistant; 7 | import dja.housecleaning.company.jobpositions.Cleaner; 8 | import dja.housecleaning.company.processes.PrepareForCleaningProcess; 9 | import dja.housecleaning.company.shared.CleaningInstructions; 10 | import other.things.CleaningSupply; 11 | import other.things.CleaningTool; 12 | 13 | 14 | public class InternalPrepareForCleaningProcess implements PrepareForCleaningProcess { 15 | 16 | private Staff staff = Staff.ALL; 17 | 18 | @Override 19 | public Cleaner selectCleaner(CleaningInstructions instructions) { 20 | // some process here 21 | return staff.getCleaner(); 22 | } 23 | 24 | @Override 25 | public List getCleaningSupplies(CleaningInstructions instructions) { 26 | Assistant assistant = staff.getAssistant(); 27 | return assistant.getNeededCleaningSupplies(instructions); 28 | } 29 | 30 | @Override 31 | public List getCleaningTools(CleaningInstructions instructions) { 32 | Assistant assistant = staff.getAssistant(); 33 | return assistant.getNeededCleaningTools(instructions); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-frontoffice/src/main/java/dja/housecleaning/frontoffice/FrontOffice.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.frontoffice; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | 7 | import dja.housecleaning.company.internal.assets.Vehicles; 8 | import dja.housecleaning.company.internal.assets.Storage; 9 | import dja.housecleaning.frontoffice.internal.FrontOfficeCleaningRequest; 10 | import dja.housecleaning.usecases.CleaningRequest; 11 | import dja.housecleaning.usecases.CustomerUsecases; 12 | import other.things.CleaningTool; 13 | import other.things.Van; 14 | 15 | public class FrontOffice { 16 | 17 | public static final FrontOffice PLACE = new FrontOffice(); 18 | 19 | private FrontOffice() { 20 | } 21 | 22 | public void cleanMyHousePlease(OrderForm orderForm, String money) { 23 | Money payment = Money.parse(money); 24 | 25 | CleaningRequest cleaningRequest = new FrontOfficeCleaningRequest(orderForm.getAddress(), 26 | orderForm.getInstructions(), payment); 27 | 28 | CustomerUsecases.GET.cleanCustomerHouse(cleaningRequest); 29 | } 30 | 31 | public Van borrowVan(String who) { 32 | return Vehicles.companyVan; 33 | // throw new UnsupportedOperationException(); 34 | } 35 | 36 | public List borrowTools(String who) { 37 | return Storage.PLACE.getCleaningTools(); 38 | // throw new UnsupportedOperationException(); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/internal/processes/InternalNewOrderProcess.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.processes; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | import org.osgi.service.component.annotations.Component; 7 | 8 | import dja.housecleaning.company.internal.staff.Staff; 9 | import dja.housecleaning.company.jobpositions.Accountant; 10 | import dja.housecleaning.company.jobpositions.Receptionist; 11 | import dja.housecleaning.company.processes.NewOrderProcess; 12 | import dja.housecleaning.company.shared.CleaningInstructions; 13 | import dja.housecleaning.company.shared.InsufficientAmountException; 14 | 15 | @Component 16 | public class InternalNewOrderProcess implements NewOrderProcess { 17 | 18 | private Staff staff = Staff.ALL; 19 | 20 | @Override 21 | public void checkPayment(Money money) throws InsufficientAmountException { 22 | Receptionist receptionist = staff.getReceptionist(); 23 | receptionist.recievePayment(money); 24 | Accountant accountant = staff.getAccountant(); 25 | accountant.recordIncome(money); 26 | 27 | } 28 | 29 | @Override 30 | public CleaningInstructions prepareInstructions(String address, List clientInstructions) { 31 | Receptionist receptionist = staff.getReceptionist(); 32 | return receptionist.prepareCleaningInstructions(address, clientInstructions); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /HouseCleaning3/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | decomposing.java.apps 6 | HouseCleaning3 7 | 0.0.1-SNAPSHOT 8 | pom 9 | 10 | 11 | 12 | other 13 | things 14 | 0.0.1-SNAPSHOT 15 | 16 | 17 | org.joda 18 | joda-money 19 | 0.12 20 | 21 | 22 | org.jline 23 | jline 24 | 3.7.0 25 | 26 | 27 | 28 | 29 | 30 | 31 | maven-compiler-plugin 32 | 3.7.0 33 | 34 | 1.8 35 | 1.8 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | HouseCleaning3-client 44 | HouseCleaning3-front 45 | HouseCleaning3-company 46 | HouseCleaning3-assets 47 | 48 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/internal/processes/InternalPrepareForCleaningProcess.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.processes; 2 | 3 | import java.util.List; 4 | 5 | import org.osgi.service.component.annotations.Component; 6 | 7 | import dja.housecleaning.company.internal.staff.Staff; 8 | import dja.housecleaning.company.jobpositions.Assistant; 9 | import dja.housecleaning.company.jobpositions.Cleaner; 10 | import dja.housecleaning.company.processes.PrepareForCleaningProcess; 11 | import dja.housecleaning.company.shared.CleaningInstructions; 12 | import other.things.CleaningSupply; 13 | import other.things.CleaningTool; 14 | 15 | @Component 16 | public class InternalPrepareForCleaningProcess implements PrepareForCleaningProcess { 17 | 18 | private Staff staff = Staff.ALL; 19 | 20 | @Override 21 | public Cleaner selectCleaner(CleaningInstructions instructions) { 22 | // some process here 23 | return staff.getCleaner(); 24 | } 25 | 26 | @Override 27 | public List getCleaningSupplies(CleaningInstructions instructions) { 28 | Assistant assistant = staff.getAssistant(); 29 | return assistant.getNeededCleaningSupplies(instructions); 30 | } 31 | 32 | @Override 33 | public List getCleaningTools(CleaningInstructions instructions) { 34 | Assistant assistant = staff.getAssistant(); 35 | return assistant.getNeededCleaningTools(instructions); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-frontoffice/src/main/java/dja/housecleaning/frontoffice/FrontOffice.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.frontoffice; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | import org.osgi.service.component.annotations.Component; 7 | import org.osgi.service.component.annotations.Reference; 8 | 9 | import dja.housecleaning.company.internal.assets.Storage; 10 | import dja.housecleaning.company.internal.assets.Vehicles; 11 | import dja.housecleaning.frontoffice.internal.FrontOfficeCleaningRequest; 12 | import dja.housecleaning.usecases.CleaningRequest; 13 | import dja.housecleaning.usecases.CustomerUsecases; 14 | import other.things.CleaningTool; 15 | import other.things.Van; 16 | 17 | @Component (service=FrontOffice.class) 18 | public class FrontOffice { 19 | 20 | @Reference 21 | CustomerUsecases customerUsecases; 22 | 23 | 24 | public void cleanMyHousePlease(OrderForm orderForm, String money) { 25 | Money payment = Money.parse(money); 26 | 27 | CleaningRequest cleaningRequest = new FrontOfficeCleaningRequest(orderForm.getAddress(), 28 | orderForm.getInstructions(), payment); 29 | 30 | customerUsecases.cleanCustomerHouse(cleaningRequest); 31 | } 32 | 33 | public Van borrowVan(String who) { 34 | // return Vehicles.companyVan; 35 | throw new UnsupportedOperationException(); 36 | } 37 | 38 | public List borrowTools(String who) { 39 | // return Storage.PLACE.getCleaningTools(); 40 | throw new UnsupportedOperationException(); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-company/src/main/java/dja/housecleaning/company/staff/Ronald.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.staff; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | 7 | import dja.housecleaning.company.jobpositions.Receptionist; 8 | import dja.housecleaning.company.shared.CleaningInstructions; 9 | import dja.housecleaning.company.shared.InsufficientAmountException; 10 | import dja.housecleaning.company.shared.PricingPolicy; 11 | 12 | class Ronald implements Receptionist { 13 | 14 | public static final Ronald PERSON = new Ronald(); 15 | 16 | private Ronald() { 17 | } 18 | 19 | @Override 20 | public void recievePayment(Money money) throws InsufficientAmountException{ 21 | System.out.println("Ronald: checking payment"); 22 | if (money.isLessThan(PricingPolicy.sevicePrice)) { 23 | throw new InsufficientAmountException(PricingPolicy.sevicePrice, money); 24 | } 25 | } 26 | 27 | @Override 28 | public CleaningInstructions prepareCleaningInstructions(String address, List instructions) { 29 | System.out.println("Ronald: preparing cleaning instructions"); 30 | CleaningInstructions cleaningInstructions = new CleaningInstructions(); 31 | cleaningInstructions.address = address; 32 | for (String instruction : instructions) { 33 | if (instruction.isEmpty()) { 34 | cleaningInstructions.instructions.add(new CleaningInstructions.Instruction(/* parse and create proper instruction */)); 35 | } 36 | } 37 | return cleaningInstructions; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/internal/processes/InternalTransportProcess.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.processes; 2 | 3 | import java.io.FileInputStream; 4 | import java.io.IOException; 5 | import java.util.List; 6 | import java.util.Properties; 7 | 8 | import dja.housecleaning.company.internal.assets.Vehicles; 9 | import dja.housecleaning.company.jobpositions.Cleaner; 10 | import dja.housecleaning.company.processes.TransportProcess; 11 | import other.things.CleaningSupply; 12 | import other.things.CleaningTool; 13 | import other.things.Van; 14 | 15 | public class InternalTransportProcess implements TransportProcess { 16 | 17 | Van companyVan = Vehicles.companyVan; 18 | 19 | @Override 20 | public void goTo(String address, Cleaner cleaner, List supplies, List tools) { 21 | companyVan.load(supplies); 22 | companyVan.load(tools); 23 | companyVan.addPassenger(cleaner); 24 | companyVan.drive(address); 25 | } 26 | 27 | @Override 28 | public boolean isCurrentlyAvailable() { 29 | boolean vanIsFunctional = false; 30 | Properties properties = new Properties(); 31 | try { 32 | properties.load(new FileInputStream(System.getProperty("user.dir") + "/status")); 33 | vanIsFunctional = Boolean.valueOf(properties.getProperty("van.functional", "false")); 34 | } catch (IOException e) { 35 | } 36 | 37 | return vanIsFunctional; 38 | } 39 | 40 | @Override 41 | public int priority() { 42 | return 1; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/internal/staff/Harry.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.staff; 2 | 3 | import org.joda.money.Money; 4 | 5 | import dja.housecleaning.company.internal.assets.Software; 6 | import dja.housecleaning.company.jobpositions.Accountant; 7 | import dja.housecleaning.company.jobpositions.Cleaner; 8 | import dja.housecleaning.company.shared.CleaningInstructions; 9 | 10 | class Harry implements Cleaner, Accountant { 11 | 12 | public static final Harry PERSON = new Harry(); 13 | 14 | private Harry() { 15 | } 16 | 17 | @Override 18 | public void recordIncome(Money money) { 19 | Software.companyBookkepingsystem.recordIncome(money.getAmount().doubleValue()); 20 | } 21 | 22 | 23 | public void cleanHouse (CleaningInstructions instructions) { 24 | System.out.println("Harry: cleaning 💦"); 25 | System.out.println("Harry: done cleaning 🌟"); 26 | } 27 | 28 | // public Van borrowVan(String who) { 29 | // if ("friend".equals(who)) { 30 | // System.out.println("Harry: Here is my 🚚️"); 31 | // return Garage.PLACE.getVan(); 32 | // } 33 | // System.out.println("Harry: I'm sorry but I don't know you!"); 34 | // return null; 35 | // } 36 | // 37 | // public List borrowTools(String who) { 38 | // if ("friend".equals(who)) { 39 | // System.out.println("Harry: Here are my 🛠️"); 40 | // return Andrey.PERSON.getCleaningTools(); 41 | // } 42 | // System.out.println("Harry: I'm sorry but I don't know you!"); 43 | // return null; 44 | // } 45 | 46 | @Override 47 | public String toString() { 48 | return "Harry"; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/internal/staff/Harry.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.staff; 2 | 3 | import org.joda.money.Money; 4 | 5 | import dja.housecleaning.company.internal.assets.Software; 6 | import dja.housecleaning.company.jobpositions.Accountant; 7 | import dja.housecleaning.company.jobpositions.Cleaner; 8 | import dja.housecleaning.company.shared.CleaningInstructions; 9 | 10 | class Harry implements Cleaner, Accountant { 11 | 12 | public static final Harry PERSON = new Harry(); 13 | 14 | private Harry() { 15 | } 16 | 17 | @Override 18 | public void recordIncome(Money money) { 19 | Software.companyBookkepingsystem.recordIncome(money.getAmount().doubleValue()); 20 | } 21 | 22 | 23 | public void cleanHouse (CleaningInstructions instructions) { 24 | System.out.println("Harry: cleaning 💦"); 25 | System.out.println("Harry: done cleaning 🌟"); 26 | } 27 | 28 | // public Van borrowVan(String who) { 29 | // if ("friend".equals(who)) { 30 | // System.out.println("Harry: Here is my 🚚️"); 31 | // return Garage.PLACE.getVan(); 32 | // } 33 | // System.out.println("Harry: I'm sorry but I don't know you!"); 34 | // return null; 35 | // } 36 | // 37 | // public List borrowTools(String who) { 38 | // if ("friend".equals(who)) { 39 | // System.out.println("Harry: Here are my 🛠️"); 40 | // return Andrey.PERSON.getCleaningTools(); 41 | // } 42 | // System.out.println("Harry: I'm sorry but I don't know you!"); 43 | // return null; 44 | // } 45 | 46 | @Override 47 | public String toString() { 48 | return "Harry"; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/internal/staff/Harry.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.staff; 2 | 3 | import org.joda.money.Money; 4 | 5 | import dja.housecleaning.company.internal.assets.Software; 6 | import dja.housecleaning.company.jobpositions.Accountant; 7 | import dja.housecleaning.company.jobpositions.Cleaner; 8 | import dja.housecleaning.company.shared.CleaningInstructions; 9 | 10 | class Harry implements Cleaner, Accountant { 11 | 12 | public static final Harry PERSON = new Harry(); 13 | 14 | private Harry() { 15 | } 16 | 17 | @Override 18 | public void recordIncome(Money money) { 19 | Software.companyBookkepingsystem.recordIncome(money.getAmount().doubleValue()); 20 | } 21 | 22 | 23 | public void cleanHouse (CleaningInstructions instructions) { 24 | System.out.println("Harry: cleaning 💦"); 25 | System.out.println("Harry: done cleaning 🌟"); 26 | } 27 | 28 | // public Van borrowVan(String who) { 29 | // if ("friend".equals(who)) { 30 | // System.out.println("Harry: Here is my 🚚️"); 31 | // return Garage.PLACE.getVan(); 32 | // } 33 | // System.out.println("Harry: I'm sorry but I don't know you!"); 34 | // return null; 35 | // } 36 | // 37 | // public List borrowTools(String who) { 38 | // if ("friend".equals(who)) { 39 | // System.out.println("Harry: Here are my 🛠️"); 40 | // return Andrey.PERSON.getCleaningTools(); 41 | // } 42 | // System.out.println("Harry: I'm sorry but I don't know you!"); 43 | // return null; 44 | // } 45 | 46 | @Override 47 | public String toString() { 48 | return "Harry"; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/internal/processes/InternalTransportProcess.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.processes; 2 | 3 | import java.io.FileInputStream; 4 | import java.io.IOException; 5 | import java.util.List; 6 | import java.util.Properties; 7 | 8 | import org.osgi.service.component.annotations.Component; 9 | 10 | import dja.housecleaning.company.internal.assets.Vehicles; 11 | import dja.housecleaning.company.jobpositions.Cleaner; 12 | import dja.housecleaning.company.processes.TransportProcess; 13 | import other.things.CleaningSupply; 14 | import other.things.CleaningTool; 15 | import other.things.Van; 16 | 17 | @Component 18 | public class InternalTransportProcess implements TransportProcess { 19 | 20 | Van companyVan = Vehicles.companyVan; 21 | 22 | @Override 23 | public void goTo(String address, Cleaner cleaner, List supplies, List tools) { 24 | companyVan.load(supplies); 25 | companyVan.load(tools); 26 | companyVan.addPassenger(cleaner); 27 | companyVan.drive(address); 28 | } 29 | 30 | @Override 31 | public boolean isCurrentlyAvailable() { 32 | boolean vanIsFunctional = false; 33 | Properties properties = new Properties(); 34 | try { 35 | properties.load(new FileInputStream(System.getProperty("user.dir") + "/status")); 36 | vanIsFunctional = Boolean.valueOf(properties.getProperty("van.functional", "false")); 37 | } catch (IOException e) { 38 | } 39 | 40 | return vanIsFunctional; 41 | } 42 | 43 | @Override 44 | public int priority() { 45 | return 1; 46 | } 47 | 48 | // @Override 49 | // public int status() { 50 | // return 0; 51 | // } 52 | } 53 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/internal/staff/Ronald.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.staff; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | 7 | import dja.housecleaning.company.internal.shared.InternalCleaningInstruction; 8 | import dja.housecleaning.company.internal.shared.InternalCleaningInstructions; 9 | import dja.housecleaning.company.internal.shared.PricingPolicy; 10 | import dja.housecleaning.company.jobpositions.Receptionist; 11 | import dja.housecleaning.company.shared.CleaningInstructions; 12 | import dja.housecleaning.company.shared.InsufficientAmountException; 13 | 14 | class Ronald implements Receptionist { 15 | 16 | public static final Ronald PERSON = new Ronald(); 17 | 18 | private Ronald() { 19 | } 20 | 21 | @Override 22 | public void recievePayment(Money money) throws InsufficientAmountException{ 23 | System.out.println("Ronald: checking payment"); 24 | if (money.isLessThan(PricingPolicy.sevicePrice)) { 25 | throw new InsufficientAmountException(PricingPolicy.sevicePrice, money); 26 | } 27 | } 28 | 29 | @Override 30 | public CleaningInstructions prepareCleaningInstructions(String address, List instructions) { 31 | System.out.println("Ronald: preparing cleaning instructions"); 32 | InternalCleaningInstructions cleaningInstructions = new InternalCleaningInstructions(); 33 | cleaningInstructions.address = address; 34 | for (String instruction : instructions) { 35 | if (instruction.isEmpty()) { 36 | cleaningInstructions.instructions.add(new InternalCleaningInstruction(/* parse and create proper instruction */)); 37 | } 38 | } 39 | return cleaningInstructions; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/internal/staff/Ronald.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.staff; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | 7 | import dja.housecleaning.company.internal.shared.InternalCleaningInstruction; 8 | import dja.housecleaning.company.internal.shared.InternalCleaningInstructions; 9 | import dja.housecleaning.company.internal.shared.PricingPolicy; 10 | import dja.housecleaning.company.jobpositions.Receptionist; 11 | import dja.housecleaning.company.shared.CleaningInstructions; 12 | import dja.housecleaning.company.shared.InsufficientAmountException; 13 | 14 | class Ronald implements Receptionist { 15 | 16 | public static final Ronald PERSON = new Ronald(); 17 | 18 | private Ronald() { 19 | } 20 | 21 | @Override 22 | public void recievePayment(Money money) throws InsufficientAmountException{ 23 | System.out.println("Ronald: checking payment"); 24 | if (money.isLessThan(PricingPolicy.sevicePrice)) { 25 | throw new InsufficientAmountException(PricingPolicy.sevicePrice, money); 26 | } 27 | } 28 | 29 | @Override 30 | public CleaningInstructions prepareCleaningInstructions(String address, List instructions) { 31 | System.out.println("Ronald: preparing cleaning instructions"); 32 | InternalCleaningInstructions cleaningInstructions = new InternalCleaningInstructions(); 33 | cleaningInstructions.address = address; 34 | for (String instruction : instructions) { 35 | if (instruction.isEmpty()) { 36 | cleaningInstructions.instructions.add(new InternalCleaningInstruction(/* parse and create proper instruction */)); 37 | } 38 | } 39 | return cleaningInstructions; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/internal/staff/Ronald.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.staff; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | 7 | import dja.housecleaning.company.internal.shared.InternalCleaningInstruction; 8 | import dja.housecleaning.company.internal.shared.InternalCleaningInstructions; 9 | import dja.housecleaning.company.internal.shared.PricingPolicy; 10 | import dja.housecleaning.company.jobpositions.Receptionist; 11 | import dja.housecleaning.company.shared.CleaningInstructions; 12 | import dja.housecleaning.company.shared.InsufficientAmountException; 13 | 14 | class Ronald implements Receptionist { 15 | 16 | public static final Ronald PERSON = new Ronald(); 17 | 18 | private Ronald() { 19 | } 20 | 21 | @Override 22 | public void recievePayment(Money money) throws InsufficientAmountException{ 23 | System.out.println("Ronald: checking payment"); 24 | if (money.isLessThan(PricingPolicy.sevicePrice)) { 25 | throw new InsufficientAmountException(PricingPolicy.sevicePrice, money); 26 | } 27 | } 28 | 29 | @Override 30 | public CleaningInstructions prepareCleaningInstructions(String address, List instructions) { 31 | System.out.println("Ronald: preparing cleaning instructions"); 32 | InternalCleaningInstructions cleaningInstructions = new InternalCleaningInstructions(); 33 | cleaningInstructions.address = address; 34 | for (String instruction : instructions) { 35 | if (instruction.isEmpty()) { 36 | cleaningInstructions.instructions.add(new InternalCleaningInstruction(/* parse and create proper instruction */)); 37 | } 38 | } 39 | return cleaningInstructions; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-company/src/main/java/dja/housecleaning/company/staff/Harry.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.staff; 2 | 3 | import java.util.List; 4 | 5 | import org.joda.money.Money; 6 | 7 | import dja.housecleaning.company.assets.Software; 8 | import dja.housecleaning.company.assets.Storage; 9 | import dja.housecleaning.company.assets.Vehicles; 10 | import dja.housecleaning.company.jobpositions.Accountant; 11 | import dja.housecleaning.company.jobpositions.Cleaner; 12 | import dja.housecleaning.company.shared.CleaningInstructions; 13 | import other.things.CleaningTool; 14 | import other.things.Van; 15 | 16 | class Harry implements Cleaner, Accountant { 17 | 18 | public static final Harry PERSON = new Harry(); 19 | 20 | private Harry() { 21 | } 22 | 23 | @Override 24 | public void recordIncome(Money money) { 25 | Software.companyBookkepingsystem.recordIncome(money.getAmount().doubleValue()); 26 | } 27 | 28 | 29 | public void cleanHouse (CleaningInstructions instructions) { 30 | System.out.println("Harry: cleaning 💦"); 31 | System.out.println("Harry: done cleaning 🌟"); 32 | } 33 | 34 | public Van borrowVan (String who) { 35 | if ("friend".equals(who)) { 36 | System.out.println("Harry: Here is my 🚚️"); 37 | return Vehicles.companyVan; 38 | } 39 | System.out.println("Harry: I'm sorry but I don't know you!"); 40 | return null; 41 | } 42 | 43 | public List borrowTools (String who) { 44 | if ("friend".equals(who)) { 45 | System.out.println("Harry: Here are my 🛠️"); 46 | return Storage.PLACE.getCleaningTools(); 47 | } 48 | System.out.println("Harry: I'm sorry but I don't know you!"); 49 | return null; 50 | } 51 | 52 | @Override 53 | public String toString() { 54 | return "Harry"; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /HouseCleaning3/README.md: -------------------------------------------------------------------------------- 1 | # House cleaning 3 2 | 3 | ## The company structure 4 | 5 | 6 | In this example, [Harry](HouseCleaning3-company/src/main/java/dja/housecleaning/company/Harry.java) hires new assistant [Andrey](HouseCleaning3-company/src/main/java/dja/housecleaning/company/Andrey.java). He also splits the company assets into a [garage](HouseCleaning3-assets/src/main/java/dja/housecleaning/assets/Garage.java) for the van and [storage](HouseCleaning3-assets/src/main/java/dja/housecleaning/assets/Storage.java) for the tools and supplies. 7 | 8 | Unenforced agreement is that Andrey is in charge for the storage and Harry is using the garage. Then the company is divided into 3 departments _(modules)_, following industry's best practices. 9 | 10 | ### [Front office](HouseCleaning3-front) 11 | 12 | This is where customers are served. Thus this is where [Ronald](HouseCleaning3-front/src/main/java/dja/housecleaning/front/Ronald.java) and the standard [order form](HouseCleaning3-front/src/main/java/dja/housecleaning/front/OrderForm.java) are located. 13 | 14 | ### [Company](HouseCleaning3-company) 15 | This is where the company actually operates from. Thus this is where Harry and Andrey are located. 16 | 17 | ### [Assets](HouseCleaning3-assets) 18 | 19 | This is where all the company assets are kept. 20 | 21 | ## The PROs 22 | 23 | The company operation can now be divided between Harry and Andrey and all future assistants. Andrey and all future assistants are not available _(package private)_ for anyone else but Harry. 24 | 25 | ## The CONs 26 | 27 | Since both the garage and storage are outside the company they need to be publicly available. Again, there is no way to physically limit Ronald's access to the garage nor storage. Moreover, Harry need to be publicly available for Ronald to contact him, thus he is no longer isolated from customers. 28 | 29 | -------------------------------------------------------------------------------- /HouseCleaning3/HouseCleaning3-company/src/main/java/dja/housecleaning/company/Andrey.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import dja.housecleaning.assets.Storage; 7 | import other.things.CleaningSupply; 8 | import other.things.CleaningTool; 9 | 10 | class Andrey { 11 | 12 | Storage storage = Storage.PLACE; 13 | 14 | static final Andrey PERSON = new Andrey(); 15 | 16 | private Andrey() { 17 | } 18 | 19 | List getNeededCleaningSupplies(String instructions) { 20 | System.out.println("Andrey: pick cleaning supplies based on provided instructions"); 21 | List neededCleaningSupplies = new ArrayList<>(); 22 | for (CleaningSupply cleaningSupply : storage.getCleaningSupplies()) { 23 | // some filter logic here 24 | neededCleaningSupplies.add(cleaningSupply); 25 | } 26 | return neededCleaningSupplies; 27 | } 28 | 29 | List getNeededCleaningTools(String instructions) { 30 | System.out.println("Andrey: pick cleaning tools based on provided instructions"); 31 | List neededCleaningTools = new ArrayList<>(); 32 | for (CleaningTool cleaningTool : storage.getCleaningTools()) { 33 | // some filter logic here 34 | neededCleaningTools.add(cleaningTool); 35 | } 36 | return neededCleaningTools; 37 | } 38 | 39 | void storeCleaningTools(List cleaningTools) { 40 | System.out.println("Andrey: putting cleaning tools in storage"); 41 | // 42 | } 43 | 44 | void storeCleaningSupplies(List cleaningSupplies) { 45 | System.out.println("Andrey: checking and putting cleaning supplies in storage"); 46 | for (CleaningSupply cleaningSupply : cleaningSupplies) { 47 | if (cleaningSupply.isEmpty()) { 48 | // purchase 49 | } 50 | } 51 | // 52 | } 53 | 54 | @Override 55 | public String toString() { 56 | return "Andrey"; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /HouseCleaning2/src/main/java/dja/housecleaning/Garage.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import other.things.CleaningSupply; 7 | import other.things.CleaningTool; 8 | import other.things.Van; 9 | 10 | class Garage { 11 | 12 | private List cleaningTools = new ArrayList<>(); 13 | private List leaningSupplies = new ArrayList<>(); 14 | private Van van = new Van(); 15 | 16 | public static final Garage PLACE = new Garage(); 17 | 18 | private Garage() { 19 | } 20 | 21 | public void add (CleaningTool cleaningTool) { 22 | cleaningTools.add(cleaningTool); 23 | } 24 | 25 | public void add (CleaningSupply cleaningSupply) { 26 | leaningSupplies.add(cleaningSupply); 27 | } 28 | 29 | public List getCleaningTools() { 30 | return cleaningTools; 31 | } 32 | 33 | public List getCleaningSupplies() { 34 | return leaningSupplies; 35 | } 36 | 37 | public List getNeededCleaningSupplies(String instructions) { 38 | System.out.println("Smart garage: SELECT cleaning supplies FROM garage WHERE supplies LIKE provided instructions"); 39 | List neededCleaningSupplies = new ArrayList<>(); 40 | for (CleaningSupply cleaningSupply : leaningSupplies) { 41 | // some filter logic here 42 | neededCleaningSupplies.add(cleaningSupply); 43 | } 44 | return neededCleaningSupplies; 45 | } 46 | 47 | public List getNeededCleaningTools(String instructions) { 48 | System.out.println("Smart garage: SELECT cleaning tools FROM garage WHERE tools LIKE provided instructions"); 49 | List neededCleaningTools = new ArrayList<>(); 50 | for (CleaningTool cleaningTool : cleaningTools) { 51 | neededCleaningTools.add(cleaningTool); 52 | } 53 | return neededCleaningTools; 54 | } 55 | 56 | public Van getVan() { 57 | return van; 58 | } 59 | 60 | 61 | } 62 | -------------------------------------------------------------------------------- /HouseCleaning4/HouseCleaning4-backoffice/src/main/java/dja/housecleaning/backoffice/Andrey.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.backoffice; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import other.things.CleaningSupply; 7 | import other.things.CleaningTool; 8 | 9 | public class Andrey { 10 | 11 | Storage storage = Storage.PLACE; 12 | 13 | public static final Andrey PERSON = new Andrey(); 14 | 15 | private Andrey() { 16 | } 17 | 18 | public List getNeededCleaningSupplies(String instructions) { 19 | System.out.println("Andrey: pick cleaning supplies based on provided instructions"); 20 | List neededCleaningSupplies = new ArrayList<>(); 21 | for (CleaningSupply cleaningSupply : storage.getCleaningSupplies()) { 22 | // some filter logic here 23 | neededCleaningSupplies.add(cleaningSupply); 24 | } 25 | return neededCleaningSupplies; 26 | } 27 | 28 | public List getNeededCleaningTools(String instructions) { 29 | System.out.println("Andrey: pick cleaning tools based on provided instructions"); 30 | List neededCleaningTools = new ArrayList<>(); 31 | for (CleaningTool cleaningTool : storage.getCleaningTools()) { 32 | // some filter logic here 33 | neededCleaningTools.add(cleaningTool); 34 | } 35 | return neededCleaningTools; 36 | } 37 | 38 | public void storeCleaningTools(List cleaningTools) { 39 | System.out.println("Andrey: putting cleaning tools in storage"); 40 | // 41 | } 42 | 43 | public void storeCleaningSupplies(List cleaningSupplies) { 44 | System.out.println("Andrey: checking and putting cleaning supplies in storage"); 45 | for (CleaningSupply cleaningSupply : cleaningSupplies) { 46 | if (cleaningSupply.isEmpty()) { 47 | // purchase 48 | } 49 | } 50 | // 51 | } 52 | 53 | public List getCleaningTools () { 54 | return storage.getCleaningTools(); 55 | } 56 | 57 | @Override 58 | public String toString() { 59 | return "Andrey"; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-client/src/main/java/dja/housecleaning/client/Client.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.client; 2 | 3 | 4 | import java.lang.reflect.InvocationTargetException; 5 | import java.lang.reflect.Method; 6 | import java.util.List; 7 | 8 | import org.osgi.service.component.annotations.Component; 9 | import org.osgi.service.component.annotations.Reference; 10 | 11 | import dja.housecleaning.frontoffice.FrontOffice; 12 | import dja.housecleaning.frontoffice.OrderForm; 13 | import other.things.CleaningTool; 14 | import other.things.Van; 15 | 16 | 17 | @Component( // 18 | property = { // 19 | "osgi.command.function=clean", // 20 | "osgi.command.function=borrowVan", // 21 | "osgi.command.function=borrowTools", // 22 | "osgi.command.scope=hc" // 23 | }, // 24 | service = Object.class // 25 | ) 26 | public class Client { 27 | 28 | @Reference FrontOffice frontOffice; 29 | 30 | public Client() { 31 | System.out.println("Java version is: " + System.getProperty("java.version")); 32 | } 33 | 34 | public void clean (String money) { 35 | OrderForm orderForm = new OrderForm(); 36 | orderForm.setAddress("some street"); 37 | orderForm.addInstruction("clean the floor"); 38 | frontOffice.cleanMyHousePlease(orderForm, money); 39 | } 40 | 41 | 42 | public void borrowVan(String param) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { 43 | 44 | Method borrowVan = frontOffice.getClass().getMethod("borrowVan", String.class); 45 | Van van = (Van)borrowVan.invoke(frontOffice, param); 46 | van.drive("⛱️"); 47 | System.out.println("Client: I'm on vacation! Will be back next week! May be!"); 48 | 49 | } 50 | 51 | public void borrowTools(String param) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { 52 | Method borrowTools = frontOffice.getClass().getMethod("borrowTools", String.class); 53 | List cleaningTools = (List)borrowTools.invoke(frontOffice, param); 54 | cleaningTools.clear(); 55 | System.out.println("Client: Opps I lost your 🛠️. I'm so sorry!"); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-company/src/main/java/dja/housecleaning/company/staff/Andrey.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.staff; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import dja.housecleaning.company.assets.Storage; 7 | import dja.housecleaning.company.jobpositions.Assistant; 8 | import dja.housecleaning.company.shared.CleaningInstructions; 9 | import other.things.CleaningSupply; 10 | import other.things.CleaningTool; 11 | 12 | class Andrey implements Assistant { 13 | 14 | public static final Andrey PERSON = new Andrey(); 15 | 16 | private Storage storage = Storage.PLACE; 17 | 18 | private Andrey() { 19 | } 20 | 21 | @Override 22 | public List getNeededCleaningSupplies(CleaningInstructions instructions) { 23 | System.out.println("Andrey: pick cleaning supplies based on provided instructions"); 24 | List neededCleaningSupplies = new ArrayList<>(); 25 | for (CleaningSupply cleaningSupply : storage.getCleaningSupplies()) { 26 | // some filter logic here 27 | neededCleaningSupplies.add(cleaningSupply); 28 | } 29 | return neededCleaningSupplies; 30 | } 31 | 32 | @Override 33 | public List getNeededCleaningTools(CleaningInstructions instructions) { 34 | System.out.println("Andrey: pick cleaning tools based on provided instructions"); 35 | List neededCleaningTools = new ArrayList<>(); 36 | for (CleaningTool cleaningTool : storage.getCleaningTools()) { 37 | // some filter logic here 38 | neededCleaningTools.add(cleaningTool); 39 | } 40 | return neededCleaningTools; 41 | } 42 | 43 | @Override 44 | public void storeCleaningTools(List cleaningTools) { 45 | System.out.println("Andrey: putting cleaning tools in storage"); 46 | // 47 | } 48 | 49 | @Override 50 | public void storeCleaningSupplies(List cleaningSupplies) { 51 | System.out.println("Andrey: checking and putting cleaning supplies in storage"); 52 | for (CleaningSupply cleaningSupply : cleaningSupplies) { 53 | if (cleaningSupply.isEmpty()) { 54 | // purchase 55 | } 56 | } 57 | // 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "Andrey"; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-company/src/main/java/dja/housecleaning/company/internal/staff/Andrey.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.staff; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import dja.housecleaning.company.internal.assets.Storage; 7 | import dja.housecleaning.company.jobpositions.Assistant; 8 | import dja.housecleaning.company.shared.CleaningInstructions; 9 | import other.things.CleaningSupply; 10 | import other.things.CleaningTool; 11 | 12 | class Andrey implements Assistant { 13 | 14 | public static final Andrey PERSON = new Andrey(); 15 | 16 | private Storage storage = Storage.PLACE; 17 | 18 | private Andrey() { 19 | } 20 | 21 | @Override 22 | public List getNeededCleaningSupplies(CleaningInstructions instructions) { 23 | System.out.println("Andrey: pick cleaning supplies based on provided instructions"); 24 | List neededCleaningSupplies = new ArrayList<>(); 25 | for (CleaningSupply cleaningSupply : storage.getCleaningSupplies()) { 26 | // some filter logic here 27 | neededCleaningSupplies.add(cleaningSupply); 28 | } 29 | return neededCleaningSupplies; 30 | } 31 | 32 | @Override 33 | public List getNeededCleaningTools(CleaningInstructions instructions) { 34 | System.out.println("Andrey: pick cleaning tools based on provided instructions"); 35 | List neededCleaningTools = new ArrayList<>(); 36 | for (CleaningTool cleaningTool : storage.getCleaningTools()) { 37 | // some filter logic here 38 | neededCleaningTools.add(cleaningTool); 39 | } 40 | return neededCleaningTools; 41 | } 42 | 43 | @Override 44 | public void storeCleaningTools(List cleaningTools) { 45 | System.out.println("Andrey: putting cleaning tools in storage"); 46 | // 47 | } 48 | 49 | @Override 50 | public void storeCleaningSupplies(List cleaningSupplies) { 51 | System.out.println("Andrey: checking and putting cleaning supplies in storage"); 52 | for (CleaningSupply cleaningSupply : cleaningSupplies) { 53 | if (cleaningSupply.isEmpty()) { 54 | // purchase 55 | } 56 | } 57 | // 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "Andrey"; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-company/src/main/java/dja/housecleaning/company/internal/staff/Andrey.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.staff; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import dja.housecleaning.company.internal.assets.Storage; 7 | import dja.housecleaning.company.jobpositions.Assistant; 8 | import dja.housecleaning.company.shared.CleaningInstructions; 9 | import other.things.CleaningSupply; 10 | import other.things.CleaningTool; 11 | 12 | class Andrey implements Assistant { 13 | 14 | public static final Andrey PERSON = new Andrey(); 15 | 16 | private Storage storage = Storage.PLACE; 17 | 18 | private Andrey() { 19 | } 20 | 21 | @Override 22 | public List getNeededCleaningSupplies(CleaningInstructions instructions) { 23 | System.out.println("Andrey: pick cleaning supplies based on provided instructions"); 24 | List neededCleaningSupplies = new ArrayList<>(); 25 | for (CleaningSupply cleaningSupply : storage.getCleaningSupplies()) { 26 | // some filter logic here 27 | neededCleaningSupplies.add(cleaningSupply); 28 | } 29 | return neededCleaningSupplies; 30 | } 31 | 32 | @Override 33 | public List getNeededCleaningTools(CleaningInstructions instructions) { 34 | System.out.println("Andrey: pick cleaning tools based on provided instructions"); 35 | List neededCleaningTools = new ArrayList<>(); 36 | for (CleaningTool cleaningTool : storage.getCleaningTools()) { 37 | // some filter logic here 38 | neededCleaningTools.add(cleaningTool); 39 | } 40 | return neededCleaningTools; 41 | } 42 | 43 | @Override 44 | public void storeCleaningTools(List cleaningTools) { 45 | System.out.println("Andrey: putting cleaning tools in storage"); 46 | // 47 | } 48 | 49 | @Override 50 | public void storeCleaningSupplies(List cleaningSupplies) { 51 | System.out.println("Andrey: checking and putting cleaning supplies in storage"); 52 | for (CleaningSupply cleaningSupply : cleaningSupplies) { 53 | if (cleaningSupply.isEmpty()) { 54 | // purchase 55 | } 56 | } 57 | // 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "Andrey"; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /HouseCleaning8/HouseCleaning8-company/src/main/java/dja/housecleaning/company/internal/staff/Andrey.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company.internal.staff; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import dja.housecleaning.company.internal.assets.Storage; 7 | import dja.housecleaning.company.jobpositions.Assistant; 8 | import dja.housecleaning.company.shared.CleaningInstructions; 9 | import other.things.CleaningSupply; 10 | import other.things.CleaningTool; 11 | 12 | class Andrey implements Assistant { 13 | 14 | public static final Andrey PERSON = new Andrey(); 15 | 16 | private Storage storage = Storage.PLACE; 17 | 18 | private Andrey() { 19 | } 20 | 21 | @Override 22 | public List getNeededCleaningSupplies(CleaningInstructions instructions) { 23 | System.out.println("Andrey: pick cleaning supplies based on provided instructions"); 24 | List neededCleaningSupplies = new ArrayList<>(); 25 | for (CleaningSupply cleaningSupply : storage.getCleaningSupplies()) { 26 | // some filter logic here 27 | neededCleaningSupplies.add(cleaningSupply); 28 | } 29 | return neededCleaningSupplies; 30 | } 31 | 32 | @Override 33 | public List getNeededCleaningTools(CleaningInstructions instructions) { 34 | System.out.println("Andrey: pick cleaning tools based on provided instructions"); 35 | List neededCleaningTools = new ArrayList<>(); 36 | for (CleaningTool cleaningTool : storage.getCleaningTools()) { 37 | // some filter logic here 38 | neededCleaningTools.add(cleaningTool); 39 | } 40 | return neededCleaningTools; 41 | } 42 | 43 | @Override 44 | public void storeCleaningTools(List cleaningTools) { 45 | System.out.println("Andrey: putting cleaning tools in storage"); 46 | // 47 | } 48 | 49 | @Override 50 | public void storeCleaningSupplies(List cleaningSupplies) { 51 | System.out.println("Andrey: checking and putting cleaning supplies in storage"); 52 | for (CleaningSupply cleaningSupply : cleaningSupplies) { 53 | if (cleaningSupply.isEmpty()) { 54 | // purchase 55 | } 56 | } 57 | // 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "Andrey"; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-usecases/src/main/java/dja/housecleaning/usecases/CustomerUsecases.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.usecases; 2 | 3 | import java.util.List; 4 | 5 | import dja.housecleaning.company.jobpositions.Cleaner; 6 | import dja.housecleaning.company.processes.CleanHouseProcess; 7 | import dja.housecleaning.company.processes.NewOrderProcess; 8 | import dja.housecleaning.company.processes.PrepareForCleaningProcess; 9 | import dja.housecleaning.company.processes.TransportProcess; 10 | import dja.housecleaning.company.shared.CleaningInstructions; 11 | import dja.housecleaning.company.shared.InsufficientAmountException; 12 | import other.things.CleaningSupply; 13 | import other.things.CleaningTool; 14 | 15 | public class CustomerUsecases { 16 | 17 | public static CustomerUsecases GET = new CustomerUsecases(); 18 | 19 | public void cleanCustomerHouse(CleaningRequest cleaningRequest) { 20 | 21 | NewOrderProcess newOrderProcess = new NewOrderProcess(); 22 | PrepareForCleaningProcess prepareForCleaningProcess = new PrepareForCleaningProcess(); 23 | CleanHouseProcess cleanHouseProcess = new CleanHouseProcess(); 24 | TransportProcess transportProcess = new TransportProcess(); 25 | 26 | // check customer's order 27 | try { 28 | newOrderProcess.checkPayment(cleaningRequest.getPayment()); 29 | } catch (InsufficientAmountException e) { 30 | cleaningRequest.fixPayment(e.getExpected(), e.getReceived()); 31 | return; 32 | } 33 | 34 | CleaningInstructions cleaningInstructions = newOrderProcess.prepareInstructions(cleaningRequest.getAddress(), 35 | cleaningRequest.getInstructions()); 36 | 37 | // prepare 38 | List supplies = prepareForCleaningProcess.getCleaningSupplies(cleaningInstructions); 39 | List tools = prepareForCleaningProcess.getCleaningTools(cleaningInstructions); 40 | Cleaner cleaner = prepareForCleaningProcess.selectCleaner(cleaningInstructions); 41 | 42 | // send cleaner 43 | transportProcess.goTo(cleaningRequest.getAddress(), cleaner, supplies, tools); 44 | 45 | // clean 46 | cleanHouseProcess.cleanHouse(cleaner, cleaningInstructions); 47 | 48 | // make sure the cleaner can go back 49 | transportProcess.goTo("office", cleaner, supplies, tools); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /HouseCleaning4/HouseCleaning4-company/src/main/java/dja/housecleaning/Harry.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning; 2 | 3 | import java.util.List; 4 | 5 | import dja.housecleaning.backoffice.Andrey; 6 | import other.things.BookkeepingSystem; 7 | import other.things.CleaningSupply; 8 | import other.things.CleaningTool; 9 | import other.things.Van; 10 | 11 | public class Harry { 12 | 13 | public static final Harry PERSON = new Harry(); 14 | 15 | private BookkeepingSystem bookkeepingSystem = new BookkeepingSystem(); 16 | 17 | private Andrey andrey = Andrey.PERSON; 18 | 19 | private Garage garage = Garage.PLACE; 20 | 21 | private Harry() { 22 | } 23 | 24 | public void cleanHouseOrder (String address, String instructions, double money) { 25 | if (money < 100) { 26 | System.out.println("You need to pay me more!"); 27 | return; 28 | } 29 | 30 | List neededCleaningTools = andrey.getNeededCleaningTools(instructions); 31 | List neededCleaningSupplies = andrey.getNeededCleaningSupplies(instructions); 32 | 33 | Van myVan = garage.getVan(); 34 | myVan.load(neededCleaningTools); 35 | myVan.load(neededCleaningSupplies); 36 | myVan.addPassenger(this); 37 | myVan.drive(address); 38 | 39 | System.out.println("Harry: cleaning 💦"); 40 | System.out.println("Harry: done cleaning 🌟"); 41 | 42 | myVan.load(neededCleaningSupplies); 43 | myVan.load(neededCleaningSupplies); 44 | myVan.addPassenger(this); 45 | myVan.drive("back to my office"); 46 | 47 | andrey.storeCleaningSupplies(neededCleaningSupplies); 48 | andrey.storeCleaningTools(neededCleaningTools); 49 | 50 | bookkeepingSystem.recordIncome(money); 51 | } 52 | 53 | public Van borrowVan (String who) { 54 | if ("friend".equals(who)) { 55 | System.out.println("Harry: Here is my 🚚️"); 56 | return Garage.PLACE.getVan(); 57 | } 58 | System.out.println("Harry: I'm sorry but I don't know you!"); 59 | return null; 60 | } 61 | 62 | public List borrowTools (String who) { 63 | if ("friend".equals(who)) { 64 | System.out.println("Harry: Here are my 🛠️"); 65 | return Andrey.PERSON.getCleaningTools(); 66 | } 67 | System.out.println("Harry: I'm sorry but I don't know you!"); 68 | return null; 69 | } 70 | 71 | @Override 72 | public String toString() { 73 | return "Harry"; 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /HouseCleaning3/HouseCleaning3-company/src/main/java/dja/housecleaning/company/Harry.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.company; 2 | 3 | import java.util.List; 4 | 5 | import dja.housecleaning.assets.Garage; 6 | import dja.housecleaning.assets.Storage; 7 | import other.things.BookkeepingSystem; 8 | import other.things.CleaningSupply; 9 | import other.things.CleaningTool; 10 | import other.things.Van; 11 | 12 | public class Harry { 13 | 14 | public static final Harry PERSON = new Harry(); 15 | 16 | private BookkeepingSystem bookkeepingSystem = new BookkeepingSystem(); 17 | 18 | private Andrey andrey = Andrey.PERSON; 19 | 20 | private Garage garage = Garage.PLACE; 21 | 22 | private Harry() { 23 | } 24 | 25 | public void cleanHouseOrder (String address, String instructions, double money) { 26 | if (money < 100) { 27 | System.out.println("You need to pay me more!"); 28 | return; 29 | } 30 | 31 | List neededCleaningTools = andrey.getNeededCleaningTools(instructions); 32 | List neededCleaningSupplies = andrey.getNeededCleaningSupplies(instructions); 33 | 34 | Van myVan = garage.getVan(); 35 | myVan.load(neededCleaningTools); 36 | myVan.load(neededCleaningSupplies); 37 | myVan.addPassenger(this); 38 | myVan.drive(address); 39 | 40 | System.out.println("Harry: cleaning 💦"); 41 | System.out.println("Harry: done cleaning 🌟"); 42 | 43 | myVan.load(neededCleaningSupplies); 44 | myVan.load(neededCleaningSupplies); 45 | myVan.addPassenger(this); 46 | myVan.drive("back to my office"); 47 | 48 | andrey.storeCleaningSupplies(neededCleaningSupplies); 49 | andrey.storeCleaningTools(neededCleaningTools); 50 | 51 | bookkeepingSystem.recordIncome(money); 52 | } 53 | 54 | public Van borrowVan (String who) { 55 | if ("friend".equals(who)) { 56 | System.out.println("Harry: Here is my 🚚️"); 57 | return Garage.PLACE.getVan(); 58 | } 59 | System.out.println("Harry: I'm sorry but I don't know you!"); 60 | return null; 61 | } 62 | 63 | public List borrowTools (String who) { 64 | if ("friend".equals(who)) { 65 | System.out.println("Harry: Here are my 🛠️"); 66 | return Storage.PLACE.getCleaningTools(); 67 | } 68 | System.out.println("Harry: I'm sorry but I don't know you!"); 69 | return null; 70 | } 71 | 72 | @Override 73 | public String toString() { 74 | return "Harry"; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-usecases/src/main/java/dja/housecleaning/usecases/CustomerUsecases.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.usecases; 2 | 3 | import java.util.List; 4 | 5 | import dja.housecleaning.company.jobpositions.Cleaner; 6 | import dja.housecleaning.company.processes.CleanHouseProcess; 7 | import dja.housecleaning.company.processes.NewOrderProcess; 8 | import dja.housecleaning.company.processes.PrepareForCleaningProcess; 9 | import dja.housecleaning.company.processes.TransportProcess; 10 | import dja.housecleaning.company.shared.CleaningInstructions; 11 | import dja.housecleaning.company.shared.InsufficientAmountException; 12 | import other.things.CleaningSupply; 13 | import other.things.CleaningTool; 14 | 15 | public class CustomerUsecases { 16 | 17 | public static CustomerUsecases GET = new CustomerUsecases(); 18 | 19 | public void cleanCustomerHouse(CleaningRequest cleaningRequest) { 20 | 21 | NewOrderProcess newOrderProcess = new NewOrderProcess(); 22 | PrepareForCleaningProcess prepareForCleaningProcess = new PrepareForCleaningProcess(); 23 | CleanHouseProcess cleanHouseProcess = new CleanHouseProcess(); 24 | TransportProcess transportProcess = new TransportProcess(); 25 | if (!transportProcess.isVanFunctional()) { 26 | throw new RuntimeException("Uhhh seems like our van is broken! No way to go to the client 😢"); 27 | } 28 | 29 | // check customer's order 30 | try { 31 | newOrderProcess.checkPayment(cleaningRequest.getPayment()); 32 | } catch (InsufficientAmountException e) { 33 | cleaningRequest.fixPayment(e.getExpected(), e.getReceived()); 34 | return; 35 | } 36 | 37 | CleaningInstructions cleaningInstructions = newOrderProcess.prepareInstructions(cleaningRequest.getAddress(), 38 | cleaningRequest.getInstructions()); 39 | 40 | // prepare 41 | List supplies = prepareForCleaningProcess.getCleaningSupplies(cleaningInstructions); 42 | List tools = prepareForCleaningProcess.getCleaningTools(cleaningInstructions); 43 | Cleaner cleaner = prepareForCleaningProcess.selectCleaner(cleaningInstructions); 44 | 45 | // send cleaner 46 | transportProcess.goTo(cleaningRequest.getAddress(), cleaner, supplies, tools); 47 | 48 | // clean 49 | cleanHouseProcess.cleanHouse(cleaner, cleaningInstructions); 50 | 51 | // make sure the cleaner can go back 52 | transportProcess.goTo("office", cleaner, supplies, tools); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /HouseCleaning1/src/main/java/dja/housecleaning/client/Client.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.client; 2 | 3 | import java.io.IOException; 4 | import java.util.List; 5 | 6 | import org.jline.reader.LineReader; 7 | import org.jline.reader.LineReaderBuilder; 8 | import org.jline.reader.ParsedLine; 9 | import org.jline.reader.impl.completer.StringsCompleter; 10 | import org.jline.terminal.Terminal; 11 | import org.jline.terminal.TerminalBuilder; 12 | import org.jline.utils.AttributedStringBuilder; 13 | import org.jline.utils.AttributedStyle; 14 | 15 | import dja.housecleaning.Harry; 16 | import other.things.CleaningTool; 17 | import other.things.Van; 18 | 19 | public class Client { 20 | 21 | public static void main(String[] args) throws IOException { 22 | new Client(); 23 | } 24 | 25 | private Client() throws IOException { 26 | 27 | Terminal terminal = TerminalBuilder.terminal(); 28 | StringsCompleter completer = new StringsCompleter("exit", "clean", "borrowVan", "borrowTools"); 29 | 30 | LineReader reader = LineReaderBuilder.builder() 31 | .terminal(terminal) 32 | .completer(completer) 33 | .build(); 34 | 35 | String javaVersion = new AttributedStringBuilder() 36 | .style(AttributedStyle.DEFAULT.foreground(AttributedStyle.RED)) 37 | .append(System.getProperty("java.version")) 38 | .toAnsi(); 39 | System.out.println("Java version is: " + javaVersion); 40 | 41 | Harry harry = Harry.PERSON; 42 | String line; 43 | while (true) { 44 | line = reader.readLine("house cleaning > ").trim(); 45 | 46 | if (line.equalsIgnoreCase("quit") || line.equalsIgnoreCase("exit")) { 47 | break; 48 | } 49 | ParsedLine parsedLine = reader.getParser().parse(line, 0); 50 | String command = parsedLine.words().get(0); 51 | String param = parsedLine.words().size() > 1 ? parsedLine.words().get(1) : null; 52 | 53 | try { 54 | switch (command) { 55 | case "clean": 56 | harry.cleanHouse("some street", "clean the widows", 200); 57 | break; 58 | case "borrowVan": 59 | Van van = harry.borrowVan(param); 60 | van.drive("⛱️"); 61 | System.out.println("Client: I'm on vacation! Will be back next week! May be!"); 62 | break; 63 | case "borrowTools": 64 | List cleaningTools = harry.borrowTools(param); 65 | cleaningTools.clear(); 66 | System.out.println("Client: Opps I lost your 🛠️. I'm so sorry!"); 67 | break; 68 | default: 69 | break; 70 | } 71 | } catch (Exception e) { 72 | System.out.println(e.getMessage()); 73 | } 74 | } 75 | 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /HouseCleaning2/src/main/java/dja/housecleaning/Harry.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning; 2 | 3 | import java.util.List; 4 | 5 | import other.things.BookkeepingSystem; 6 | import other.things.CleaningSupply; 7 | import other.things.CleaningSupplyStore; 8 | import other.things.CleaningTool; 9 | import other.things.Van; 10 | 11 | class Harry { 12 | 13 | public static final Harry PERSON = new Harry(); 14 | 15 | private BookkeepingSystem bookkeepingSystem = new BookkeepingSystem(); 16 | 17 | private Harry() { 18 | Garage garage = Garage.PLACE; 19 | garage.add(new CleaningTool("vaccume cleaner")); 20 | garage.add(new CleaningTool("floor mop")); 21 | garage.add(new CleaningTool("glass wiper")); 22 | // ... 23 | garage.add(CleaningSupplyStore.purchase("carpet cleaner")); 24 | garage.add(CleaningSupplyStore.purchase("wood cleaner")); 25 | garage.add(CleaningSupplyStore.purchase("glass cleaner")); 26 | // ... 27 | } 28 | 29 | public void cleanHouseOrder (String address, String instructions, double money) { 30 | if (money < 100) { 31 | System.out.println("Harry: You need to pay me more!"); 32 | return; 33 | } 34 | Garage garage = Garage.PLACE; 35 | 36 | List neededCleaningTools = garage.getNeededCleaningTools(instructions); 37 | List neededCleaningSupplies = garage.getNeededCleaningSupplies(instructions); 38 | 39 | Van myVan = garage.getVan(); 40 | myVan.load(neededCleaningTools); 41 | myVan.load(neededCleaningSupplies); 42 | myVan.addPassenger(this); 43 | myVan.drive(address); 44 | 45 | System.out.println("Harry: cleaning 💦"); 46 | System.out.println("Harry: done cleaning 🌟"); 47 | 48 | myVan.load(neededCleaningTools); 49 | myVan.load(neededCleaningSupplies); 50 | myVan.addPassenger(this); 51 | myVan.drive("back to my office"); 52 | 53 | System.out.println("Harry: Checking supplies "); 54 | for (CleaningSupply cleaningSupply : neededCleaningSupplies) { 55 | if (cleaningSupply.isEmpty()) { 56 | // purchase 57 | } 58 | } 59 | 60 | bookkeepingSystem.recordIncome(money); 61 | } 62 | 63 | public Van borrowVan (String who) { 64 | if ("friend".equals(who)) { 65 | System.out.println("Harry: Here is my 🚚️"); 66 | return Garage.PLACE.getVan(); 67 | } 68 | System.out.println("Harry: I'm sorry but I don't know you!"); 69 | return null; 70 | } 71 | 72 | public List borrowTools (String who) { 73 | if ("friend".equals(who)) { 74 | System.out.println("Harry: Here are my 🛠️"); 75 | return Garage.PLACE.getCleaningTools(); 76 | } 77 | System.out.println("Harry: I'm sorry but I don't know you!"); 78 | return null; 79 | } 80 | 81 | @Override 82 | public String toString() { 83 | return "Harry"; 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /HouseCleaning2/src/main/java/dja/housecleaning/client/Client.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.client; 2 | 3 | import java.io.IOException; 4 | import java.lang.reflect.Method; 5 | import java.util.List; 6 | 7 | import org.jline.reader.LineReader; 8 | import org.jline.reader.LineReaderBuilder; 9 | import org.jline.reader.ParsedLine; 10 | import org.jline.reader.impl.completer.StringsCompleter; 11 | import org.jline.terminal.Terminal; 12 | import org.jline.terminal.TerminalBuilder; 13 | import org.jline.utils.AttributedStringBuilder; 14 | import org.jline.utils.AttributedStyle; 15 | 16 | import dja.housecleaning.OrderForm; 17 | import dja.housecleaning.Ronald; 18 | import other.things.CleaningTool; 19 | import other.things.Van; 20 | 21 | public class Client { 22 | 23 | public static void main(String[] args) throws IOException { 24 | new Client(); 25 | } 26 | 27 | private Client() throws IOException { 28 | 29 | Terminal terminal = TerminalBuilder.terminal(); 30 | StringsCompleter completer = new StringsCompleter("exit", "clean", "borrowVan", "borrowTools"); 31 | 32 | LineReader reader = LineReaderBuilder.builder() 33 | .terminal(terminal) 34 | .completer(completer) 35 | .build(); 36 | 37 | String javaVersion = new AttributedStringBuilder() 38 | .style(AttributedStyle.DEFAULT.foreground(AttributedStyle.RED)) 39 | .append(System.getProperty("java.version")) 40 | .toAnsi(); 41 | System.out.println("Java version is: " + javaVersion); 42 | 43 | Ronald ronald = Ronald.PERSON; 44 | String line; 45 | while (true) { 46 | line = reader.readLine("house cleaning > ").trim(); 47 | 48 | if (line.equalsIgnoreCase("quit") || line.equalsIgnoreCase("exit")) { 49 | break; 50 | } 51 | ParsedLine parsedLine = reader.getParser().parse(line, 0); 52 | String command = parsedLine.words().get(0); 53 | String param = parsedLine.words().size() > 1 ? parsedLine.words().get(1) : null; 54 | 55 | try { 56 | switch (command) { 57 | case "clean": 58 | OrderForm orderForm = ronald.getOrderForm(); 59 | orderForm.setAddress("some street"); 60 | orderForm.setInstructions("clean the floor"); 61 | ronald.cleanMyHousePlease(orderForm, 200); 62 | break; 63 | case "borrowVan": 64 | Method borrowVan = ronald.getClass().getMethod("borrowVan", String.class); 65 | Van van = (Van)borrowVan.invoke(ronald, param); 66 | van.drive("⛱️"); 67 | System.out.println("Client: I'm on vacation! Will be back next week! May be!"); 68 | break; 69 | case "borrowTools": 70 | Method borrowTools = ronald.getClass().getMethod("borrowTools", String.class); 71 | List cleaningTools = (List)borrowTools.invoke(ronald, param); 72 | cleaningTools.clear(); 73 | System.out.println("Client: Opps I lost your 🛠️. I'm so sorry!"); 74 | break; 75 | default: 76 | break; 77 | } 78 | } catch (Exception e) { 79 | System.out.println(e.getMessage()); 80 | } 81 | } 82 | 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /HouseCleaning3/HouseCleaning3-client/src/main/java/dja/housecleaning/client/Client.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.client; 2 | 3 | import java.io.IOException; 4 | import java.lang.reflect.Method; 5 | import java.util.List; 6 | 7 | import org.jline.reader.LineReader; 8 | import org.jline.reader.LineReaderBuilder; 9 | import org.jline.reader.ParsedLine; 10 | import org.jline.reader.impl.completer.StringsCompleter; 11 | import org.jline.terminal.Terminal; 12 | import org.jline.terminal.TerminalBuilder; 13 | import org.jline.utils.AttributedStringBuilder; 14 | import org.jline.utils.AttributedStyle; 15 | 16 | import dja.housecleaning.front.OrderForm; 17 | import dja.housecleaning.front.Ronald; 18 | import other.things.CleaningTool; 19 | import other.things.Van; 20 | 21 | public class Client { 22 | 23 | public static void main(String[] args) throws IOException { 24 | new Client(); 25 | } 26 | 27 | private Client() throws IOException { 28 | 29 | Terminal terminal = TerminalBuilder.terminal(); 30 | StringsCompleter completer = new StringsCompleter("exit", "clean", "borrowVan", "borrowTools"); 31 | 32 | LineReader reader = LineReaderBuilder.builder() 33 | .terminal(terminal) 34 | .completer(completer) 35 | .build(); 36 | 37 | String javaVersion = new AttributedStringBuilder() 38 | .style(AttributedStyle.DEFAULT.foreground(AttributedStyle.RED)) 39 | .append(System.getProperty("java.version")) 40 | .toAnsi(); 41 | System.out.println("Java version is: " + javaVersion); 42 | 43 | Ronald ronald = Ronald.PERSON; 44 | String line; 45 | while (true) { 46 | line = reader.readLine("house cleaning > ").trim(); 47 | 48 | if (line.equalsIgnoreCase("quit") || line.equalsIgnoreCase("exit")) { 49 | break; 50 | } 51 | ParsedLine parsedLine = reader.getParser().parse(line, 0); 52 | String command = parsedLine.words().get(0); 53 | String param = parsedLine.words().size() > 1 ? parsedLine.words().get(1) : null; 54 | 55 | try { 56 | switch (command) { 57 | case "clean": 58 | OrderForm orderForm = ronald.getOrderForm(); 59 | orderForm.setAddress("some street"); 60 | orderForm.setInstructions("clean the floor"); 61 | ronald.cleanMyHousePlease(orderForm, 200); 62 | break; 63 | case "borrowVan": 64 | Method borrowVan = ronald.getClass().getMethod("borrowVan", String.class); 65 | Van van = (Van)borrowVan.invoke(ronald, param); 66 | van.drive("⛱️"); 67 | System.out.println("Client: I'm on vacation! Will be back next week! May be!"); 68 | break; 69 | case "borrowTools": 70 | Method borrowTools = ronald.getClass().getMethod("borrowTools", String.class); 71 | List cleaningTools = (List)borrowTools.invoke(ronald, param); 72 | cleaningTools.clear(); 73 | System.out.println("Client: Opps I lost your 🛠️. I'm so sorry!"); 74 | break; 75 | default: 76 | break; 77 | } 78 | } catch (Exception e) { 79 | e.printStackTrace(); 80 | } 81 | } 82 | 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /HouseCleaning4/HouseCleaning4-client/src/main/java/dja/housecleaning/client/Client.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.client; 2 | 3 | import java.io.IOException; 4 | import java.lang.reflect.Method; 5 | import java.util.List; 6 | 7 | import org.jline.reader.LineReader; 8 | import org.jline.reader.LineReaderBuilder; 9 | import org.jline.reader.ParsedLine; 10 | import org.jline.reader.impl.completer.StringsCompleter; 11 | import org.jline.terminal.Terminal; 12 | import org.jline.terminal.TerminalBuilder; 13 | import org.jline.utils.AttributedStringBuilder; 14 | import org.jline.utils.AttributedStyle; 15 | 16 | import dja.housecleaning.frontoffice.OrderForm; 17 | import dja.housecleaning.frontoffice.Ronald; 18 | import other.things.CleaningTool; 19 | import other.things.Van; 20 | 21 | public class Client { 22 | 23 | public static void main(String[] args) throws IOException { 24 | new Client(); 25 | } 26 | 27 | private Client() throws IOException { 28 | 29 | Terminal terminal = TerminalBuilder.terminal(); 30 | StringsCompleter completer = new StringsCompleter("exit", "clean", "borrowVan", "borrowTools"); 31 | 32 | LineReader reader = LineReaderBuilder.builder() 33 | .terminal(terminal) 34 | .completer(completer) 35 | .build(); 36 | 37 | String javaVersion = new AttributedStringBuilder() 38 | .style(AttributedStyle.DEFAULT.foreground(AttributedStyle.RED)) 39 | .append(System.getProperty("java.version")) 40 | .toAnsi(); 41 | System.out.println("Java version is: " + javaVersion); 42 | 43 | Ronald ronald = Ronald.PERSON; 44 | String line; 45 | while (true) { 46 | line = reader.readLine("house cleaning > ").trim(); 47 | 48 | if (line.equalsIgnoreCase("quit") || line.equalsIgnoreCase("exit")) { 49 | break; 50 | } 51 | ParsedLine parsedLine = reader.getParser().parse(line, 0); 52 | String command = parsedLine.words().get(0); 53 | String param = parsedLine.words().size() > 1 ? parsedLine.words().get(1) : null; 54 | 55 | try { 56 | switch (command) { 57 | case "clean": 58 | OrderForm orderForm = ronald.getOrderForm(); 59 | orderForm.setAddress("some street"); 60 | orderForm.setInstructions("clean the floor"); 61 | ronald.cleanMyHousePlease(orderForm, 200); 62 | break; 63 | case "borrowVan": 64 | Method borrowVan = ronald.getClass().getMethod("borrowVan", String.class); 65 | Van van = (Van)borrowVan.invoke(ronald, param); 66 | van.drive("⛱️"); 67 | System.out.println("Client: I'm on vacation! Will be back next week! May be!"); 68 | break; 69 | case "borrowTools": 70 | Method borrowTools = ronald.getClass().getMethod("borrowTools", String.class); 71 | List cleaningTools = (List)borrowTools.invoke(ronald, param); 72 | cleaningTools.clear(); 73 | System.out.println("Client: Opps I lost your 🛠️. I'm so sorry!"); 74 | break; 75 | default: 76 | break; 77 | } 78 | } catch (Exception e) { 79 | e.printStackTrace(); 80 | } 81 | } 82 | 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /HouseCleaning5/HouseCleaning5-client/src/main/java/dja/housecleaning/client/Client.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.client; 2 | 3 | import java.io.IOException; 4 | import java.lang.reflect.Method; 5 | import java.util.List; 6 | 7 | import org.jline.reader.LineReader; 8 | import org.jline.reader.LineReaderBuilder; 9 | import org.jline.reader.ParsedLine; 10 | import org.jline.reader.impl.completer.StringsCompleter; 11 | import org.jline.terminal.Terminal; 12 | import org.jline.terminal.TerminalBuilder; 13 | import org.jline.utils.AttributedStringBuilder; 14 | import org.jline.utils.AttributedStyle; 15 | 16 | import dja.housecleaning.frontoffice.FrontOffice; 17 | import dja.housecleaning.frontoffice.OrderForm; 18 | import other.things.CleaningTool; 19 | import other.things.Van; 20 | 21 | public class Client { 22 | 23 | public static void main(String[] args) throws IOException { 24 | new Client(); 25 | } 26 | 27 | private Client() throws IOException { 28 | 29 | Terminal terminal = TerminalBuilder.terminal(); 30 | StringsCompleter completer = new StringsCompleter("exit", "clean", "borrowVan", "borrowTools"); 31 | 32 | LineReader reader = LineReaderBuilder.builder() 33 | .terminal(terminal) 34 | .completer(completer) 35 | .build(); 36 | 37 | String javaVersion = new AttributedStringBuilder() 38 | .style(AttributedStyle.DEFAULT.foreground(AttributedStyle.RED)) 39 | .append(System.getProperty("java.version")) 40 | .toAnsi(); 41 | System.out.println("Java version is: " + javaVersion); 42 | 43 | FrontOffice frontOffice = FrontOffice.PLACE; 44 | String line; 45 | while (true) { 46 | line = reader.readLine("house cleaning > ").trim(); 47 | 48 | if (line.equalsIgnoreCase("quit") || line.equalsIgnoreCase("exit")) { 49 | break; 50 | } 51 | ParsedLine parsedLine = reader.getParser().parse(line, 0); 52 | String command = parsedLine.words().get(0); 53 | String param = parsedLine.words().size() > 1 ? parsedLine.words().get(1) : null; 54 | 55 | try { 56 | switch (command) { 57 | case "clean": 58 | OrderForm orderForm = new OrderForm(); 59 | orderForm.setAddress("some street"); 60 | orderForm.addInstruction("clean the floor"); 61 | frontOffice.cleanMyHousePlease(orderForm, param); 62 | break; 63 | case "borrowVan": 64 | Method borrowVan = frontOffice.getClass().getMethod("borrowVan", String.class); 65 | Van van = (Van)borrowVan.invoke(frontOffice, param); 66 | van.drive("⛱️"); 67 | System.out.println("Client: I'm on vacation! Will be back next week! May be!"); 68 | break; 69 | case "borrowTools": 70 | Method borrowTools = frontOffice.getClass().getMethod("borrowTools", String.class); 71 | List cleaningTools = (List)borrowTools.invoke(frontOffice, param); 72 | cleaningTools.clear(); 73 | System.out.println("Client: Opps I lost your 🛠️. I'm so sorry!"); 74 | break; 75 | default: 76 | break; 77 | } 78 | } catch (Exception e) { 79 | e.printStackTrace(); 80 | } 81 | } 82 | 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /HouseCleaning6/HouseCleaning6-client/src/main/java/dja/housecleaning/client/Client.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.client; 2 | 3 | import java.io.IOException; 4 | import java.lang.reflect.Method; 5 | import java.util.List; 6 | 7 | import org.jline.reader.LineReader; 8 | import org.jline.reader.LineReaderBuilder; 9 | import org.jline.reader.ParsedLine; 10 | import org.jline.reader.impl.completer.StringsCompleter; 11 | import org.jline.terminal.Terminal; 12 | import org.jline.terminal.TerminalBuilder; 13 | import org.jline.utils.AttributedStringBuilder; 14 | import org.jline.utils.AttributedStyle; 15 | 16 | import dja.housecleaning.frontoffice.FrontOffice; 17 | import dja.housecleaning.frontoffice.OrderForm; 18 | import other.things.CleaningTool; 19 | import other.things.Van; 20 | 21 | public class Client { 22 | 23 | public static void main(String[] args) throws IOException { 24 | new Client(); 25 | } 26 | 27 | private Client() throws IOException { 28 | 29 | Terminal terminal = TerminalBuilder.terminal(); 30 | StringsCompleter completer = new StringsCompleter("exit", "clean EUR100", "borrowVan", "borrowTools"); 31 | 32 | LineReader reader = LineReaderBuilder.builder() 33 | .terminal(terminal) 34 | .completer(completer) 35 | .build(); 36 | 37 | String javaVersion = new AttributedStringBuilder() 38 | .style(AttributedStyle.DEFAULT.foreground(AttributedStyle.RED)) 39 | .append(System.getProperty("java.version")) 40 | .toAnsi(); 41 | System.out.println("Java version is: " + javaVersion); 42 | 43 | FrontOffice frontOffice = FrontOffice.PLACE; 44 | String line; 45 | while (true) { 46 | line = reader.readLine("house cleaning > ").trim(); 47 | 48 | if (line.equalsIgnoreCase("quit") || line.equalsIgnoreCase("exit")) { 49 | break; 50 | } 51 | ParsedLine parsedLine = reader.getParser().parse(line, 0); 52 | String command = parsedLine.words().get(0); 53 | String param = parsedLine.words().size() > 1 ? parsedLine.words().get(1) : null; 54 | 55 | try { 56 | switch (command) { 57 | case "clean": 58 | OrderForm orderForm = new OrderForm(); 59 | orderForm.setAddress("some street"); 60 | orderForm.addInstruction("clean the floor"); 61 | frontOffice.cleanMyHousePlease(orderForm, param); 62 | break; 63 | case "borrowVan": 64 | Method borrowVan = frontOffice.getClass().getMethod("borrowVan", String.class); 65 | Van van = (Van)borrowVan.invoke(frontOffice, param); 66 | van.drive("⛱️"); 67 | System.out.println("Client: I'm on vacation! Will be back next week! May be!"); 68 | break; 69 | case "borrowTools": 70 | Method borrowTools = frontOffice.getClass().getMethod("borrowTools", String.class); 71 | List cleaningTools = (List)borrowTools.invoke(frontOffice, param); 72 | cleaningTools.clear(); 73 | System.out.println("Client: Opps I lost your 🛠️. I'm so sorry!"); 74 | break; 75 | default: 76 | break; 77 | } 78 | } catch (Exception e) { 79 | e.printStackTrace(); 80 | } 81 | } 82 | 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /HouseCleaning7/HouseCleaning7-client/src/main/java/dja/housecleaning/client/Client.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning.client; 2 | 3 | import java.io.IOException; 4 | import java.lang.reflect.Method; 5 | import java.util.List; 6 | 7 | import org.jline.reader.LineReader; 8 | import org.jline.reader.LineReaderBuilder; 9 | import org.jline.reader.ParsedLine; 10 | import org.jline.reader.impl.completer.StringsCompleter; 11 | import org.jline.terminal.Terminal; 12 | import org.jline.terminal.TerminalBuilder; 13 | import org.jline.utils.AttributedStringBuilder; 14 | import org.jline.utils.AttributedStyle; 15 | 16 | import dja.housecleaning.frontoffice.FrontOffice; 17 | import dja.housecleaning.frontoffice.OrderForm; 18 | import other.things.CleaningTool; 19 | import other.things.Van; 20 | 21 | public class Client { 22 | 23 | public static void main(String[] args) throws IOException { 24 | new Client(); 25 | } 26 | 27 | private Client() throws IOException { 28 | 29 | Terminal terminal = TerminalBuilder.terminal(); 30 | StringsCompleter completer = new StringsCompleter("exit", "clean EUR100", "borrowVan", "borrowTools"); 31 | 32 | LineReader reader = LineReaderBuilder.builder() 33 | .terminal(terminal) 34 | .completer(completer) 35 | .build(); 36 | 37 | String javaVersion = new AttributedStringBuilder() 38 | .style(AttributedStyle.DEFAULT.foreground(AttributedStyle.RED)) 39 | .append(System.getProperty("java.version")) 40 | .toAnsi(); 41 | System.out.println("Java version is: " + javaVersion); 42 | 43 | FrontOffice frontOffice = FrontOffice.PLACE; 44 | String line; 45 | while (true) { 46 | line = reader.readLine("house cleaning > ").trim(); 47 | 48 | if (line.equalsIgnoreCase("quit") || line.equalsIgnoreCase("exit")) { 49 | break; 50 | } 51 | ParsedLine parsedLine = reader.getParser().parse(line, 0); 52 | String command = parsedLine.words().get(0); 53 | String param = parsedLine.words().size() > 1 ? parsedLine.words().get(1) : null; 54 | 55 | try { 56 | switch (command) { 57 | case "clean": 58 | OrderForm orderForm = new OrderForm(); 59 | orderForm.setAddress("some street"); 60 | orderForm.addInstruction("clean the floor"); 61 | frontOffice.cleanMyHousePlease(orderForm, param); 62 | break; 63 | case "borrowVan": 64 | Method borrowVan = frontOffice.getClass().getMethod("borrowVan", String.class); 65 | Van van = (Van)borrowVan.invoke(frontOffice, param); 66 | van.drive("⛱️"); 67 | System.out.println("Client: I'm on vacation! Will be back next week! May be!"); 68 | break; 69 | case "borrowTools": 70 | Method borrowTools = frontOffice.getClass().getMethod("borrowTools", String.class); 71 | List cleaningTools = (List)borrowTools.invoke(frontOffice, param); 72 | cleaningTools.clear(); 73 | System.out.println("Client: Opps I lost your 🛠️. I'm so sorry!"); 74 | break; 75 | default: 76 | break; 77 | } 78 | } catch (Exception e) { 79 | e.printStackTrace(); 80 | } 81 | } 82 | 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /HouseCleaning1/src/main/java/dja/housecleaning/Harry.java: -------------------------------------------------------------------------------- 1 | package dja.housecleaning; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import other.things.BookkeepingSystem; 7 | import other.things.CleaningSupply; 8 | import other.things.CleaningSupplyStore; 9 | import other.things.CleaningTool; 10 | import other.things.Van; 11 | 12 | public class Harry { 13 | 14 | private List myCleaningTools = new ArrayList<>(); 15 | private List myCleaningSupplies = new ArrayList<>(); 16 | private Van myVan = new Van(); 17 | private BookkeepingSystem bookkeepingSystem = new BookkeepingSystem(); 18 | 19 | public static final Harry PERSON = new Harry(); 20 | 21 | private Harry() { 22 | myCleaningTools.add(new CleaningTool("vaccume cleaner")); 23 | myCleaningTools.add(new CleaningTool("floor mop")); 24 | myCleaningTools.add(new CleaningTool("glass wiper")); 25 | // ... 26 | myCleaningSupplies.add(CleaningSupplyStore.purchase("carpet cleaner")); 27 | myCleaningSupplies.add(CleaningSupplyStore.purchase("wood cleaner")); 28 | myCleaningSupplies.add(CleaningSupplyStore.purchase("glass cleaner")); 29 | // ... 30 | } 31 | 32 | public void cleanHouse (String address, String instructions, double money) { 33 | if (money < 100) { 34 | System.out.println("Harry: You need to pay me more!"); 35 | return; 36 | } 37 | 38 | System.out.println("Harry: Pick cleaning supplies based on provided instructions"); 39 | List neededCleaningTools = new ArrayList<>(); 40 | for (CleaningTool cleaningTool : myCleaningTools) { 41 | // some filter logic here 42 | neededCleaningTools.add(cleaningTool); 43 | } 44 | 45 | System.out.println("Harry: Pick cleaning tools based on provided instructions"); 46 | List neededCleaningSupplies = new ArrayList<>(); 47 | for (CleaningSupply cleaningSupply : myCleaningSupplies) { 48 | // some filter logic here 49 | neededCleaningSupplies.add(cleaningSupply); 50 | } 51 | 52 | myVan.load(myCleaningSupplies); 53 | myVan.load(myCleaningTools); 54 | myVan.addPassenger(this); 55 | myVan.drive(address); 56 | 57 | System.out.println("Harry: cleaning 💦"); 58 | System.out.println("Harry: done cleaning 🌟"); 59 | 60 | myVan.load(myCleaningSupplies); 61 | myVan.load(myCleaningTools); 62 | myVan.addPassenger(this); 63 | myVan.drive("back to my office"); 64 | 65 | System.out.println("Harry: Checking supplies "); 66 | for (CleaningSupply cleaningSupply : neededCleaningSupplies) { 67 | if (cleaningSupply.isEmpty()) { 68 | // purchase 69 | } 70 | } 71 | 72 | bookkeepingSystem.recordIncome(money); 73 | } 74 | 75 | public Van borrowVan (String who) { 76 | if ("friend".equals(who)) { 77 | System.out.println("Harry: Here is my 🚚️"); 78 | return myVan; 79 | } 80 | System.out.println("Harry: I'm sorry but I don't know you!"); 81 | return null; 82 | } 83 | 84 | public List borrowTools (String who) { 85 | if ("friend".equals(who)) { 86 | System.out.println("Harry: Here are my 🛠️"); 87 | return myCleaningTools; 88 | } 89 | System.out.println("Harry: I'm sorry but I don't know you!"); 90 | return null; 91 | } 92 | 93 | @Override 94 | public String toString() { 95 | return "Harry"; 96 | } 97 | } 98 | --------------------------------------------------------------------------------