The Art of Programming

You say use a Uid and I say, use a Guid! Uid v.s. Guid

26. January 2011 18:21 by Scott in   //  Tags: , ,   //   Comments (0)

An Email I wrote to one of my developers.  Thought I would share.

So, lets just bring it down to one scenario.

I have a People's table and a Building's table.  One table has a various amount of people including names, DOB and various other small tidbits about their life.  The building has the same.  Its name, its type, and address and various other tidbits.

Now, lets say I have an Images Table.  I want to link images to the buildings and to the people.  But all people and buildings have more than one image.  Instead of adding a new column in that image table to describe the type of image it is for (also adding another table to describe the types of images).  I just have one relation and that is a Item_Id.  That image table is then queried when ever buildings or people are queried.  Only searching for the people Guid or the Building Guid.

Now, lets say I have the images table again, but the people table and buildings table have INT's as their identifier.  If I pull from the Images table all images that have an Item_Id == 5, I could get both personal pictures and building pictures.  Including any other type of picture I take.  And thats why I don't like to use INT's unless I am positively sure it won't cause adverse affects later on.

Make sense?

What Gives? Microsofts Code Generation Tool

17. November 2008 19:48 by Scott in   //  Tags: , , , , ,   //   Comments (31)

In a world of Microsoft and third party applications, out comes t4.  t4 is a code generation tool that can compete with CodeSmith, but its FREE and built right into Visual Studio. It has been years since the first edition with very little publication of the actual application. t4 is a free code generation engine from Microsoft that underpins the Domain Specific Languages and Software Factory toolkits.  t4 is a rich code generation and has the ability to stand up against and compete with CodeSmith.  I have used both Codesmith and MyGeneration a lot in the past few years, so I have seen the competition.  What is nice about this old/non publicized tool is that it is built directly into Visual Studio 2008.

t4 is being spear headed into the open source market for free templates by Oleg Sych.  It brings a long a toolbox which can also be download with extra templates along with a GREAT T4 Editor which of course is also free.  There is not more need to spend money on CodeSmith, when Microsoft will do it right out of the box with Visual Studio.

Some have speculated, why hasn't Microsoft published this tool to a greater extent.  We can only think that it has to do with being a Gold Partner.  Microsoft doesn't like to lose Gold Partners and therefore hasn't truly publicized this tool.  The next question you have to ask your self is what can be generated?

  • Site Maps.
  • Database schemas.
  • Session Variables. 
  • Store Procedures.
  • Text Documents.

As of October 2008, t4 Editor has been officially placed as a plug in to Visual Studio 2010, which will boost the ability to generate t4 code through other means besides CodeSmith.

Demos and Other information can be found below.

Point of concern: If your company currently uses CodeSmith, wouldn't it be nice to tell your boss what you found could save the company a few hundred dollars by using something that is already built into Visual Studio? So why not give it a try and save a little money doing it?

kick it on

If you liked this post, please be sure to subscribe to my RSS Feed.

Another way of thinking about how to store data inspired by ASP.NET

14. October 2008 10:38 by Scott in   //  Tags: , ,   //   Comments (49)

A while back I witnessed how the profile properties of ASP.NET are stored in the database.  All the properties all stored in one string.  There is then another string that describes the properties and how to view them and pull them from the database.

For example you have this string:

Then you have another string that looks like this:

If you break it down correctly you could get something like this:

  • Property Name : SmtpServer
  • Property Type : string (S) <-- Or this could be the Serialize As Type
  • Property Start Index : 0
  • Property String Length : 18

Now the question that I ask my self is:
Does this actually increase performance of the system?

I would argue yes and no.  Since the system could have an infinite amount of members attached to it and a countless amount of profile properties.  It would need to have something like this to decrease the amount of rows owned by a single user in the profile table. To give an example, I could be one user with 20 propertie.  If the application had over 1,000,000 users, that would be 20,000,000 rows.  That is huge and you must design for scale when it comes to an application that could potentially be used by all the world.

I would argue no to small applications.  If you only ever expect 1,000 users to an application, then why build something this complex other than for the thrill of it. This is especially the case when you don't need to worry about space on the system.  Space is cheap, but time spent coding a solution for this sample could be huge depending on experience.

I personally would build a generic code base for two ideas of this kind.  You could first build the generic code for the example above, but there would be another generic sample to build for. Lets say that you knew you were only going to ever store numbers in your database for each user.  These numbers could be used for ID's of another tables real data.  So I only want to store ID's of a table for each user.

I would store them like:

This is because I wouldn't need another cell to split them up with indexes.  I would just split the numbers by the Colon. I would love to hear everyone's thoughts on this and why or why not it is a good choice.  Thanks for the time to read this.

kick it on

If you liked this post, please be sure to subscribe to my RSS Feed.