From ... Path: supernews.google.com!sn-xit-03!supernews.com!news-feed.riddles.org.uk!skynet.be!newsfeed2.news.nl.uu.net!sun4nl!EU.net!Norway.EU.net!not-for-mail From: Erik Naggum Newsgroups: comp.lang.lisp Subject: Re: Trouble with labels Date: 12 Apr 2001 13:44:14 +0000 Organization: Naggum Software, Oslo, Norway Lines: 32 Message-ID: <3196071854975641@naggum.net> References: <4sf6dto7mf556cvahss96e5u1087idd6vq@4ax.com> <3195982690560792@naggum.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: oslo-nntp.eunet.no 987083054 109 195.0.192.66 (12 Apr 2001 13:44:14 GMT) X-Complaints-To: newsmaster@eunet.no NNTP-Posting-Date: 12 Apr 2001 13:44:14 GMT Mail-Copies-To: never User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 Xref: supernews.google.com comp.lang.lisp:9221 * Paolo Amoroso > I have a design question: why do you keep the code for checking for the > appropriate balance in a separate :AROUND method instead of adding it to > WITHDRAW's primary method? I can think of a few reasons: > > - because performing a withdrawal and checking for an appropriate balance > are orthogonal operations > - for improving modularization, i.e. for making it easier to later add > other validation methods > - to emphasize a WITHDRAW protocol All of the above, some of which I think of only after you suggest them. :) However, my initial reason for doing this was to show that you might want to deal with credit limits without modifying the core operation. In real life, a withdrawal that requests credit is an automatically granted loan, with a lot of background work to deal with the loan. So a :before method that took care of the credit approval would update the balance before the withdrawal updated it again. Anyone who has had to deal with accounts with real money in real life knows that the first principle that you never violate is that you never affect the money supply. Maintaining that invariant is hard work in banking applications. Much of the complexity in database transactions come from banking requirements not to create or destroy money, no matter what happens. #:Erik -- I found no peace in solitude. I found no chaos in catastrophe. -- :wumpscut: