DannyT Posted July 27, 2005 Posted July 27, 2005 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 isn't great, i know what I want to achieve just need to get a bit more grasp on the concepts/practices. Cheers, Dan Quote
mhildner Posted July 27, 2005 Posted July 27, 2005 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 doesn't do much for you here. They do have a Data Access Application Block, I haven't used it as I've seen no support for biz objects. It's a free download, and I'd 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 Quote
DannyT Posted July 27, 2005 Author Posted July 27, 2005 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 i'd like a few other opinions before thinking about forking out that sort of dosh! Quote
Joe Mamma Posted July 27, 2005 Posted July 27, 2005 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' date=' too! :) 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 Liberty's Programming C#. Second, I would recommend that you get Lowy's book Programming .NET Components. (People. . . if you don't own this-get it yesterday!!!) Now, with an understanding of C#, and Lowy's Component Bible in hand, get Lothka's 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 lothka's 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 don't let it discourage you. Two other general OOP books you should have on your book shelf - The (in)famous GOF Fowler's Refactoring Bible Buy your books here - www.nerdbooks.com Tell him blair sent you! Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
DannyT Posted July 27, 2005 Author Posted July 27, 2005 Now that's one enthusiastic reply! Cheers JM, will certainly check them out. OOP, design paterns and 'proper' syntax isn't total noobage material to me, i've done a lot of actionscript 2.0 (macromedia's 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 that's 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 Quote
DannyT Posted July 27, 2005 Author Posted July 27, 2005 Buy your books here - www.nerdbooks.com Tell him blair sent you! P.S. I don't get it? Quote
Joe Mamma Posted July 28, 2005 Posted July 28, 2005 Nothing to get. . . Except fantastic prices, fantastic selection and personal service!!! On average 25% less than amazon. Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
bri189a Posted July 28, 2005 Posted July 28, 2005 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 you're doing in C# and understand OOP, VB.NOT holds up just fine... just don't do anything to advanced and try not to let VB let you get too lazy and you'll 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#!!!! Quote
Joe Mamma Posted July 28, 2005 Posted July 28, 2005 (perhaps this thread should be moved???) here's how I think - "I need a MyObject, myObject, initialized with 'do-re-mi'" which is exactly what this says: MyObject myObject = new MyObject("doremi") - - - - - Here's 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 doesn't mirror normal thought. Look at event handlers. . . I think: "MyControl's Click event handler needs to call DoClick"- C#: MyControl.Click += new EventHandler(DoClick); I dont think: "I need to add a handler to MyControl's click Event that references DoClick" VB: AddHandler MyControl.Click, addressof(DoClick) for the coup de grâce, I will finish with Casting: in C# the statement MyObj myObj = (MyObj) obj; implies: Take a MyObj, called myObj and, through a MyObj filter, point at obj. But in VB- Dim myObj as MyObj = DirectCast(obj, GetType(MyObj)) huh??? what does that gobble-di-gook say???? "Dimension a space, call it myObj, it holds a MyObj type and fill it with a DirectCast operation of obj against the type of MyObj" Give me a break! VB.NOT!!!! :rolleyes: :p ;) Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.