Subsonic, coding habits and other random thoughts

I was reading a post from Fredrik Normén’s blog today called What Purpose does the Repository Pattern have? I found this attempting to figure out how I was going to alter the SubSonic output to fit my own needs, which is, in a nutshell:

Create a single repository that allows the use of web services as well as database access.

I am not sure that all patterns have to be pure to be useful. I certainly believe one should be careful about altering patterns prior to truly understanding both their code and understanding the pattern.

I find most people that state they have reworked so-and-so’s software and made it much better (where so-and-so is a software giant) are simply full of it. Under the microscope, you often find some serious flaws in their architecture. This does not mean some software giants are not full of it, of course, just that those who gather a huge following generally have some clue of what they are doing.

On the other hand, I find most purists ending up with over engineered solutions, which can be just as bad. Sticking to strict guidelines just to stick to guidelines can get you into trouble. I say this with a disclaimer that the less experienced the developer, the more of a purist you want. Creative newbies more often destroy the box than think outside of the box.

The point here is you use patterns as tools. If you find that a minor alteration works for you, then consider it. Don’t reinvent the wheel, but allow some fluidity.  I would make sure you understood the purpose of the pattern before heading down the path, but once you do the due diligence, there is no reason you cannot alter things to make them work better. Have a good code review, however, or you might find you are a bozo after it is too late to turn back. Remember, many executives continue to sink money after sunk costs (ie, you are going to live with your bad code for a LONG time).

Fredrik did bring up something interesting that I wish to look at:

If we return an IQueryable<> instead of a IList from our Repository and decide to use LINQ To SQL, we will need to have something in mind. Correct me if I’m wrong, but the GetTable method used by LINQ to SQL will return a Table<> object, which implements the IQueryable<> interface. The Table<> object will hold a reference to the DataContext. So a call to the ToList() method of the IQueryable<> require the context.

If true, we may be working up some memory we never use, as the context is going to consume some memory. If true, I am not certain this is a big deal in most applications, but it would be something I would consider if you were looking at an application that needed to scale.

In the long run, I am going to make my decision to use SubSonic, or not, based on how much work I have to do to the underlying framework pieces. If I do not have to change anything, then I will go that route. If I have to alter things, then I will rethink my use of SubSonic. Either way, I thank Rob for the time to put the examples out there, as this is how I learn. And, if some of his design does suffer from performance problems, I am fairly certain he will work on it in the next release. That is part of getting the design right (The design is never right the first time).

BTW, Rob has commented on my last blog entry. I do not find this surprising, as I have found Microsoft employees, and MVPS for that matter, to be a very helpful group. If Rob can get me through this minefield without having to rewrite the SubSonic infrastructure, I will gladly examine it closer as my solution. If not, I learn more. It is a win either way for me.

Peace and Grace,


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: