New Tools Require New Standards

“An old belief is like an old shoe.  We so value its comfort that we fail to notice the hole in it.”
Robert Brault

As developers we all have standards, even if they aren’t that well defined.  Of course I’m talking about technology standards but feel free to insert your social awareness and/or hygiene standard joke here.  Standards can range from the usual coding standards to the names you give your servers (e.g Lord of the Rings Characters) and everything in-between.

Having been a developer for one third of my life, I’ve developed quite a few standards of my own.  Having worked in Windows shops most of my career, most my standards are focused around those tools.

Ruby on RailsWhen I first tried Ruby on Rails, I was prepared for a new website architecture (e.g. MVC).  What I wasn’t prepared for was adopting the new coding standards that Ruby encouraged.  With my brain already overloaded with the new architecture, I found myself writing Ruby code as though it was C# code.  The biggest one I noticed was naming my database tables and fields in camel case format instead of the underscore format that Rails encouraged.

I know this sounds stupid now, but at the time, my poor overloaded brain wanted to keep using the camel case names even though the tool, Rails, didn’t encourage it.  I even went as far as to look up how to override the underscore names before I came to my senses.

Crushing your HeadIt’s easy to forget but the main reason for having standards is to “compensate for the strictly limited size of our skulls”.  As Steve McConnell says:

“The primary benefit of a coding standard is that it reduces the complexity burden associated with revisiting formatting, documentation, and naming decisions with every line of code you write. When you standardize such decisions, you free up mental resources that can be focused on more challenging aspects of the programming problem.”

Often standards arise  from the tools being used.  All tools come with their own standards from the creators and community at large.  In some cases, a standard is created to work around a limitation of the tools being used.  Just remember that when you switch to a new tool, such as when I tried Ruby on Rails, the old standards might not be applicable anymore.  Let me repeat that for emphasis:

When you switch tools, your existing standards will have to change.

This is a rule I am struggling to remember and I’ve only been a developer for one third of my life.  Now imagine you have been a developer for over half your life.  How hard is it to give up on your well worn standards when faced with a new tool?  Very hard, I think, based on this summarized experience I recently had:

  • Start developing application using Fluent NHibernate as it will be the company’s new standard.
  • Well into development, find out the company’s existing standards require all database access to go through stored procedures.  Brought to our attention by a tech lead who had been a DBA for over half his life.
  • Have several meetings and e-mails about the impact of re-writing the code to meet the standard and how the tool NHibernate doesn’t work well with their existing stored procedures standard.
  • The tech lead relents and allows us to use NHibernate as it was designed.

There is a much longer story but the important part is the tech lead realized that if you are adopting a new tool at your company, your existing standards will have to change.  Remember that the standards he had helped reduce his mental load.  Being a technical lead is enough work without having to learn a new set of standards.

My hope is that after I’ve been a developer half my life, I remember my own rule and am willing to adapt my entrenched standards to a new tool despite the pain it might cause my brain.

Posted in Software Development | Tagged , , | Comments Off on New Tools Require New Standards

The Taxman

Well, it’s that time of year in the SaturdayMP basement… The tax deadline for filing 2009 personal taxes in Canada is April 30

We’re slowly gathering dusty papers to send to our accountants, the fine folks at Every Bean Counts (great name!)

Before SaturdayMP and the olden days of High C consulting, we did our own taxes using personal tax software and NETFILEd the paperwork then headed to the bank. If we were prepared, we’d have the correct crumbled up piece of paper with the (correct) amount we owed scribbled on it. There, the teller would stamp it several times, emphatically, then withdraw the money from our accounts in no time.

It was really efficient with the exception of 2007 when too many taxpayers with the internet crashed NETFILE… anyway, it’s a little too efficient for my tastes: it’s so cruel to consider it takes a full 365.25 days to earn the money and literally seconds to suck it out of the account.

PS My favourite episode of Corner Gas was “The Taxman”. If you haven’t seen it yet, go rent Season 1.

Posted in Uncategorized | Tagged , | Comments Off on The Taxman

SaturdayMP to-do list

  • Laundry
  • Payroll
  • Payroll
  • Create Secret Project
  • Laundry
  • Enjoy summer
  • Laundry
  • Test Secret Project
  • Payroll
  • Update News/blog re: Secret Project
  • Start Super-secret project
  • Oil change
  • Laundry
  • Payroll
  • Finish Super-secret project
  • Change Furnace Filter
  • Laundry
  • Yearend Tax stuff
  • Enjoy first snow fall
  • More payroll
  • More laundry
  • Start Really super secret project
  • The basement-based fun never ends…

    Posted in Fun | Tagged , , , | Comments Off on SaturdayMP to-do list

    Starting Any Method in a New Thread Using .NET

    The main problem I encountered was creating a function to accept any function pointer along with an unknown number of arguments.  I got around this problem using the ThreadStart and delegate() features in C# (.NET 3.5).  First off create your method to take any method as so:

    public static Thread StartMethodInNewThread(ThreadStart methodToStart)
    {
        // Do common some stuff before starting the thread, such as logging.
    
        // Start the task in a new thread
        Thread t = new Thread(methodToStart);
        t.Start();
    
        // Do some stuff after starting the thread, such as more logging.
    
        // If the caller cares you can return the thread.
        return t;
    }
    

    Now anywhere in your code where you need to start a new method in a thread write the following:

    // Example of starting an instantiated object method in
    // a new thread.
    FooBar fb = new FooBar();
    ThreadStart ts = new ThreadStart(delegate() { fb.Foo(1, 2); });
    _fooThread = ThreadHelper.StartMethodInNewThread(ts);
    
    // Example of a static method.
    ThreadStart ts = new ThreadStart(delegate() { FooBar.Bar(3, "String D"); });
    _barThread = ThreadHelper.StartMethodInNewThread(ts);
    

    The secret is the ThreadStart, delegate, and Anonymous Methods features.  The ThreadStart object accepts any delegate.  The delegate along with Anonymous Methods allows you create a code block that contains just the one method, along with arguments, that you want to execute.

    The caller is responsible for creating the ThreadStart object with the method, along with it’s arguments, to run in a separate thread along with it’s arguments.  Once wrapped in the ThreadStart object it can be safely passed to the thread starting method.  The thread starting method can do any common actions before and after starting the thread.

    You can find a working example at:

    http://bitbucket.org/chris_c/examples/

    Look in the StartAnyMethodInNewThread folder.

    Posted in Code Examples | Tagged , | Comments Off on Starting Any Method in a New Thread Using .NET

    Use Fun Addresses when Demoing your Software

    Next time your entering data for a software demo try spicing it up and sneak some your famous real or fictional addresses.  Often you can’t use the fictional state/province but the street addresses are easy to sneak into a demo, or even better, into your product documentation.  Some ideas to get you thinking:

    #101 1984
    Miniluv Building
    London, Oceania

    1428 Elm Street
    Madstop, New England
    United States

    123 Sesame Street

    211b Baker Street
    London, England

    1600 Pennsylvania Ave NW
    Washington, DC
    United States

    Candy Cane Lane
    North Pole
    H0H 0H0
    Canada

    742 Evergreen Terrace
    Springfield
    United States

    11235-813 Avenue
    Fibonacci, BC

    Finally, for the immature in Canada, try using the following postal code (the Canadian version of zip codes) T1T-1E5.  It’s event better if your software doesn’t display dash in the middle.

    Posted in Fun | Tagged | Comments Off on Use Fun Addresses when Demoing your Software

    Another Basement Dweller?

    Hi,

    I should introduce myself. I’m Ada, co-founder of Saturday MP. By co-founder, it basically means Chris asked me if he could start a company and I (finally) said yes.

    Chris has given me permission to post to the blog. This may be a mistake because I seem innocent but I can also have a perverse sense of humour. While I’m no stranger to computers, the internet nor the blog-world, the circles I run in tend to revolve around knit blogs and ravelry. There, I’ve shown my true colours. You want more? I. Am. Canadian. I spell “Canadian” so you’ll see a lot of “u’s” in my posts. Chris doesn’t care as much – he’s Canadian too, but let’s face it, he doesn’t worry too much about spelling.

    So, you’ll know if I’m posting because of the spelling, the motherly touch I give to the posts but really, the lack of tehcnical-ese content. Don’t get me wrong, I had my fair share of geekiness (first computer was a Vic20 with tape drive, I loved my Q-BASIC programming courses, first e-mail viewer was PINE, and I can probably still navigate around in AIX), but the point of the blog is to shine a bit of light on the glamourous world of basement-based software development. It’s not all sunshine and roses (especially not in the basement) but it can be exciting. If it’s something that you’re considering, we hope you follow along.

    So…

    I like to share funny stories to break the ice.

    Before we collaborated on SaturdayMP, I had my own company, a sole proprietorship. I had a business number and I billed under the name “High C Consulting”. I repeatedly “score” an off the chart C on the DiSC profile analysis. Plus, I’m a singer. Yes, I can reach that high C. Sometimes when we’re being funny between our 4 walls, we refer to the company as “wrong-notes consulting” or “off-key consulting”.

    I thought you’d appreciate my humour.

    Posted in Uncategorized | Tagged , , , , | Comments Off on Another Basement Dweller?

    Save Your Envrionment

    Do you remember VB Commenter?  Probably not because all the cool kids, like you, where using C# so you had no need for it.  See, way back in the Visual Studio 2003 era only .NET’s favorite child, C#, had support for XML comments.  Some jealous VB.NET developer (sorry, can’t remember who) wanted VB.NET to be just as cool so VB Commenter addin was created.

    Still back in the Visual Studio 2003 era I created rules engine where the end user could script their own rules and hook them into their business application.  The rules referenced pre-compiled business objects.  To create documentation for the end user about these objects I used VB Commenter along with NDoc to generate a MSDN help file.

    Fast forward a couple years later and I end up working on the same rules engine code base but with a different company (it’s a long story).  One of the first things I was asked was how to create the rules documentation.  Once I explained how the second question I was asked was if I had copy of VB Commenter.  I didn’t have a copy and told my co-worker to just download it.  Unfortunately he couldn’t find it on the web and neither could I.  That meant we couldn’t generate the rules documentation which sucked.  Actually we were able to generate them again but it was a lot of work.

    FYI: It appears that VB Commenter has re-appeared here.

    The moral of my story is you should store 3rd party libraries and tools.  Don’t rely on them forever being on the internet.  I recommend storing it with your source code in your source code management (SCM) tool an idea I got from the excellent Under Pressure and On Time book.  The book, and myself, recommend storing all the items, within reason, you need to setup your build machine and developer workstations.

    When I setup a project in source control now I create a “Env” folder, short for environment. Inside this folder I put all the items needed to create the projects build machine and developer workstation.  For example, Mini-Compressor Env folder has the following:

    Mini-Compressor Env Folder

    The Saturday MP website Env folder has the following:

    Saturday MP Env Folder

    The goal when setting up my build machine or developer workstation is to do the following:

    1. Install the operating system.
    2. Install items not in the Env folder, such as Visual Studio.
    3. Install the source code control tool.
    4. Do a get latest to get the source good.
    5. Install the items from the Env folder.

    Ideally, all items such as your compiler, IDE, etc would all be in the Env folder but tools, like Visual Studio, are large and don’t play nice with SCM tools.  You don’t want people to have to download over 2 Gigs when doing a get latest version from you version control.  For these large tools I recommend backing them up somewhere else but close to you version control tool.

    Just recently I migrated my build machine and developer workstation from Windows Vista to Windows 7.  Having everything in the Env folder was a real time and life saver.  For example, to setup Ruby and Rails to use MySQL on Windows you need a specific version of MySQL and the magical libmySQL.dll file.  If you don’t have the libmySQL.dll or the wrong version of MySQL you won’t be able to access your database.  Having the libmySQL.dll file along with specific verions of MySQL in Env saved me the hassle of finding these items on the internet again.  Having a document that outlines your workstation setup, “Windows Setup.txt” also helped.

    So once again the moral of the story is: Make sure you have all the items required to build your project, preferably in your SCM.

    Posted in Uncategorized | Tagged | Comments Off on Save Your Envrionment

    Building for Both 32 and 64 Bit Architectures

    My latest task has been getting Mini-Compressor to work on Windows 7.  In the end no code changes are actually required to get Mini-Compressor working on Windows 7 but the installer required a bit of work.  The amount of work was actually minimal but it turned into a big pain because I didn’t document the installer and had to relearn a couple key points.  To prevent this from happening again I thought I’d better take some notes on the problems I encountered and share them with you dear reader.  That way you won’t make the same mistakes I made twice.

    For .NET projects you don’t have to worry about the bit-i-ness, just pick the Platform of “Any CPU” and it will work fine on both 32 and 64 bit architectures.   For C++ projects you need specify the platform which is Win32 or x64.  This means your build will require two compiles, one for each platform.

    Create a new solution (Release-64) and project configuration (Release64).  I have a dash in the solution one so I know it’s a solution configuration not a project one.  In both cases when prompted copy from the existing Release configuration and don’t create the corisponding project/solution configuration.

    Creating Release-64 Configuration

    Also create the x64 platform if it doesn’t exist.  Tip: If you can’t create the x64 platform from the Configuration Manager you probably didn’t install the x64 compilers.  To fix this problem go to Add/Remove Programs and choose to Uninstall/Change Visual Studio 2008.  When prompted choose “Add or Remove Features” then make sure the x64 compilers is selected.

    Now the you have the configurations created set them up in the configuration manager.  In the screen shots below MiniCompShellExt is the C++ applicaiton.  You can also ignore the “32” at the end of MiniCompInstaller32 as it can handle create 32 and 64 bit installers.  I’m just lazy and haven’t bothered to change the name yet.

    Finally adjust your C++ projects settings as shown below.  When the Release Configuration is selected make sure the Platform is Win32 and when the Release64 Configuration is selected that the Platform is x64.  Selecting the x64 Platform will update some the settings for you but it never hurts to check.   The settings you are interested in are the “C/C++–>Preprocessor–>Preprocessor Definitions” and “Linker–>Advanced–>Target Machine”.  The examples below show the x64 settings:

    Now you can compile both a 32 and 64 bit application.  Mini-Compressor uses an NAnt build script and the compile target looks like:

    <target name="compile" description="Compiles the code.">
      <exec program="Devenv.com" basedir="C:Program Files (x86)Microsoft Visual Studio 9.0Common7IDE">
        <arg line='/rebuild "${slnconfig}" "MiniComp.sln"' />
       </exec>
     </target>
    

    During the automated build the NAnt script is called twice. Once with ${slnconfig} set to Release and then to Release-64.

    Posted in Uncategorized | Tagged , | Comments Off on Building for Both 32 and 64 Bit Architectures