OOP practices for data extraction

DannyT

Active member
Joined
Apr 14, 2005
Messages
36
Are there any best practice/design patterns geared towards database access in OOP for .net? I.e. how to keep objects seperate from the database calls to maintain maximum reusability of classes.

OOP is still pretty new to me so apologies if the wording isnt great, i know what I want to achieve just need to get a bit more grasp on the concepts/practices.

Cheers,
Dan
 
Yes. By far the best way to seperate things is through the use of business objects. Business objects usually have an associated data access class. The data access class is DB specific, but the biz object is not.

Unfortunately Microsoft doesnt do much for you here. They do have a Data Access Application Block, I havent used it as Ive seen no support for biz objects. Its a free download, and Id use it over using nothing.

Although pricey (USD $700), the Mere Mortals Framework has (among other things) really well designed biz ojbects. It also ships with the source code.

Mike
 
Thanks mhildner, will be partaking in a lot of reading on this matter i think. I really like the concept, just need to work on my know how.

has anyone else used the Mere Mortals Framework? They talk a good product on the site but id like a few other opinions before thinking about forking out that sort of dosh!
 
DannyT said:
Are there any best practice/design patterns geared towards database access in OOP for .net? I.e. how to keep objects seperate from the database calls to maintain maximum reusability of classes.
Yes. . . lots! They fill bookstores with 500 page books describing them. I believe you can even get a PhD in this, too! :)
DannyT said:
OOP is still pretty new to me. . .
First, forget about VB.NOT. You are going to do alot of borrowing of ideas from java/c++/delphi - VB.NOT is so non-OOP standard in its syntactical constructs that translating it is going to wear you down.
So, if C# is new to you, get Libertys Programming C#.

Second, I would recommend that you get Lowys book Programming .NET Components. (People. . . if you dont own this-get it yesterday!!!)

Now, with an understanding of C#, and Lowys Component Bible in hand, get Lothkas Expert C# Business Objects (also available in a VB.NOT version) and Implement the CSLA around your Database (free downloads of the framework are available at lothkas website). Supposedly the .NET 2.0 book is coming out soon and you might want to wait for that. FYI -This 2 star review of Lothka lacks understanding of what the CSLA really is and how it is to be applied, so dont let it discourage you.

Two other general OOP books you should have on your book shelf -
Buy your books here -

www.nerdbooks.com

Tell him blair sent you!
 
Now thats one enthusiastic reply!
Cheers JM, will certainly check them out. OOP, design paterns and proper syntax isnt total noobage material to me, ive done a lot of actionscript 2.0 (macromedias wanna be oop effort) and have done alot of reading around the subject. Just feel now is the time to get properly stuck into it all.

Just for anyone else thats interested, as an almost more recent extension of the gof book check out Head First absolutely awesome book and quite possibly the final inspiration for me to delve into OOP full on.

Dan
 
VB.NOT - tell us how your really feel.

Hey, at least your not stuck doing it for a living...go to work do VB.NET, come home do C#.NET - both have become so interchangable to me now I forget about some of the stupidity in the name conventions, but, if you know what youre doing in C# and understand OOP, VB.NOT holds up just fine... just dont do anything to advanced and try not to let VB let you get too lazy and youll be fine: Always Option Strict On and always remove the VisualBasic reference...then you can port to C# seemlessly...and some day I will convert that shop to C#!!!!
 
(perhaps this thread should be moved???)

heres how I think -

"I need a MyObject, myObject, initialized with do-re-mi"

which is exactly what this says:

MyObject myObject = new MyObject("doremi")
- - - - -

Heres how I dont think -

"DIMension a space in memory, myObject, which will contain an instance of MyObject, and the MyObject is to be initialized with a doremi"

which is what VB syntax implies -

dim myObject as MyObject = new MyObject("doremi")
- - - - -

Yeah, its not that much more typing, it just doesnt mirror normal thought.

Look at event handlers. . .

I think:
"MyControls Click event handler needs to call DoClick"-

C#:
MyControl.Click += new EventHandler(DoClick);

I dont think:
"I need to add a handler to MyControls click Event that references DoClick"

VB:
AddHandler MyControl.Click, addressof(DoClick)

for the coup de gr
 
Back
Top