Code Persona

Tool To Quickly Version Control / Reverse Engineer Your Database Jan 04

Jeff Atwood, in his blog post strongly recommends taking your database to source control. He mentions:
The database is a critical part of your application. If you deploy version 2.0 of your application against version 1.0 of your database, what do you get? A broken application. And that's why your database should always be under source control right next to your application code. You deploy the app, and you deploy the database. Like peanut butter and chocolate, they are two great tastes that taste great together.
In the past we’ve scripted our databases using the Visual Studio Database project and hand written our DDL and DML script for the data model and the default data.
Microsoft SQL Server Database Publication Wizard has the capability of generating your SQL scripts from your database so that you don’t have to write these manually.
Of-course Management Studio can do this as well but where this tool really scores is in it’s ability to generate the DML for data in the tables as well if you want it to.
This means now you can create your database and fill dummy data into it using Management Studio, then fire this tool, point it to this database and you get a ready to use SQL script which you can version control.
With a free tool to take your database to SVN and very little effort needed to achieve this, there is no reason why you shouldn’t keep your database in your SVN now.
So, is your database under version control? If not, go ahead, try this database. If you are manually writing your DDL and DML script for database schema and default data this tool might save you a lot of time as well.  
 

Think LINQ with LINQPad - The SQL Analyzer of LINQ Jan 03

Soren in his post expresses his desire for finding the SQL Query Analyzer equivalent of LINQ. He states:
If you haven't picked up on it yet I can tell you that I' very excited about LINQ at this point. Now all I need is for someone to create Query Analyser for LINQ for me and I'm good to good. What's even more interesting about such a tool is the fact that you would be able to target not just SQL but all the supported data store, although the queries wouldn't be interchangeable
Turns out, Soren is in luck.
LINQPad isn’t exactly a Query Analyzer but it does for LINQ programmers pretty much what Query Analyzer did for SQL Programmers.
It allows you to hook on to any SQL database and fire LINQ statements much like you would have fired SQL statements in Query Analyzer.
The authors of LINQPad give very valuable advice if you are genuinely interested in learning LINQ and getting into the LINQ way of thinking:
The rules are simple:
  1. Locate the shortcut for SQL Management Studio on your Start Menu and move it some place else.
  2. In its place, insert a shortcut to LINQPad.
  3. For the next week, perform all your ad-hoc SQL queries using only LINQPad.
At the end of the week, you will actually think in LINQ, rather than thinking in SQL and translating to LINQ.
It’s a single executable; it hooks on to both SQL Server 2005 and SQL Express and allows you not just practice LINQ but adapt to the LINQ way of thinking.
Give LINQPad a shot. Very soon you will genuinely start writing LINQ much like you write SQL, instead of thinking SQL and then attempting to translate it to LINQ.

I've moved... Oct 12

I've finally moved to a personal server for blogging - all future entires will be posted at http://www.thousandtyone.com/blog

 

 

Cool Tools For DotNet Data Access Layer [Highly Recommended] Sep 08

This is the kind of post that would usually go on my "other Blog" since that's where most of my technology posts go. Also,  that is where I like to play it safe with what I write :).

But since I've been blogging about the Open source thingy that I've started working on (I still can't believe I've already started wasting my weekends behind coding for a self commitment :)) I am going to go ahead and post all related material to that initiative here.

Code-Smith (this is a Paid Product with 30 day trial) is one of the tools I've used in more than one professional client projects now. I've been using it back from the days when the basic version was free and I just don't have enough good things to say about it. I Love this beautiful template based code generator.

Another framework that I've loved using in Past for professional projects was Rocky Lhotka's CSLA Business Objects Framework.

Code Smith now has built in templates to generate CLSA Business objects and I've always recommended this Duo (CodeSmith + CSLA) to Anyone who wanted to build an Enterprise Level Data Access Layer with SQL Server.

However, since I started working on this open source initiative, where Data Access Didn't play a major part in the framework that I was writing. In fact, my database consists of just 3 tables that I use primarily for saving settings. In this Scenario CSLA with Remoting sounded like a little bit of an overkill from the prospective of Maintenance.

This is when I was introduced to NetTires and it was pretty much love at first sight. NetTires generates code that let's me use Strongly Typed Entities for Data Access. It generates code which in turn uses Microsoft Enterprise Library. The generated code looks clean, reliable and high in quality.

Some of the other features (evident in 10 minutes of playing with the framework include)  support for Deep-Loads (So, if you have Student and Student-Marks table in one-to-many relationship you "can" get a Student object that also has Marks information loaded in a Collection within that object.) Deep-Saves, Data Caching, Elegant use of generics etc.

It uses Nullable Types quite elegantly, so all optional fields in database are basically Nullable types e.g. (int? CustomerAge - which the same as saying Nullable<CustomerAge>). There are a few classical problems with transactions and Identity columns (I posted about this on my "other blog" in a different post) which it addresses pretty elegantly.

If You want to write truely Distributed Application where Data Access is the life and soul of your application You might want to consider CSLA or evaluate NetTires a little more rigorously to compare the Pro's and Con's of both. (Maybe, I'll do this someday).

But, If you're in a hurry, need to write a quick Data Access Layer or Data Access is not the bread-and-butter of the application you're writing I HIGHLY Recommend NetTires! I've used it for a week now and I am LOVING it! As I use it more and more I am leaning to believe that maybe I could recommend it in a considerably sized professional project too.

GWB on Internet Explorer 7.0 - Beta 3 Jul 15

I’ve just downloaded Internet Explorer Beta 3 and it looks like all Internet Explorer issues I talked about in my First and Second Post of this blog have been fixed in Beta 3! GWB seems works PERFECTLY with Internet Explorer Beta 3 and I haven't come across ANY issues with posting on GWB using IE 7 Beta 3 yet! Things Rock!!

At Times "No Comments" Are Better! Jul 08

        #region Private Declarations

                // Private variables to be encapsulted by public properties

                string _DonatorId = ""; // Id of the donator. will be auto generated by CSLA business object.

                bool _IsDonatorAuthorizedToDonate = false; // donator not authorized to donate by default.

                string _DonatedAmount = ""; // assgined later.

                DateTime _DonationDate; // assigned later. Will be current system DateTime in new form.

                // Fetched from DB in existing form.

                /* These fields exist in base User table and have been commented. Will be removed later.

                string _DonatorName = ""; // To be assigned later.

                string _DonatorAddress = ""; // To be assigned later.

                string _DonatorPhone = ""; // To be assigned later.

                string _DonatorContactAddress = ""; // To be assigned later.

                */

            #endregion

 

What you see above is a snippet of perfectly “well commented” (spelt “well commentated”)… goo! To the guy who wrote this piece of art I say:

 

If you’re going to write comments just because a book / everyone else told you write them, here’s a piece of advice: Don’t! Honestly, I preffer:

 

        #region Private Declarations

                string _DonatorId = "";

                bool _IsDonatorAuthorizedToDonate = false;

                string _DonatedAmount = "";

                DateTime _DonationDate;

            #endregion

 

In Rare circumstances like this one, I can read code. Honestly, I can! And what’s with the “Will be removed later” thing? I'll get a House-keeper to clean my mess?

 

On a slightly serious note, How do you intend to track this stuff later? At least, have “//TODO:” Tasks for stuff like this. Tools / Options / Task List - has options to allow you to create a New Task Token if you don't like TODO and want to have a Token that says “CleanUp“. Get a crash course in your IDE before you code. Please!!