stevedoria.net

reused, like this site's design

Archive for the 'Refactoring' Category

Write Less Code: C# Properties

February 15th, 2018 Posted in C#, Refactoring | Comments »

I inherited the responsibility of maintaining an internal development tool implemented in C#. I recently added new classes to extend the tool’s functionality. Several of the new classes uses several properties, and I found myself writing code similar to the following: class Shape { private int _width; private int _height; private bool _isVisible; public int […]

Refactoring Could’ve Saved the Day

November 2nd, 2007 Posted in Refactoring, Software Engineering | Comments »

I have ran into a few snags while trying to update parts of my code that depended on other peoples’ code. Other people updated the interface of their modules, and I needed to update the way my module interacted with theirs. Being slightly optimistic and feeling a bit of schedule pressure, a simple identifier substitution […]

Explicitly Redundant

October 12th, 2007 Posted in Refactoring | Comments »

Today, I caught myself doing this: bool f() { bool r; if( x == y ) { r = true; } else { r = false; } return r; } When I really should have written: bool f() { return x == y; } In the actual code I that I was writing, x and […]