Regarding exercise 08, I have some questions:
1. Task 1, Task 2: Should we annotate each single method with @Operation in the code that appears in Composite, Leaf or Component and that is declared by Component? This is my current understanding of the @Operation annotation. The same question arises for the Decorator pattern.
2. Task 1: Is it okay if there is a class between a Composite and the Component in the type hierarchy? Should we in this case not label the in-between class (my current approach).
3. Task 1: Are enums of interest for this task?
4. Task 2: Should we use further annotations than those that are imported for the second task? I suppose yes, just wanted to make sure.
5. Task 2: Should we search for a Composite-Pattern-Client in task 2, as the code is only a library and not used from the outside?
6. Task 2: How should we implement the methods weight and label for a SubGraph? Or does it not matter for the upload?
Best,
Ben
Exercise 08
Moderatoren: pmueller, SE - Design and Construction
- AizazZaidee
- BASIC-Programmierer
- Beiträge: 106
- Registriert: 20. Apr 2016 22:49
Re: Exercise 08
I was also thinking about Enum but then I think they should be because whole Strategy can be implemented as one single Enum, for example:
I guess the one you talking about is default Context.
Code: Alles auswählen
//Implementation + Interface
public enum Strategy {
STRATEGY_A {
@Override
void execute() {
System.out.print("Executing strategy A");
}
},
STRATEGY_B {
@Override
void execute() {
System.out.print("Executing strategy B");
}
};
abstract void execute();
}
//Usage
public static void main(String[] args) {
UseStrategy useStrategy = new UseStrategy();
useStrategy.perform(Strategy.STRATEGY_A);
useStrategy.perform(Strategy.STRATEGY_B);
}
private void perform(Strategy strategy) {
strategy.execute();
}
Re: Exercise 08
Hi,
Best,
Patrick
Yes.Ben Kohr hat geschrieben: ↑1. Jul 2018 12:161. Task 1, Task 2: Should we annotate each single method with @Operation in the code that appears in Composite, Leaf or Component and that is declared by Component? This is my current understanding of the @Operation annotation. The same question arises for the Decorator pattern.
If this in-between does not really take part in the given pattern, it might not be necessary to annotate it (or just with the annotations of a different pattern).
Why not?
Yes. These imports are just included because of the name clash.
If there is no client you cannot annotate it.
Subgraph should have its own label defaulting to an empty String, and the weight should be the total weight of all contained elements.
Best,
Patrick
Re: Exercise 08
Hello,
Regarding task 2.3: we should implement the "getElementsSorted" method in the "SubGraph", right?
Greets
Regarding task 2.3: we should implement the "getElementsSorted" method in the "SubGraph", right?
Greets