userexit
JCHJava Community | Help. Code. Learn.
•Created by userexit on 12/23/2024 in #java-help
Use Case Diagram Question:
1. A customer uses a drink in the following way: he puts a coin in the drink collector
parts, he selects the drink, he collects the chosen drink from the drinks tray and
excess change in the change trap. Who is the actor in the system? Is it the drink,
the coin collector, the customer, the drinks bin or the coin trap?
2. Marcel, whose job is to supply vending machines, can help himself to drinks. For
model this activity of Marcel, should we define a new actor? How do you model that?
3. When Marcel comes with his clarque filled with new drinks to fill the
drinks distributor, is it considered a new player? How do you model this?
4. Some suppliers are also qualified to carry out maintenance operations
in addition to the usual operations of suppliers. They are therefore restorative in addition
to be a supplier. How to model this?
12 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 12/18/2024 in #java-help
Help with interfaces/ inheritance
Hello im building a game where I'll have a board and GamePiece's that will be placed on the board,
I have tokens, these can be placed on the board after some validation and they can't be moved once placed for the rest of the game
I have totems, these will be automatically be placed in the center at the start of the game and they can be moved afterwards
I need a way to distinguish between them so:
1- Inheritance ? Bad choice of using inheritance in here because I'm not needing hierarchical use of methods in gamepiece it would only be to extends from GamePiece and call the super constructor in the constructor for both cases, so im only using it for subtyping, which is bad practice
I don't know what other option there might be for this, any help designing this ?
11 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 12/13/2024 in #java-help
Im trying to make dragging on a grid, but the element is dragging under the other columns and rows
4 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 11/3/2024 in #java-help
How to include a thymeleaf template into another one, to include header, footer etc
Title is self explanatory
-
63 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 11/2/2024 in #java-help
I set incrment to be 10, and I set initial value to be 100 but its not working, did it with hibernat
242 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 10/30/2024 in #java-help
How to create custom id generator for primary key in springboot
very clear question in title
302 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 10/30/2024 in #java-help
How to choose between using @Enumerated and a converter ? or @PostLoad and @PrePersist ?
Which one is better ? or does it depend, and if it depends, in what does it depend ?
4 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 10/28/2024 in #java-help
Enable live reload with Spring Boot devtools
help with the title
7 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 10/28/2024 in #java-help
Need help with this error in vscodium
8 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 10/28/2024 in #java-help
Syntax questions
Id like to know what these syntaxes mean:
javadoc -d doc Hello.java
jar -cf hello.jar Hello.class
java -cp hello.jar Hello
36 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 5/24/2024 in #java-help
Is this good composition class ?
4 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 5/21/2024 in #java-help
Help decoupling a presenter class in multiple classes
4 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 5/21/2024 in #java-help
Is it good practice to have 2 DTO's. one for database, one for application.
Im having an error as my DTO constructor can throw exceptions if the data introduced to it is invalid, but doing so means I can't create DTO's in DAO without handling these exceptions, but the DAO layer is not supposed to handle exceptions
4 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 5/21/2024 in #java-help
Should I decouple my presenter in multiple ones ?
6 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 5/20/2024 in #java-help
Help improving this code
ok so when i query a favorite row i know its id because its already been inserted, problem arises when i try inserting a favoritedto that i made in the program, i cant know what the id will be for it, but i dont have to either because the add method of my dao will just insert it and sql will generate a key for it. problem is when im trying to save a favorite ride i need to pass a favoritedto as argument but a favoritedto requires a id to be constructed, so i just put garbage number to construct it, there is no issue then all fine. problem is i dont think this is good written and i would refer to this as spaghetti code
195 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 5/20/2024 in #java-help
How could I simplify this
public interface Dao<K, S extends Key<K>> {
void update(S item);
void insert(S item);
void delete(K key);
S select(K key);
List<S> selectAll();
}
public interface Dao<K, T, S extends Key<K, T>> {
void update(S item);
void insert(S item);
void delete(K key1, T key2);
S select(K key1, T key2);
List<S> selectAll();
}
public interface Dao<K, T, I S extends Key<K, T, I>> {
void update(S item);
void insert(S item);
void delete(K key1, T key2, I key3);
S select(K key1, T key2, I key3);
List<S> selectAll();
}
87 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 5/19/2024 in #java-help
HELP HANDLING ERRORS IN MVP
Design Pattern: MVP -> MODEL-VIEW-PRESENTER
Interaction with user - presenter calls logic on model - model updates presenter - presenter updates view and/or calls new logic on model
now assume there is code in model that throws errors (parameter validation for example):
in presenter:
try {
model.doSomething();
} catch (error) {
view.showError(blabla);
}
is it better this way, or is it better like this:
in presenter:
model.doSomething();
in model:
if (name.length < 2) {
notifyObservers(ModelEvent.NOT_ENOUGH_NAME_LENGTH);
return;
}
then in presenter:
update(ModelEvent event) {
switch (event) {
case NOT_ENOUGH_NAME_LENGTH:
view.showError(blabla);
break;
}
}
50 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 5/18/2024 in #java-help
Help Project MVP Layout
I was thinking of this layout:
Presenter class that will handle interaction between model and view
ViewController class with methods to interact with the UI
Model package with:
- Repository that is going to contact the database and get me the needed information
- Dijkstra class that is going to handle calculating shortest path between 2 nodes.
Instantiating View => generating the UI
Instantiating Presenter => initializing the View with data that I get from the model, adding presenter as a button handler for view and adding presenter as an observer of Model
Instantiating Model => creating an instance of dijkstra and repository.
any idea how to optimize this ?
4 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 5/18/2024 in #java-help
Help optimize this dijkstra algorithm:
9 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 5/17/2024 in #java-help
Help implementing DJIKSTRA ALGORITHM
I have a Graph class that contains a Set of nodes,
I define a node to have a name and adjacent nodes.
The only thing im struggling with is:
lets say we have this:
A ---- B ---- C
|
|
D ---- E
Node D has name "D" and its adjacent nodes are E and A. How can I adapt my class to hold the distance to node E and A ? I have thought of modifying my node class to have a attribute distance to Parent, then Node E distance to parent is 1 but what if it has multiple parents as in what if a node F was connected to it
4 replies