Home Blog Page 2

Extracting the InviteRedeemer class from the Invite model in Discourse – Part 3

The results of previous post left us in decent shape to finish up the refactoring of the InviteRedeemer#redeem method.  The gist below shows the starting point for this portion of the refactoring. The private methods are left out for brevity. The first thing to tackle is the multiple assignments to the result variable.  The first change is to replace the nil...

Extracting the InviteRedeemer class from the Invite model in Discourse – Part 2

In the previous post, the InviteRedeemer struct was extracted in order to isolate the functionality required to redeem an invite.  When we left off, the redeem method had been moved to InviteRedeemer and all the tests were passing which gives the assurance that we have preserved all of the functionality required. The starting point for the next steps are based...

Extracting the InviteRedeemer class from the Invite model in Discourse – Part 1

After poking around the Discourse project on Code Climate, I found that the Invite#redeem method was given a high complexity score. After studying the redeem method for a bit, I decided it would be a good subject for the next refactoring. The method that we started with is shown below. While looking at the original method, there are a few things...

But What About Testing?

In the last post, I didn't mention testing but please don't take that to mean that no testing was done.  I ran tests as soon as I forked the repository and after each small change.  Like I heard at the recent Ancient City Ruby conference, you don't want to stay in the red too long. While I was living in...

Removing Duplication From the Post Model in Discourse

Discourse made a big splash a few months back when the project was first revealed.  Being that it's such a well known codebase in the Ruby community I decided to spend some time doing some minor refactoring to get my feet wet. After looking at the scores on Code Climate, the Post model seemed like a good place to start....

The Shift

In November 2011, I took a Ruby on Rails Pragmatic Studio class taught by Jim Weirich and Dave Thomas where I learned just how different things could be when you've been a Microsoft guy all of your career. While I will continue to use .Net and other Microsoft products on a regular basis, I feel that Ruby and Rails...