Extreme Programming: Try Avoiding These Usual Suspects

Today I was really lucky to attend an workshop by expert software engineer Corey Haines. Corey challenged us to go extreme with avoiding the following common programming pitfalls:


Long methods are where bugs go to hide. It’s a good rule of thumb to keep your methods to less than 3 lines. Super long methods are really hard to understand, especially when looking over your code later, or if someone else comes into your codebase. If your methods are getting too long, try to refactor by extracting some of the lines of code into other methods. Keep it simple!


This one is super counter-intuitive, but if statements are actually not very object oriented (OO). Your method should do one thing. With an IF statement, you’re asking the method to do two things. If you’re finding yourself using an if statement, really think about what you’re trying to accomplish, and whether you need to create another object instead.

No Primitives

Avoid passing primitive data structures (e.g. arrays, hashes, numbers, booleans) between methods. If you’re passing in more than one thing into a method, consider making a new Object. Only objects or lists of objects should be passed between methods.

Enjoy the article? Join over 17,500+ Swift developers and enthusiasts who get my weekly updates.