VB.NET Version of the Code for the N-Layer Design Articles Now Available

My on-line friend Peter has been so kind to translate the code for the Contact Manager Application from my articles about N-Layer Design to Visual Basic.NET.

He used an on-line code translator to do most of the translation and then manually fixed some open issues. I briefly looked at it and tested the code, and everything seems to work fine.

There's one small issue though. My original C# code used using blocks in all data access methods. Apparently, the converter had problems with that so now all using blocks have been replaced with standard Try Catch blocks. I think the "issue" makes sense, as using is just a language trick that eventually compiles to a standard Try / Catch block so when you look at the MSIL, you probably just get a Try / Catch block.

Anyway, I am very happy with Peter's efforts. Peter: thanks a lot for doing this.

I haven't tested this VB version as thoroughly as I tested the C# edition, so if you find an issue with the VB version: please let me know.

Have fun with the VB version which you can find here and at the end of the each article.


Where to Next?

Wonder where to go next? You can read existing comments below or you can post a comment yourself on this article .


Consider making a donation
Please consider making a donation using PayPal. Your donation helps me to pay the bills so I can keep running Imar.Spaanjaars.Com, providing fresh content as often as possible.



Feedback by Other Visitors of Imar.Spaanjaars.Com

On Friday, January 18, 2008 2:57:29 PM Al Battle said:
Imar,

The N-Tier Design article was most excellent.  However, I was wondering if you have a related article where Inheritance is used to create the BO, BLL & DAL layers?  If you have a VB version of it, I'd greatly appreciate it.  Keep up the good work.  
On Sunday, January 20, 2008 12:59:40 PM Imar Spaanjaars said:
Hi Battle,

Nope, sorry, no inheritance implementation.

There is a VB version of the code created in the N-Layer article series available though.

Cheers,

Imar
On Monday, January 28, 2008 9:48:11 PM Ryan said:
Imar,
   Great article on n-layer design.  I agree with Battle that if possible an explanation of how inheritance could be used would be great.  I've tried implementing it in my DAL by making the FillDataRecord(ByVal myDataRecord As IDataRecord) method public and renaming it to an overloaded method of GetItem().  this way i could call it from a child class and pass in an IDataRecord.  for instance, if my parent was person and child was student.  i was thinking i could then have a method called StudentDB.GetItem(ByVal myDataRecord As IDataRecord), in which i could say...
dim myStudent as student = PersonDB.GetItem(myDataRecord)
myStudent.studentID = myDataRecord.GetString(myDataRecord.GetOrdinal("studentID"))    
....and continue on with my additional properties that a student has that were not inherited from Person.
HOWEVER, this is not possible because I'm trying to DownCast a Person to a Student.  So i'm trying to think of other possible implementations of inheritance to avoid duplicate code.  Please let me know your thoughts.

Thanks,
Ryan
On Thursday, January 31, 2008 8:35:17 PM Imar Spaanjaars said:
Hi Ryan,

I am not sure I agree that a Person should know how to load itself. Would an abstract Person class be better in this case? Then when you get the data for a Student, you can forward to IDataRecord to an Person loader (or an IPerson loader if you are using interfaces instead of inheritance) that knows how to copy data from the reader into the Person.

You could also create a protected Fill method that accepts the IDataRecord. That way you can call the base class's Fill method and forward the IDataRecord.

It's difficult to suggest good examples, as I don't know anything about your current setup, knowledge, design and database. If this info isn't enough, please try posting on a forum like http://p2p.wrox.com and supply some more detail.

Cheers,

Imar

Talk Back! Comment on Imar.Spaanjaars.Com

I am interested in what you have to say about this article. Feel free to post any comments, remarks or questions you may have about this article. The Talk Back feature is not meant for technical questions that are not directly related to this article. So, a post like "Hey, can you tell me how I can upload files to a MySQL database in PHP?" is likely to be removed. Also spam and unrealistic job offers will be deleted immediately.

When you post a comment, you have to provide your name and the comment. Your e-mail address is optional and you only need to provide it if you want me to contact you. It will not be displayed along with your comment. I got sick and tired of the comment spam I was receiving, so I have protected this page with a simple calculation exercise. This means that if you want to leave a comment, you'll need to complete the calculation before you hit the Post Comment button.

If you want to object to a comment made by another visitor, be sure to contact me and I'll look into it ASAP. Don't forget to mention the page link, or the QuickDocId of the document.

For more information about the Talk Back feature, check out this news item.