nus-cs2103-AY2021S1 / forum

20 stars 2 forks source link

Command pattern #503

Closed keanecjy closed 3 years ago

keanecjy commented 3 years ago
  1. What does the receiver do in the Command pattern?
  2. In the context of AB3, is the Receiver the Model class or the Person class for the AddCommand?

image

damithc commented 3 years ago
  1. What does the receiver do in the Command pattern?

The thing the command will act on (if any).

2. In the context of AB3, is the Receiver the Model class or the Person class for the AddCommand?

You can check (I can't remember) what thing is being given to commands to act on. Some command might not need any e.g., the HelpCommand

keanecjy commented 3 years ago
  1. In the context of AB3, is the Receiver the Model class or the Person class for the AddCommand?

You can check (I can't remember) what thing is being given to commands to act on. Some command might not need any e.g., the HelpCommand

Must it be part of the constructor parameter? Or can it be a parameter during the execute method? This is because Person is passed in as the constructor parameter, and Model is passed in in the execute method. In this case, are both classes considered acted on?

damithc commented 3 years ago

Must it be part of the constructor parameter? Or can it be a parameter during the execute method? This is because Person is passed in as the constructor parameter, and Model is passed in in the execute method. In this case, are both classes considered acted on?

All of these are acceptable ways of connecting the receiver(s) to the command.

keanecjy commented 3 years ago

Ok thank you @damithc