Archive

Archive for the ‘Refactoring’ Category

Richmond Code Camp 3 reviewed

This last Saturday morning, the Thycotic team headed to Richmond at a bright and early 6am. This alone wouldn’t have been too bad but some on the team had been busy until 2am on a client project! For the first Richmond Code Camp ever, it actually didn’t rain (it rained all day for the last two).

John started out withhis presentation on NHibernate which drew alarge audience. I watched Hal Hayes (of Acritech) present on XQuery which is an interesting session that I have somehow missed at the various local usergroups over the last year. Then I caught upwith Frank at hisTablet PC session – he confirmed my suspicions that the handwriting recognition has been greatly improved in Vista. He also pointed me towards these great tablet applicationswhich I just had to try –Ink Artallows you to paint in oil on your tablet! Frank was showing it on Vista but it doesn’t seem to be included in the Experience Pack for Vista … Frank?

I did find ArtRage2 in my quest which seems to do a similar job. There is something incredibly cool about painting on a tablet.

Unfortunately I didn’t get to attend any further sessions since I was presenting for the last two slots of the day. Which also meant that I missed John’s second session (Lucene.NET) and Kevin’s first presentation at a Code Camp where he covered Cryptography and Hashing which is something he knows a great deal about – Kevin did the second round of Cryptography work in our Secret Server product. I also heard wonderful stories about our other presenting team member, Bryce, whose laptop wouldn’t cooperate and he had to wing his entire session on Code Access Security with no code or slides (this was also only his second Code Camp presentation ever – nice job Bryce!).

My two sessions were Refactoring (a hands on session using Bob Martin’s Prime Generator example) and Unit Testing with RhinoMocks. Session slides should be posted on the Richmond Code Camp website soon. The Refactoring session worked out really well with the sizeOfArray and primeCandidates variables naturally emerging as the instance field candidates – the audience also got very involved and yelled out lots of ideas. Working with code line by line and generating discussion is always fascinating.

Thanks to the folks at the Richmond Code Camp for organizing another fine event.

Jonathan Cogley is the CEO and founder of Thycotic Software, a .NET consulting company and ISV in Washington DC. Our product, Secret Server is a enterprise password manager system for teams to secure their passwords. Where do you keep your passwords or do you still use the samepassword everywhere?

Refactoring example in C# and VB.NET

March 26, 2007 1 comment

Our very own Bryant Smith has revamped his conversion of Martin Fowler’s refactoring example (originally in Java) to nowcover both C# and VB.NET.

You can find the article here with the relevant downloads and walkthrough.

Martin Fowler’s example works nicely because it is a simple class structurethat is easy to understand. It alsohas enough complexity to allow refactorings like MoveMethod to show how data and operations should be related. I also like Bob Martin’s refactoring example on generating primes but it doesn’t have much of the OO feel since the whole thing is really just one method being broken out with little instance data. Both examples are great for debating techniques and trying out new ideas. A book filled withrefactoringpuzzles would be a great resource … anyone?

Our team has a weekly Friday morning meeting where we experiment with new techniques and ideas – we have done both of the mentioned refactoring examples by breaking our team into programming pairs and then comparing their solutions at the end. This is a lot of fun and allows the team to experiment with refactoring ideas outside of the deadline crunch. Both examples have worked well in this environment and have helped to spread adoption and familiarity of refactoring techniques across the group. Of course, everyday pairing also helps but sometimes it is nice to refactor it several different ways and then compare approaches (something a client might not be too excited about! :)) – although the learning experience is fantastic.

If you are interested in joining our team where we practice Test Driven Development, Pair Programming and Refactoring daily – we are hiring.

Jonathan Cogley is the CEO and founder of Thycotic Software, a .NET consulting company and ISV in Washington DC. Our product, Secret Server is an enterprise password management system for teams to secure their passwords. Where do you keep your passwords or do you use the samepassword everywhere?

Whitespace is a code smell

March 23, 2007 11 comments

Do you space out your code so there are line breaks between the pieces of logic? Whydo you think this isnecessary? Typically this is done to separate chunks of logic so that they can be easily distinguished. If it is a complicated enough chunk, then it may even make sense to put a comment at the top of the chunk. At this point, the Agile police will jump on you and tell you to turn your comment intoa method name and perform an Extract Method refactoring. This is great practice (fellow Agile police member here!) and it makes a lot of sense since it abstracts the concept and makes the code more self describing.

But let's thinkback to those line breaks again … if it needed the line breaks, then there is code smell. If your code needs whitespace in the method to make it cleaner to read then it is probably doing too much. Of course, this is very subjective and easy to argue (heck – our team can't fully agree on this either!) but think carefully the next time you find yourself adding extra whitespace to your code and think:

  • Is this code as simple as it should be?
  • Does this logic all belong here or could it be broken out into other methods/classes?

Jonathan Cogley is the CEO and founder of Thycotic Software, a .NET consulting company and ISV in Washington DC. Our product, Secret Server is an enterprise password management system for teams to secure their passwords. Where do you keep your passwords or do you use the samepassword everywhere?