/img/cartoon-avatar.jpg

Ryan Rinaldi

Wrangling in Legacy Code

Working with legacy code can be a challenge, but with a few best practices in place, it can become a manageable task. Over the years, I’ve learned a few tips that make it easier for teams to get a grip on the codebase. Set up a script for the local environment. To streamline the process, use the tools that the team is most familiar with, whether it be Vagrant, Chef, Powershell DSC, or something else.

Programming by coincidence

As a developer it’s of super duper importance that we understand what each and every line of code that we write does and how it works. While a lot of code that we write leverages libraries to provide wonderful abstractions over complex implementations we owe it to ourselves, the businesses that we work for and other developers on our teams to understand what these libraries are doing and how they are doing it.

Scrum - One team, multiple projects?

At work we are in the process of implementing Scrum (actually tomorrow is our first Sprint Planning meeting. Really looking forward to it.) Everybody on the team has read the books on Scrum and we are all very excited to finally be formalizing our processes but we are in disagreement about how best to actually implement Scrum. The problem is that we are a small team responsible for a set of pretty independent applications.

SQL Server - Full text indexing of html content

Sorry for the long and boring title, but I wanted to make it easy for Google to find this post. If you happen to have a site that is storing Unicode (that’s bold because it’s important, as you will see later!) HTML content in a SQL Server database and you want to enable full text indexing there are a few hoops you have to jump through that aren’t obvious. First of all, you can’t store your content as varchar, nvarchar or text.

Stupid SQL tricks

Don’t ask why I needed this, but here is a SQL function that will abbreviate a string: create function dbo.fnAbbreviate(@source nvarchar(100)) returns nvarchar(100) begin if charindex(' ', @source) = 0 return @source declare @result nvarchar(100) declare @i int declare @char nvarchar(1) set @result = '' set @i = 0; while @i < len(@source) begin set @char = substring(@source, @i, 1) if CONVERT(varbinary, @char) = CONVERT(varbinary, UPPER(@char)) begin set @result = @result + @char end set @i = @i + 1 end set @result = REPLACE(@result, ' ', '') return @result; end

Tooling

What tools do you use? If you are reading this I bet you use some flavor of Visual Studio and some form of source control, but like most developers your tooling stops there. Why? Have you tried the various Visual Studio add-ins like ReSharper or CodeRush? How about SQL Schema diff tools like SQL Compare from Red-Gate? How about a build server like Team Build or Cruise Control? Most developers I know would answer no to most of those questions.