Re: Of Java and C#



On Jan 31, 12:36 am, LX-i <lxi0...@xxxxxxxxxxxx> wrote:
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*!".


Yeah there are some people in various groups like that - best to
ignore them.

There's industry standard as such. Its more 'best practise' or 'common
practise' or 'a language idiom'

For example, the OO language Ruby and its most popular framework Rails
(known as Ruby on Rails or RoR) uses an 'ActiveRecord' approach.

The Model class I mentioned earlier would directly map onto a db table
of the same name (library) and the OO methods called on that object
directly effect the db.

so...

Library.list

would go to the actual database table and retrieve the data.

class Song < ActiveRecord::Base
# Uses an integer of seconds to hold the length of the song

def length=(minutes)
write_attribute(:length, minutes * 60)
end

def length
read_attribute(:length) / 60
end
end

The class above is what we would write ..all the database code is in
the library base class 'ActiveRecord' we dont need to do any db work,
other than setting up the config to tell RoR what db to connect to
which has a Table called Song (ruby even works out that the 's' on
Songs class is just a plural for Song Table)


This may sound simple, but the power it gives developers to create
highly rich and high performing web applications is amazing.

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

Cool.

Andrew

.



Relevant Pages

  • HOW DO i MAKE A LIST FOR SONGS?
    ... The "database" I have created is very ... in my collection I have a song title: ... that appears on 3 different albums and by 2 ... the "search criteria". ...
    (microsoft.public.excel.worksheet.functions)
  • Re: WMP 10 and Playlist
    ... Congributing Artist is most likely NOT the main singer of the song. ... on the internet to fill WMP fields when a CD is ripped) to the WMP fields. ... when you rip a CD unknown to the internet database you can ...
    (microsoft.public.windowsmedia.player)
  • Re: Classes required for an application
    ... the database before the business objects. ... an application supports the business objects, ... of song information," you should think of the application as a tool for ... can be desrcribed by a user making a rating for a song. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: WMP 10 and Playlist
    ... Album artist MIGHT be the same as the artist singing the song. ... on the internet to fill WMP fields when a CD is ripped) to the WMP fields. ... when you rip a CD unknown to the internet database you can input the info manually. ...
    (microsoft.public.windowsmedia.player)
  • Re: Music site - Music Genome Project!
    ... > the artist and song. ... You can stump it with obscurity, but the database ... Taj Mahal ... Mahal's recording of Statesboro Blues with Ry Cooder on slide, ...
    (alt.guitar.amps)