Coding Tools Conflict With Old Coding Standards

WARNING:  This is not a jab at Lowy‘s Standards, I’m just picking on his stuff.  Smile [:)]  So don’t take it to heart, it’s just code.  Stick out tongue [:P]

So I’ve been creating tips o’ the day recently and I started reading through some of Juval Lowy’s C# Coding Standards.  I’m a follower of Microsoft’s & the Code Analysis/FxCop school of code creators.  I also tend to follow the idea that if it is generated, it should generate to specification with no bad code in there.  Sometimes I let things slide if the code base is really trustworthy, such as the Enterprise Application Blocks.  The reasons are long that I go by current code standards, the main reasons boil down to plain, cold, hard cash.

The simple fact is, if you don’t follow current standards it exponentially makes it more difficult to use all of the code generators, shortcuts (like ReSharper), and the legion of tools that are available for enhancing one’s ability to create good code.  While I was digging through Lowy‘s Coding Standards from IDesign I noticed a few standards that I have issue with.  If for any other reason than it costs more money, because it takes time to make changes to the tools, and thus, time is money.  Every machine one has to touch using standards that deviate from tool usage is lost time.

I know, I know, you’re probably thinking, “Adron!  How insanely obsessive compulsive!”  Yeah, well, I am.  It makes me good at what I do, it also makes me entertaining when I speak, drink, or randomly start conversations.  Let’s take a few examples just to prove my point.

In Lowy‘s Standards Document #4 is “Prefix private member variable with m_.  Use Pascal casing for the rest of the member variable name following the m_.“

public class SomeClass { private int m_Number }

The sample above is all fine and dandy, but seriously, why go old school C++ and use the m_ when one can just use the current Microsoft P&P Code Analysis/FxCop standard of just “number” or “someNumber”?  Because if you use m_, you have to alter your ReSharper template and when generating documentation it confuses some tools and in general, and when generating document it appears busy as if to add complexity where none is needed.

#20 is another item that just doesn’t really work.  It states “All member variables should be declared at the top, with one line seperating them from the properties or methods.”  This one I don’t have “that” much of a problem with, but there is a serious issue.  If you have a bunch of private members, do you know if you’ve created the appropriate respective public properly getter and setter?  Can you easily use the “prop” macro function that will allow you to generate the private and public property and all that is left is merely filling in the member name, type, and public property name?  Does it simplify what ReSharper does?  My simple rule of thumb is that you do what makes since for the file.  If you do heavy ReSharper and gen the properties then do split them as Lowy says.  But if you don’t have ReSharper than be sure to keep the private member with the public property it is for.  It is easier then to find your member and its associative property.

The last one I’m going to harp on is #10.  When doing Agile and TDD there is major emphasis that the tests are documentation.  “Use extensive external documentation for API documentation.” is somewhat counter to a live, actively changing, and readily maintained system.  I tend toward the TDD and tests are documentation approach because of the larger return on the investment developers get from this.  If the product is a software tool for other software purchasers, then yeah, create API documentation.  Otherwise keep a minimal amount of API documentation and test, test, test.

But I must say, in the end, the Lowy Standards document is some great stuff.  If you aren’t following extensive standards as he has laid out, his or Microsoft’s or whoever’s, it doesn’t matter.  To create great software one has to have good standards in place.  To have good change management and good process (Agile or otherwise) one needs good standards.

So hats off to Mr. Lowy, great job.  I just don’t agree 100%, but we wouldn’t be very good developers if we didn’t disagree on things sometimes.  Smile [:)]

kick it on DotNetKicks.com

More Tools! (That I forgot in the other post.)

Recently I made a post about tools you just have to use (at least after you’ve used them just once!).  Well there where a few that I had neglected to mention and a few I just stumbled back upon after realizing I had not installed them on my recent machine load.

  1. CodeSmith – If you have a layered application, use CodeSmith.  CodeSmith now does .netTiers, CSLA, NHibernate, Wilson’s ORMapper, APOSA, and more!  If you have a layered application (and it follow design pattern guidelines) you are probably very close to one of these already and should definitely check out generating the boiler plate code!  CodeSmith absolutely rules, I have 2 major projects under my belt now and am about to wrap another third, open source, project that utilizes CodeSmith generated code.  In every scenario it has drastically reduced code work and provided me to build projects that without I would have needed to hire or contract another developer to just handle the boiler plate while I completed the architecture design.  Instead I was able to surge ahead, create unit testing for the code base that I did have to manually create, and finish the projects on time and generally under budget!  Please note, I am NOT paid by anybody at CodeSmith!  I’m vouching for this product solely because I know what quality it is.- TestDriven.Net – This is an awesome unit testing add-in for Visual Studio.  If you’ve ever just wanted to execute a single test, this is the tool that does it!  Check it out, it’s low overhead and I’m betting you’ll dig it.- NCover – Code Coverage that will create unit tests if you are missing coverage.  I haven’t thoroughly used this software, but needless to say when the code base is of a decent size with more than 2 people contributing you should probably get some type of code coverage checker.- Reflector – Sometimes, you gotta know what’s under the hood.  This is the tool that helps you find out what is under there.

Anyway, those are the ones that I’ve somehow missed.  I’m going to throw all of these in the big bucket o’ tools list and get that published in the not too distant future.  At some point, I’m curious myself, how many tools and add-ins I actually have installed and use regularly for development.

Technorati Tags: Codesmith, .nettiers, csla, nhibernate, ormapper, aposa, design patterns, testdriven, unit testing, ncover, reflector

del.icio.us Tags: Codesmith, .nettiers, csla, nhibernate, ormapper, aposa, design patterns, testdriven, unit testing, ncover, reflector

Stored Procedures and Property Resets :: Tip O' The Day

Tip #1

As of a recent task I’ve had to go through and reset hundreds (literally, no exaggeration) of properties on some Infragistics Controls.  If you’ve ever worked with them you know how many properties and nested properties these controls have!  Well, lo’ and behold unbeknownst to me if you right click on the property there is a “Reset” option that will allow you to reset the property to the original value(s).

Tip #2 – Bonus Tip

If you’ve ever created stored procedures via the Database Project in Visual Studio you’ll notice that the default proc skeleton that is displayed has comments (or doesn’t depending on which version of Visual Studio).  This “template” file that Visual Studio uses is nothing more than a *.sql file located in the “C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\Templates\Database Project Items” directory with Visual Studio 2005.  Go in there and add your specific information to the file to cut down on stored proc coding time!

Primary Entry Focus

I was reading the great Neopoleon’s Blog last night and realized two things, I should add a bit more “pizzaz” (as they say on Dethklok’s Metacalypse) or A.K.A. personal diatribe.  Smile [:)]  I’ve been just kind of spurting out some overly general, random, off hand things and I’m going to push toward my actual 2 cents on technology, projects, and companies and also try to stick to more in depth articles.

So this stands as a warning!  Surprise [:O]

Thus my recent addition of the “rants” category will probably increase!  My category of “Discussion Points or Ideas” will probably also increase drastically as I have a lot of discussion points that would be interesting to begin.  So hopefully all 3 readers I have currently will enjoy my new directions, if not, my loss.  Sad [:(]

Windows Workflow Increases Coolness Factor

After making it through about 200+ pages of the book Essential Windows Workflow Foundation by Dharma Shukla and Bob Schmidt I discovered two capabilities that I really like about the Workflow Foundation.  The first is the database tables provided via the Workflow SDK that are used for persistence and tracking.  The second thing that caught my eye, which I had not even really thought about before, was the workflow display engine.  A part of the workflow foundation which provides actual graphical display of the workflow in a Visio Flowchart type fashion directly within an application.  Both of these sections I’m now going to elaborate on a little bit more, namely to show how to setup a basic installation of the database tables and how to put in place a workflow diagram into an application.

Workflow SQL Tracking and Persistence Tables

Most of these steps can be found at the linked MSDN page, but I’ve extrapolated by own instructions below.  Also this seemed a partial necessity since I couldn’t find instructions for setting up the tracking and persistence tables I’m rolling my own.  The MSDN articles for the persistence setup and tracking setup are available if one needs a step by step.  My directions a bit more cut and to the point.

Smile [:)]

First create a database for the tracking and persistence store to use such as “WorkflowStore“.  I know, real original.  But anyway, there are more important topics at hand!

Next find the SQL file “open the SQL script c:\WINDOWS\Microsoft.NET\Framework\v3.0\Windows Workflow Foundation\SQL\en\SqlTracking_Schema.sql“ and then run the “SQL script c:\WINDOWS\Microsoft.NET\Framework\v3.0\Windows Workflow Foundation\SQL\en\SqlTracking_Logic.sql“ file.  These two files take care of the tracking part of the workflow database.

After setting those up execute the SqlPersistenceService_Schema.sql file and the SqlPersistenceService_Logic.sql file to complete the persistence portion of the setup.

Now that the database is setup the respective web or application config files need to have some particulars added.  In the Services section of the config add the following:

“<add type=”System.Workflow.Runtime.Tracking.SqlTrackingService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ connectionString=”Initial Catalog=WorkflowTrackingStore;Data Source=localhost;Integrated Security=SSPI;”/>“

for tracking and

“<add type=”System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ connectionString=”Initial Catalog=WorkflowPersistenceStore;Data Source=localhost;Integrated Security=SSPI;” UnloadOnIdle=”true”/>“

for persistence.  For hosting the designer in a windows application stay tuned.  Until then, happy coding!

kick it on DotNetKicks.com