Code Comments
Programming Forum and web based access to our favorite programming groups.On Jan 28, 12:48 am, LX-i <lxi0...@netscape.net> wrote: > andrewmcdonagh wrote: > > > differences. I don't have the source code on my laptop, as I've been > doing the actual class at work. Look for something Monday evening CST... > > -- 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.... Oh, not sure what Java IDE you are using, but eclipse (www.eclipse.org) is a free open source one that has the same abilities as the MS c# one you talk about, but for Java. Andrew
Post Follow-up to this messageandrewmcdonagh 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? -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~ ~ / \ / ~ 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
Post Follow-up to this messageX-Trace: individual.net u3nNkc0I37teMUQc9WsFNAfAuHEokq93WZ8m2id2 mD4HUfmN0i X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3028 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 Xref: number1.nntp.dca.giganews.com comp.lang.cobol:162950 "LX-i" <lxi0007@netscape.net> wrote in message news:d182b$45bea73f$454920f8$8426@KNOLOG Y.NET... > andrewmcdonagh wrote: > > 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? > The modern approach to this is to use a data adapter and a Dataset that are "disconnected" (updated offline). The DB Connection is used to run the query, then dropped. Subsequent processing is against the Dataset (previously a "result set"). Changes to the dataset can be committed any time you want, and the connection is re-established automatically. Synchronization and detection of changes that may have occurred while you were offline, are all handled by the data adapter, which provides methods and properties to let you do whatever you want. Here's a link that may help: http://www.codersource.net/csharp_a...utorial_ed.html See also the C# "Dataset.AcceptChanges()" method and the "DataAdapter.Update()" methods. This is very powerful stuff and I am still getting my head round it. :-) Fortunately, it works as documented... Your checkMeOut() method could update the Dataset and/or commit the changes, depending on what you want/need. (Personally, I'd put the DB stuff into another Class/Method and invoke it from checkMeOut()) Pete.
Post Follow-up to this messageandrewmcdonagh wrote: > On Jan 30, 2:02 am, LX-i <lxi0...@netscape.net> wrote: > > 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
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.