Re: Programming to an Interface
- From: Joe Van Dyk <joe.vandyk@xxxxxxxxxx>
- Date: Fri, 26 May 2006 22:18:12 GMT
Laurent Bossavit wrote:
Bernard,
Could you please transform this example to "programming to an
interface", still in Ruby to allow us to compare?
(In the original, btw, I meant "account.getId" rather than "amount.getId"...) In Ruby, perhaps we could come to:
def debitAccount amount
transaction = makeTransaction()
transaction.execute(this) {balance -= amount}
end
That is, the mechanics of persisting changes to an object and wrapping the business logic in a transaction would be hidden at the next level down. You don't care how persistence or transactions are implemented, only that you can rely on both.
Laurent
You'd probably want:
def debit_account amount
transaction do
balance -= amount
end
end
I fail to see how this has anything to do with programming to an interface rather than implementation though.
Joe
.
- References:
- Programming to an Interface
- From: GoogleEyeJoe
- Re: Programming to an Interface
- From: Patrick May
- Re: Programming to an Interface
- From: GoogleEyeJoe
- Re: Programming to an Interface
- From: H. S. Lahman
- Re: Programming to an Interface
- From: Laurent Bossavit
- Re: Programming to an Interface
- From: Sasa
- Re: Programming to an Interface
- From: Laurent Bossavit
- Re: Programming to an Interface
- From: Bernard Notarianni
- Re: Programming to an Interface
- From: Laurent Bossavit
- Re: Programming to an Interface
- From: Bernard Notarianni
- Re: Programming to an Interface
- From: Laurent Bossavit
- Programming to an Interface
- Prev by Date: Re: Searching OO Associations with RDBMS Persistence Models
- Next by Date: Re: Searching OO Associations with RDBMS Persistence Models
- Previous by thread: Re: Programming to an Interface
- Next by thread: Re: Programming to an Interface
- Index(es):
Relevant Pages
|