Comments In Our Code: Necessary or Not?

Robert Rice Development Technologies, Programming Leave a Comment

No matter what your opinion is on comments, one thing is universally true: developers should create code that the next developer can understand.

Sometimes, comments are a safe, simple way to leave the code better than how you found it. Sometimes, extracting sections of code into a well-named method can be an alternative way of doing this, with the added benefit that (a) you can test this method individually and (b) it may help you to spot smells in your code or see places for further refactoring or simplification.

Each situation you encounter will require different treatment, but I hope this post has given you a starting place for creating clean, readable code in your own life!

Refactoring: Ugly Code That Does Everything

Gabe Schmidt Development Technologies, JavaScript, Node.js, Programming, Tutorial Leave a Comment

If you’ve been writing code for a significant amount of time, you’re sure to have seen the—anything but godly—“God Method.” It’s a method that performs way too many processes in the system and has grown beyond all realistic logic to become “The Method That Does Everything.”

This single unsightly method can span dozens, if not hundreds, of lines. Sometimes even over 1,000! This type of “ugly code” is an unbearable beast to maintain. This is why it’s considered a “code smell” or anti-pattern.

In this tutorial, we walk through a tangible “God Method” and step through the process to refactor it into something more manageable and human-readable. Our code is written in JavaScript for a Node.js service, but the principles apply to any language.

A Better Approach to Merging Files in Git

Brice McIver Development Technologies, Git Leave a Comment

Git has many features, but it’s likely that you only use a small subset on a daily basis. While git tends to handle things intelligently most of the time, there are situations when doing the most obvious thing doesn’t give git enough information to make informed choices.

In this post, we’ll examine one such scenario – merging files. Through trial and error, I’ll show you the normal approach people take, some of the issues that occur with that approach, and a completely different approach that preserves some data lost in the first approach.