Chorn Sokun's Weblog

Conquer inner fear, push it to the limit!

Once upon a time there was a ^GENERIC^

leave a comment »

Man ! how many times did you hear me say “I’m love the Generic so MUCH”. Not only it elegant but it really got it gold purpose of code reduction. Let look back at my previous solution on ActiveRecord Type Hierarchy and see how generic could help me:

[ActiveRecord("List_Lookups", DiscriminatorColumn = "Type", 
  DiscriminatorType = "String", DiscriminatorValue = "NA")]
public class Lookup: ActiveRecordBase where T: class{.... some code ...}

and now for derived class DeleteAll(), FindAll() etc are just ready to be use isn’t that cool?

[ActiveRecord(DiscriminatorValue = "PTL")]
public class ProjectTypeList: Lookup{.. zero code ;)}

Now I am ready to focus on another matter ;)

By the way x1r0k3wl’s comment come to rescue.

Advertisements

Written by Chorn Sokun

November 2, 2007 at 10:45 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: