Tag: programming

Helper Methods and Code Readability

Helper methods, or helper functions, are smaller pieces of code that perform part of an overall task. Often, when we write helper methods, it’s because we want to factor out a piece of code that’s common across multiple higher-level methods. But, we shouldn’t be afraid to write helper methods just for the sake of improved readability in a single algorithm as well.

Aborting on Programming Errors

Programming errors can be as small and subtle as an off-by-one error in a loop, or as large as a flaw in the implementation or design of an important algorithm. What should our code do when it runs into this type of error? In most cases, we shouldn’t be afraid just to make our program abort.

Making Objects Immutable

This blog post describes what immutable objects are in object-oriented programming. After reading this post, you should be able to implement immutable objects, and understand how they can be used to prevent unintended side effects in our code.

Computing Power Sets

This blog post describes what power sets are and how to compute them recursively. After reading this post, you should understand how to derive the power set of a given set, and appreciate the immense computational expense of computing a power set.

Wrapping Multiline Macros in C With Do/While

This blog post describes logical errors that can occur with multiline macros in C programming, and demonstrates how to resolve them directly in the definition of the macro itself. After reading this post, you should understand why wrapping multiline C macros with a “do/while” statement is a best practice to avoid these logical errors.