litendavid (3) [Avatar] Offline
#1
On page 31, the first step in the purifying process, the invoice methods add and issue become static methods in a new class. The usage code then reads:

Invoice i = new Invoice(...);
ProcessInvoice.issue(i);

But on page 33, exercise review #3, a very similar example is solved through a non-static class, which feels very unnatural. The usage code reads:

Invoice i = new Invoice(...);
Customer c = new Customer(...);
...
ProcessCustomer pc = new ProcessCustomer();
pc.issueInvoice(c, i);

I see no reason for not making ProcessCustomer static like before. Is this simply an oversight, or am I missing something? I see you're accessing "this" in issueInvoice in order to call adjustBalance, but that call could be made static too, right?

Finding the book really excellent so far, great job, Aslan! Being a teacher of programming, maths and language, I ask you to wear my approval as a badge of honour. smilie
aslam.khan (50) [Avatar] Offline
#2
Re: static classes
Hmmm, I didn't see that inconsistency. Thanks for pointing it out. I will rework to make it more consistent.

And thanks for your kind words. I will wear your badge with honour smilie

-- Aslam