Skip to content

Commit

Permalink
Merge pull request #6 from ncryptedV1/dev
Browse files Browse the repository at this point in the history
Dev to main
  • Loading branch information
cuvar authored Apr 9, 2023
2 parents de82653 + 0f34416 commit d62b8f8
Show file tree
Hide file tree
Showing 32 changed files with 1,843 additions and 9 deletions.
1,125 changes: 1,119 additions & 6 deletions README.md

Large diffs are not rendered by default.

Binary file added docs/res/cov.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions src/main/java/de/cunc/autochef/domain/aggregate/MealPlan.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@ public class MealPlan {
private LocalDate end;

public MealPlan(List<Meal> meals, LocalDate start, LocalDate end) {
int days = start.until(end).getDays();
this.start = start;
this.end = end;

int days = getDays();
if (meals.size() != days) {
throw new IllegalArgumentException(
"Mahlzeiten-Plan spannt " + days + " Tage, es wurden allerdings nur " + meals.size()
+ " Mahlzeiten übergeben");
}

this.meals = meals;
this.start = start;
this.end = end;
}

public List<Meal> getMeals() {
Expand Down
36 changes: 36 additions & 0 deletions uml/aggregate.iuml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@startuml

left to right direction

'class MealPlan {
' - meals: List<Meal>
' - start: LocalDate
' - end: LocalDate
' + getMeals(): List<Meal>
' + getStart(): LocalDate
' + getEnd(): LocalDate
' + getDays(): int
' + getGroceryList(): GroceryList
'}

class Meal {
- recipe: Recipe
- adjustedNumberOfPeople: int
+ Meal(recipe: Recipe, adjustedNumberOfPeople: int)
+ getRecipe(): Recipe
+ setRecipe(recipe: Recipe): void
+ getAdjustedNumberOfPeople(): int
+ getGroceryList(): GroceryList
}

'class GroceryList {
' - items: List<GroceryItem>
' + addItem(GroceryItem entry): void
' + getItems(): List<GroceryItem>
'}
'
'MealPlan <- GroceryList
'MealPlan <- Meal
'Meal <- GroceryList

@enduml
27 changes: 27 additions & 0 deletions uml/cohesion.iuml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@startuml
class Recipe {
- name: String
- groceryList: GroceryList
- recipeSteps: List<RecipeStep>
+ Recipe(name: String, groceryList: GroceryList, recipeSteps: List<RecipeStep>)
+ Recipe(name: String, groceryList: GroceryList, recipeSteps: RecipeStep...)
+ getName(): String
+ getRecipeSteps(): List<RecipeStep>
+ getGroceryList(): GroceryList
+ getId(): String
+ toString(): String
+ equals(Object o): boolean
+ hashCode(): int
}

class GroceryList {
// fields and methods
}

class RecipeStep {
// fields and methods
}

Recipe "1" --> "1" GroceryList
Recipe "0..*" --> "1" RecipeStep
@enduml
38 changes: 38 additions & 0 deletions uml/coupling-neg-better.iuml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@startuml

left to right direction

class ChefkochRecipeFetcher {
+getRecipe(url: String): Recipe
-extractRecipeName(content: String): String
-extractIngredients(content: String): GroceryList
-extractRecipeSteps(content: String): List<RecipeStep>
}

interface WebsiteFetcher {
+getWebsiteBody(urlString: String): String
}

class BufferedWebsiteFetcher {
+getWebsiteBody(urlString: String): String
}

class Recipe {
// fields and methods
}

class GroceryList {
// fields and methods
}

class RecipeStep {
// fields and methods
}

WebsiteFetcher <-- ChefkochRecipeFetcher
WebsiteFetcher <|.. BufferedWebsiteFetcher
Recipe <-- ChefkochRecipeFetcher
GroceryList <-- ChefkochRecipeFetcher
RecipeStep <-- ChefkochRecipeFetcher

@enduml
33 changes: 33 additions & 0 deletions uml/coupling-neg.iuml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@startuml

left to right direction

class ChefkochRecipeFetcher {
+getRecipe(url: String): Recipe
-extractRecipeName(content: String): String
-extractIngredients(content: String): GroceryList
-extractRecipeSteps(content: String): List<RecipeStep>
}

class WebsiteFetcher {
+getWebsiteBody(urlString: String): String
}

class Recipe {
// fields and methods
}

class GroceryList {
// fields and methods
}

class RecipeStep {
// fields and methods
}

WebsiteFetcher <-- ChefkochRecipeFetcher
Recipe <-- ChefkochRecipeFetcher
GroceryList <-- ChefkochRecipeFetcher
RecipeStep <-- ChefkochRecipeFetcher

@enduml
32 changes: 32 additions & 0 deletions uml/coupling-pos-1.iuml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@startuml

interface InputReader {
+readLine(): String
}

interface OutputService {
+info(msg: String): void
+warning(msg: String): void
+severe(msg: String): void
+rawOut(msg: Object): void
+rawErr(msg: Object): void
}

interface InputParser {
+getInteger(lowerBound: Integer, upperBound: Integer, question: String): Integer
+getDate(after: LocalDate, before: LocalDate, question: String): LocalDate
+getString(validator: Function<String, String>, question: String): String
}

class DialogInputParser {
-inputReader: InputReader
-outputService: OutputService
+DialogInputParser(inputReader: InputReader, outputService: OutputService)
+getInputWithType(transformFunction: Function<String, T>, question: String): T
}

InputParser <|.. DialogInputParser
DialogInputParser --> InputReader
DialogInputParser --> OutputService

@enduml
26 changes: 26 additions & 0 deletions uml/coupling-pos-2.iuml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@startuml

class Recipe {
// fields and methods
}

class RecipeFileRepository {
-recipesFolder: File
+RecipeFileRepository(recipesFolder: File)
+saveRecipe(recipe: Recipe): void
+deleteRecipe(recipe: Recipe): boolean
+getRecipes(): List<Recipe>
+getRecipe(id: String): Recipe
}

interface RecipeRepository {
+saveRecipe(recipe: Recipe): void
+deleteRecipe(recipe: Recipe): boolean
+getRecipes(): List<Recipe>
+getRecipe(id: String): Recipe
}

RecipeFileRepository ..|> RecipeRepository
RecipeRepository -> Recipe

@enduml
25 changes: 25 additions & 0 deletions uml/dependency-inversion-neg.iuml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@startuml

left to right direction

package "Infrastructure" {
class WebsiteFetcher {
+ getWebsiteBody(urlString: String)
}

package "Application" {
class ChefkochRecipeFetcher {
+ getRecipe(url: String)
- extractRecipeName(content: String)
- extractIngredients(content: String)
- extractRecipeSteps(content: String)
}

package "Domain" {
}
}
}

ChefkochRecipeFetcher -> WebsiteFetcher

@enduml
35 changes: 35 additions & 0 deletions uml/dependency-inversion-pos.iuml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@startuml

left to right direction

package "Infrastructure" {
class RecipeFileRepository {
- recipesFolder: File
+ RecipeFileRepository(recipesFolder: File)
+ saveRecipe(recipe: Recipe)
+ deleteRecipe(recipe: Recipe): boolean
+ getRecipes(): List<Recipe>
+ getRecipe(id: String): Recipe
}

package "Application" {
class DialogService {
- recipeRepository: RecipeRepository
+ DialogService(recipeRepository: RecipeRepository)
}

package "Domain" {
interface RecipeRepository {
+ saveRecipe(recipe: Recipe)
+ deleteRecipe(recipe: Recipe): boolean
+ getRecipes(): List<Recipe>
+ getRecipe(id: String): Recipe
}
}
}
}

DialogService -> RecipeRepository
RecipeRepository <|.. RecipeFileRepository

@enduml
31 changes: 31 additions & 0 deletions uml/dependency-rule-neg.iuml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@startuml

left to right direction

package "Infrastructure" {
class WebsiteFetcher {
+ getWebsiteBody(urlString: String)
}

package "Application" {
class ChefkochRecipeFetcher {
+ getRecipe(url: String)
- extractRecipeName(content: String)
- extractIngredients(content: String)
- extractRecipeSteps(content: String)
}

class DialogService {
- recipeRepository: RecipeRepository
+ DialogService(recipeRepository: RecipeRepository)
}

package "Domain" {
}
}
}

DialogService -> ChefkochRecipeFetcher
ChefkochRecipeFetcher -> WebsiteFetcher

@enduml
41 changes: 41 additions & 0 deletions uml/dependency-rule-pos.iuml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
@startuml

left to right direction

package "Infrastructure" {
class AutoChef {
+ main(args: String[])
}

class RecipeFileRepository {
- recipesFolder: File
+ RecipeFileRepository(recipesFolder: File)
+ saveRecipe(recipe: Recipe)
+ deleteRecipe(recipe: Recipe): boolean
+ getRecipes(): List<Recipe>
+ getRecipe(id: String): Recipe
}

package "Application" {
class DialogService {
- recipeRepository: RecipeRepository
+ DialogService(recipeRepository: RecipeRepository)
}

package "Domain" {
interface RecipeRepository {
+ saveRecipe(recipe: Recipe)
+ deleteRecipe(recipe: Recipe): boolean
+ getRecipes(): List<Recipe>
+ getRecipe(id: String): Recipe
}
}
}
}

AutoChef -> DialogService
AutoChef -> RecipeFileRepository
DialogService -> RecipeRepository
RecipeRepository <|.. RecipeFileRepository

@enduml
27 changes: 27 additions & 0 deletions uml/design-pattern-builder.iuml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@startuml

class MealPlanBuilder {
- mealMap: Map<LocalDate, Meal>
- startDate: LocalDate
- endDate: LocalDate
+ setStartDate(startDate: LocalDate): MealPlanBuilder
+ setEndDate(endDate: LocalDate): MealPlanBuilder
+ addMeal(date: LocalDate, meal: Meal): MealPlanBuilder
+ build(): MealPlan
}

class MealPlan {
- meals: List<Meal>
- start: LocalDate
- end: LocalDate
+ getMeals(): List<Meal>
+ getStart(): LocalDate
+ getEnd(): LocalDate
+ getDays(): int
+ getGroceryList(): GroceryList
+ toString(): String
}

MealPlanBuilder --> MealPlan

@enduml
Loading

0 comments on commit d62b8f8

Please sign in to comment.