[Tutor] class question
Alan Gauld
alan.gauld at btinternet.com
Sat Jul 14 00:12:05 CEST 2007
"Dick Moores" <rdm at rcblue.com> wrote
> Thanks. You've clarified it for me completely.
>
> Your second way seems to make more sense.
> And instead of raising the error, why not just print it:
Because that would make the class much less reusable.
It would be limited to applications using stdout. A GUI
banking program would be unable to use the BankAccount
class. But by raising an exception the user gets to decide
what to do, either pop up a dialog, print a message or send
an email to the banks client.
Its a primary design goal for reuse to de-couple business
logic - like the bank account - from the user interface.
There is a bit more discussion around this in my
Case Study topic where I convert it from command
line to GUI and again in my InterProcess Comms topic
where I turn the AddressBook into a client-server app.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
More information about the Tutor
mailing list