Re: Of Java and C#



andrewmcdonagh wrote:
On Jan 30, 2:02 am, LX-i <lxi0...@xxxxxxxxxxxx> wrote:
andrewmcdonagh wrote:
Doh...oh yes re-reading your post I see that now... Saw the talk
about Java and missed the c# connection to the class.
Not to worry though...whilst I don't know the full c# library yet I
do know OO and c#'s approaches so if you want....
Well, I forgot to e-mail the source to myself... :( But in the mean
time, I have a question for you seasoned OO folks...

Say, for example, that there is a library application where there is a
"book" object with a method of checkMeOut(), that takes a patron object,
and modifies it to indicate that it is now checked out by the given patron.

Assuming that this is a persistent application, at what point is the
information stored off? Does checkMeOut() do the work of updating the
database *and* updating the object in memory, or should there be a
separate commitChanges() method that would update a data store with the
information contained in the current instance of that object?


Like all good things ...it depends......


:)

Its common for Classes like this to also do the data persistence, or at latest, call a method on their base class to do so.

Well, of course - I didn't mean that the method would do it all, just that, when the method is done, so would that process. :)

However, its usually a better (aka looser coupled, high cohesive design) for another class to be responsible for the persisting.

A standard OO Design Pattern for this example does exist called: Model View Presenter (googleable)

I shall do that.

but like I say, it depends... there's always multiple ways of doing this... and a Book knowing it checkout history is one of them....

OK - thanks. :) I was just wondering if there was some sort of industry standard - I'd hate to be laughed out of some group because "no one does it like *that*!".

My C# is coming in the next post...

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ / \ / ~ Live from Montgomery, AL! ~
~ / \/ o ~ ~
~ / /\ - | ~ daniel@thebelowdomain ~
~ _____ / \ | ~ http://www.djs-consulting.com ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ GEEKCODE 3.12 GCS/IT d s-:+ a C++ L++ E--- W++ N++ o? K- w$ ~
~ !O M-- V PS+ PE++ Y? !PGP t+ 5? X+ R* tv b+ DI++ D+ G- e ~
~ h---- r+++ z++++ ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

"Who is more irrational? A man who believes in a God he doesn't see, or a man who's offended by a God he doesn't believe in?" - Brad Stine
.