Ex09 - Library workflow

Asfaloth
Windoof-User
Windoof-User
Beiträge: 27
Registriert: 7. Nov 2012 10:36

Ex09 - Library workflow

Beitrag von Asfaloth »

Hi,

we have a question regarding the implementation of the PizzaSystem.

What is ment by "Implement an OSM library that can be used to manage orders..."?
Do we have to implement a complete order manager which can add or remove products? Or just print the bill for the products we created in the test class?

The case class "Order" receives the customer, the register id and the products the customer orders.
In the invoke method, we visit the products and print the billing information with this information. Is this correct or should there be another method doing this?

Thanks,
Asfaloth

L4_
BASIC-Programmierer
BASIC-Programmierer
Beiträge: 104
Registriert: 24. Apr 2012 15:44

Re: Ex09 - Library workflow

Beitrag von L4_ »

Asfaloth hat geschrieben:In the invoke method, we visit the products and print the billing information with this information. Is this correct or should there be another method doing this?
I also got another question on this:

The signature of "invoke" is "invoke(v: ProductVisitor)".

First, the intention of the "invoke" method is to print the bill, right?
If yes, why do we allow all kinds of a ProductVisitor?

For example, if I would have a visitor called "MenuVisitor" which would visit all available products and print some menu (e.g. like the Menu in the Exercise), I could pass that one to "invoke", which I would not intend usually.
Thus, in my opinion the signature should be "invoke(v: ReceiptVisitor)".
Furthermore, if that is the only purpose I do not even need to pass over that ReceiptVisitor to the "invoke"-method everytime.

Do I get this right?

imaier
Mausschubser
Mausschubser
Beiträge: 61
Registriert: 21. Okt 2013 21:27

Re: Ex09 - Library workflow

Beitrag von imaier »

@Asfaloth: you don't have to implement anything that is not mentioned on the sheet. You can assemble an order simply by using the constructor of the order.

@L4_: You can also rename invoke to accept if you want, I should have done that in the first place. Why would you not want to pass other visitors to invoke? Why only a ReceiptVisitor? What is so special about the latter? Isn't the whole point of the visitor pattern that you can run different operations over your tree -- in this case: orders? I don't really understand your question about the need to pass the ReceiptVisitor to invoke every time.

Cheers,
Ingo

Antworten

Zurück zu „Archiv“