Jean Hibbert's Blog

.NET Framework, SQL Server and other random thoughts.

September 2008 - Posts

"Nice to have" VS "Must Have"

Programmers enjoy writing code. As long as we are not under too much preassure, its always fun to add those features into the system that are "nice to have" rather than critical or "must have" features. We have become "Code Addicts". By adding all these unessesary features it allows us to play with the technology and learn from our mistakes, even if it's not at our own cost.

This is unfortunately a reality. I call to all developers there to fight their code addiction. When it gets to features, LESS IS ALWAYS MORE.

Try to find:

- The solution that involved the least amount of lines of code.

- The solution that leverages the technology in the way it is supposed to be leveraged.

- The soluton that results in a refactored whole.


Complexity results in the following:

1. Longer time periods to train up support programmer who need to support the system.

2. Greater likelihood that there are unforeseen functional bugs in the system.

3. More time is required to fix and find bugs in complex systems.

4. Non-technical staff (including management) becoming skeptical and negative towards the IT industry due to support issues.

I'm not saying that there are not times when I complex problem requires a complex solution, but we must always strive to find the shortest path through the forest.

Billy Hollis, one of my heroes will be giving a talk at the 2008 Patterns and Practices Summit in Seattle this year which I will be attending. The topic is "Drowing in Complexity". Seems like I'm not the only one aware of this problem! :-)

Jean

SubSonic vs Nettiers

I've recently been working extensively with 2 ORMS. Subsonic and Nettiers. Both really good ORMS. My favourite though without a doubt is Subsonic written and designed by Rob Connery who just coincidentally now works for the ASP.NET team at Microsoft. 

Reasons I like Subsonic:

1. Its extremely lightweight. It creates stored procedure objects that return readers or datasets.

eg.

 

    public static System.Data.DataSet GetItemTypesForClientTypeSysID(int clienttypesysid, bool bIsBatch)

    {

        StoredProcedure sp = SPs.ProcSelectItemsForClientType(clienttypesysid, bIsBatch);

        return sp.GetDataSet();

    }

 

2. You can write queries in your code that can do most things including using the SQL where / ordering and only selecting specific columns.

eg

    public static int GetClientTypeSysIDFromDesc(string clienttypedesc)

    {

 

        int tempID = 0;

        Query query = new Query(TblClientType.Schema.TableName);

        query.SelectList = TblClientType.Columns.Sysid;

        query.AddWhere(TblClientType.Columns.ClientTypeDesc, Comparison.Equals, clienttypedesc);

        query.QueryType = QueryType.Select;

        tempID = (int)query.ExecuteScalar();

        return tempID;

    }

 3. Its rediculously easy to set up. You need 1) Download the subsonic libraries, 2) Run the install so that VS will pick it up, and then 3) make an update the config file's of the projects which will be using the ORM. Obviously you need to reference the subsonic libraries also.

Reasons I like Nettiers.

1.  The documentation is pretty good.

2. Setting up nettiers is also straight forward. 1) Download the templates Codesmith Templates, 2) BUY a copy of codesmith and generate the ORM layer.

The Nettiers templates are written by the author of codesmith.... This.... in my opinion is a sales stunt although any intermediate programmer should use codesmith anyway. It's and awesome template based code generation tool.

3. You can perform DeepSave and DeepLoad actions where you are able to save and load object trees based on relational database mappings.

4. You are able to create a web services layer. With some tinkering you can expose this layer as a WCF service and thus create middle-tier DAL that is accessible using your protocol/security strategy (aka Binding) of choice.

5. Nettiers also has its own cuncurrency functionality built in assuming that all the database tables used to generate the ORM have a timestamp field.

Note: Nettiers does generate a lot of code though, and if you don't use the custom TList collection object (which doesn't lend itself well to databinding) you won't be able to deepsave and deepload. Hopefully this will be fixed in later versions of nettiers.

Jean

Passion

Passion. It's a double edged sword. It can be used to achieve your wildest dreams and goals or it can make one very self destructive.

Its that feeling you get in your chest when you listen to Beethoven's 9th symphony and the vocals kick in. Its that feeling you get when you are hill training and your whole body is aching but you enjoy the pain... It's the excitement that comes with channeling the stress at work into whatever you are doing.

We should all do our best to find our passions and when we do never let the flame burn out.

Posted: Sep 20 2008, 04:40 AM by jean
Filed under:
Removing the Tool container from the Workflowview

 I've just recently been asked to make a 'minor' change to a customized version of the WorkflowView which forms part of the System.Workflow.ComponentModel.Design namespace.

The image below highlights the ToolContainer:

 

By investigating the WorkflowView object using reflector I discovered that there was an internal field called ShowToolContainter that is hard-coded to true. See below:

 

By using  reflection you can set this property to false!! Thus removing those irritating buttons.


Type t = _workflowView.GetType();

//// Set the parent field.

t.InvokeMember("ShowToolContainer", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.SetProperty, null, _workflowView, new Object[] { false });

Where there is a will there is a way!! You can use this technique in future to set other internal properties which the framework does not expose.

Jean

 

 

Posted: Sep 11 2008, 02:37 AM by jean
Filed under: