Create association table mapping pattern. #1228
Conversation
c52197a
to
74705c4
| categories: Patterns of Enterprise Application Architecture, Object-Relational Structural | ||
| tags: | ||
| - Decoupling | ||
| - many-to-many |
iluwatar
May 16, 2020
Owner
I would suggest picking categories and tags from the pre-existing ones. My suggestion for category is Idiom since this is small pattern. For tags I would suggest Enterprise Integration Pattern and Data access.
See https://github.com/iluwatar/java-design-patterns/wiki/07.-Categories-and-Tags
I would suggest picking categories and tags from the pre-existing ones. My suggestion for category is Idiom since this is small pattern. For tags I would suggest Enterprise Integration Pattern and Data access.
See https://github.com/iluwatar/java-design-patterns/wiki/07.-Categories-and-Tags
| StudentTableImpl studentTable = new StudentTableImpl(); | ||
| CourseTableImpl courseTable = new CourseTableImpl(); |
iluwatar
May 16, 2020
Owner
With Java 11 you can use var keyword to declare the variables
With Java 11 you can use var keyword to declare the variables
iluwatar
May 16, 2020
Owner
I won't mention this again but check that throughout the code
I won't mention this again but check that throughout the code
|
|
||
| package com.iluwatar.associationtable; | ||
|
|
||
| class AssociationTable { |
iluwatar
May 16, 2020
Owner
It's good practice to add Javadoc to classes that explains their purpose
It's good practice to add Javadoc to classes that explains their purpose
| */ | ||
| static void contentOfTable() { | ||
| if (AssociationTable.associations == null || AssociationTable.associations.length == 0) { | ||
| System.out.println("The table is empty!"); |
iluwatar
May 16, 2020
Owner
We should use a proper logger when outputting something. See the other patterns for examples.
We should use a proper logger when outputting something. See the other patterns for examples.
| * Storing the associations between Course and Student table, | ||
| * using the id of the objects. | ||
| */ | ||
| static int[][] associations; |
iluwatar
May 16, 2020
Owner
The multidimensional array data structure seems awfully clumsy in this case. It makes the handling code complex and verbose. Could you think of a better alternative here?
The multidimensional array data structure seems awfully clumsy in this case. It makes the handling code complex and verbose. Could you think of a better alternative here?
|
@LeonoraGy I've added my review comments. Let me know when it's ready for another look. |
Association Table Mapping pattern.