Exercise 08

Moderatoren: pmueller, SE - Design and Construction

Ben Kohr
Windoof-User
Windoof-User
Beiträge: 34
Registriert: 14. Apr 2015 17:41

Exercise 08

Beitrag von Ben Kohr » 1. Jul 2018 12:16

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

Benutzeravatar
AizazZaidee
BASIC-Programmierer
BASIC-Programmierer
Beiträge: 106
Registriert: 20. Apr 2016 22:49

Re: Exercise 08

Beitrag von AizazZaidee » 1. Jul 2018 15:38

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:

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();
  }
I guess the one you talking about is default Context.

pmueller
Moderator
Moderator
Beiträge: 87
Registriert: 25. Jan 2018 11:14

Re: Exercise 08

Beitrag von pmueller » 2. Jul 2018 11:05

Hi,
Ben Kohr hat geschrieben:
1. Jul 2018 12:16
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.
Yes.
Ben Kohr hat geschrieben:
1. Jul 2018 12:16
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).
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).
Ben Kohr hat geschrieben:
1. Jul 2018 12:16
3. Task 1: Are enums of interest for this task?
Why not?
Ben Kohr hat geschrieben:
1. Jul 2018 12:16
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.
Yes. These imports are just included because of the name clash.
Ben Kohr hat geschrieben:
1. Jul 2018 12:16
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?
If there is no client you cannot annotate it.
Ben Kohr hat geschrieben:
1. Jul 2018 12:16
6. Task 2: How should we implement the methods weight and label for a SubGraph? Or does it not matter for the upload?
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

emod02
Neuling
Neuling
Beiträge: 9
Registriert: 27. Apr 2018 19:35

Re: Exercise 08

Beitrag von emod02 » 3. Jul 2018 15:38

Hello,

Regarding task 2.3: we should implement the "getElementsSorted" method in the "SubGraph", right?

Greets

pmueller
Moderator
Moderator
Beiträge: 87
Registriert: 25. Jan 2018 11:14

Re: Exercise 08

Beitrag von pmueller » 3. Jul 2018 15:58

emod02 hat geschrieben:
3. Jul 2018 15:38
Regarding task 2.3: we should implement the "getElementsSorted" method in the "SubGraph", right?
Yes

Antworten

Zurück zu „Software Engineering - Design and Construction“