Jim's Blog Ramblings about novels, comics, programming, and other geek topics


Thoughts on Data Abstraction

Google AdSense

On my path of becoming a better developer, I've began participating in the development of DotNetKicks. DotNetKicks is an open-source project that is a community driven link submission portal. In other words, it is very similar to major web sites of Digg and Reddit, but its focused into specific areas of technology.

DotNetKicks.com is a community based news site edited by our members. It specializes in Microsoft development techniques, technologies and tools including ASP.NET, C#, VB.NET, C++, Visual Studio, Team System, SQL Server and Microsoft Vista.

Like most open source projects, the project uses Subversion. I've used SVN a few times before for other open source projects. In the past, I've just used the SVN command line. But this time, I downloaded and installed TortoiseSVN and it has worked great so far.

I've been able to address a couple enhancement requests including adding a way to see which stories a user has submitted (DNK issue 24) and see all of the comments submitted by the user (DNK issue 62). These were two pretty simple fixes that were resolved by adding some stored procedures and a little bit of coding. Gavin Joyce, project lead, writes about the new features recently added to DotNetKicks on his blog.

One of the things I've notice from reviewing the code so far, is the use of a data abstraction and business layers. In most of my work so far, I've seen very little implementations of these layers. Most of the projects that I've written or reviewed had the presentation, data, and business layers combined into the web page (either ASP.NET or JSP).

There are advantages and disadvantages to using data abstraction layers and nearly everyone does it or reads about it for academic reasons. The largest benefit is transporting the database to another vendor or platform. You can just edit the DAL instead of going through each page and updating your SQL code for any RDBMS vendor specific code.

But that doesn't happen very often for most internal company web sites. For the most part, I've worked on Oracle databases for the government and SQL Server databases for commercial and in-house projects. I've never been apart of something that need abstraction for portability.

One of the advantages that I found is the use of strongly typing the data. When directly querying a database and just outputting the contents, its impossible to test for the existence of columns at design time. With an automated build process that generates the DAL, you can find errors when referencing database objects that may not exist or be of a different data type that you code in your presentation layer.

The DNK project uses SubSonic to automatically generate a data abstraction layer for its SQL Server 2005 database. SubSonic is an open-source project that can generate data abstraction layers for SQL Server 2000, SQL Server 2005, MySQL, and Oracle databases.

An alternative to SubSonic is to use Strongly Typed TableAdapters. Scott Gu provides a detailed tutorial on how to build a data abstraction layer using Visual Studio.


My Related Posts: , ,

James Welch

James Welch is a software engineer in Vermont working for a large information technology company and specializing in .NET. Additionally, he holds a Master’s Degree in Software Engineering and a Bachelor of Science Degree in Computer Science. Jim also enjoys local craft beer, comic books, and science-fiction and fantasy novels, games, and movies.

Twitter Google+ 

Comments (1) Trackbacks (0)
  1. Nice one, but i did’nt get the disadvantages.

Leave a Reply

No trackbacks yet.