A Kaleidoscope of Programming Languages: Lisp

When I was a kid, my favorite video game was Ultimate Mortal Kombat 3. When the game loaded, there was a quote:

There is no knowledge that is not power.

Continue reading “A Kaleidoscope of Programming Languages: Lisp”

Common Refactors: Part 1 – Conditionals

In this series, I’ll talk about common refactors I suggest when doing code review in my day to day. I’ll start with conditionals, including severals example refactors. The goal is to help produce code that’s easier to read and understand, and thus, easier to maintain and produces fewer bugs.

These examples will be in TypeScript but the refactors are common patterns and can apply to most languages out there, such as Python, Ruby, Swift, PHP, Java, Go, JavaScript, etc.

Continue reading “Common Refactors: Part 1 – Conditionals”

The Repository and Unit of Work Design Patterns

Most web applications we build benefit from having a separate “data access layer” (DAL) and separating business logic from database interaction.

The main advantages to this are easier testing and maintainability. Because business logic is separated from the actual implementation, you can write code in terms of higher level abstractions, rather than having to worry about specifics.

Continue reading “The Repository and Unit of Work Design Patterns”

My favorite Data Structure: The binary search tree

Ever wondered how computers organize information? Data structures are the building blocks that store and manage data efficiently.

Like filing cabinets for your computer, they decide how you can find, add, or remove information. Understanding data structures is key for developers, as they all have pros and cons, and choosing the right one can make or break your solution!

Continue reading “My favorite Data Structure: The binary search tree”

I See You: Intro to Observer Pattern

Observer pattern is a behavioral design pattern that attempts to resolve the problem of multiple objects depending on the state of a single object. Here’s an overview, and a somewhat simplified example.

Continue reading “I See You: Intro to Observer Pattern”

Rock Solid Business Logic: The Action Pattern

The Action Pattern is a rock solid solution for organizing business logic in an application. It works quite well for medium to large-ish projects. I like the Action Pattern because it introduces few concepts, unlike some more elaborate and complex designs. It’s flexible, scalable and helps me feel more confident in handling complex business logic in my work as a developer. Even though generative AI now plays a bigger role in programming, it does not replace actual software design, and the Action Pattern can be a great tool to have in your toolbox!

Continue reading “Rock Solid Business Logic: The Action Pattern”

OOP Fundamentals: Quick and Dirty Guide to Testing

There are entire books written on testing. And it surely feels more an art than a science. My approach is similar to Kent Beck’s:

I get paid for code that works, not for tests, so my philosophy is to test as little as possible to reach a given level of confidence (I suspect this level of confidence is high compared to industry standards, but that could just be hubris). If I don’t typically make a kind of mistake (like setting the wrong variables in a constructor), I don’t test for it. I do tend to make sense of test errors, so I’m extra careful when I have logic with complicated conditionals. When coding on a team, I modify my strategy to carefully test code that we, collectively, tend to get wrong.

https://stackoverflow.com/a/153565/1015566

He goes on to add that different people will have different strategies and, at the end of the day, you just have to do what works best for you and your team. Extremely practical, and the approach I personally follow.

This won’t be a detailed post on every possible topic on tests and testing in Object-oriented Programming (OOP). There are many books about that already. Instead, this article will cover the basics of testing, so you understand how and why we test, and you can adapt it to your own needs.

Continue reading “OOP Fundamentals: Quick and Dirty Guide to Testing”

OOP Fundamentals: The Decorator Pattern

The decorator pattern is one of my favorite patterns. It is simple, extensible and powerful. It feels like it follows the essence of object oriented programming beautifully. Sadly though, it is also easy to be misused or misunderstood. So, in this post I will show you the essence of the decorator pattern, illustrated with a few examples.

Continue reading “OOP Fundamentals: The Decorator Pattern”

OOP Fundamentals: The Dependency Inversion Principle

The dependency inversion principle is one of the cornerstones of object-oriented programming. Without it, there is no object-oriented design. It’s that important.

Continue reading “OOP Fundamentals: The Dependency Inversion Principle”

Composition over Inheritance, with JavaScript examples

If you are into object-oriented programming, you most likely have heard about composition over inheritance. The concept itself is simple: Whenever possible, prefer to compose objects rather than introducing inheritance.

Continue reading “Composition over Inheritance, with JavaScript examples”

Common Code Smells in OOP

Over years of reviewing Ruby code, the same things tend to come up over and over. In this post, I’d like to address some of the most common code smells I find when reviewing OOP code (and Ruby code in particular).

Continue reading “Common Code Smells in OOP”