Category Archives: refactoring

Maybe that shouldn’t be settable

I think this is pretty, and I wanted to share. I like classes where the compiler ensures they are always in a valid state—you can’t help but use them correctly. I was writing a class that needed to call a … Continue reading 

| 22 Comments

A Guest Appearance On Tekpub’s Knockout.js Series

Tekpub release their series on Knockout.js recently and I was fortunate enough to make a guest appearance! Now I know you’re thinking “why would Derick make an appearance in a Knockout series?!” But don’t worry – I’m not there to … Continue reading 

| 1 Comment

Improve your LINQ with .Any()

LINQ’s .Any() method is under-utilized, given the benefits it brings in making your code briefer, clearer, and more efficient. LINQ in general improves the expressiveness of your collection-manipulating code by using declarative statements instead of imperative foreach loops; .Any() is … Continue reading 

| Tagged | 3 Comments

Running JavaScript… With Sneakers!

Code-review time. I haven’t written significant JavaScript in forevs, but I hit upon a use case well suited to it, had a blast coding it up, and am confident that I’ll be completely mystified by it three months from now. … Continue reading 

Also posted in arduino, JavaScript | 5 Comments

Rebuilding My Backbone.js Plugins With Modules, SRP and More

In the last few weeks, I’ve rebuilt and refactored a large amount of JavaScript code in both my Backbone.ModelBinding and Backbone.Memento plugins. In the process, I re-learned several object oriented design principles and how they apply to JavaScript. I also … Continue reading 

| Leave a comment

Legacy Operating Systems and Legacy Languages: If it ain’t broke, it still needs fixing

In my travels I’ve encountered systems chugging happily along on outdated, discontinued, unsupported technology stacks. Apps written in VB6, FoxPro, Classic ASP, still running without a hitch because the kinks had been shaken out years ago… Software users delicately avoiding … Continue reading 

| Leave a comment

An Object Lesson in Binary Compatibility

A riddle for you, friends: When is changing a method from return void to return Something a breaking change? If you already know the answer, then why hadn’t you told me? Could’ve saved me a fair bit of embarrassment. Ah … Continue reading 

Also posted in Open-Source Software | 4 Comments

Good Refactoring / Patterns For Simple UI Logic?

I’ve got a chunk of C# that sits inside of a very simple form. The form downloads an update from a web page – one of two possible downloads, based on which one is available – and shows a message … Continue reading 

| Leave a comment

A Less Ugly Switch Statement For C#

I know switch statements are considered “evil” because they are very procedural code, they violate the Open-Closed Principle, etc etc. But every now and then I don’t see a need to do anything more than a switch statement because the … Continue reading 

| Leave a comment

A Refactoring: Explicit Modeling And Reducing Duplication

A coworker showed me a method that had a series of guard clauses at the top and a series of sequential steps that had to be processed after that. All of the guard clauses and sequential steps were executed the … Continue reading 

| Leave a comment