Jeffrey Bakker
2 min readJan 14, 2021

--

This is not completely true. In C++ (which you’re specifically calling out in the article), primitives and objects are passed by-value, from which a copy is created. If you want to pass by-reference you have to explicitly use the ‘&’ syntax in the function signature to do so. Arrays and pointers are technically passed in to have a similar effect as “by-reference”, but that is to be expected. You can still dereference a pointer at the call site if you want to pass a pointer variable by value instead.

As for mutation, C++ has a concept of “const correctness”, which is also viral to the call chain according to the compiler. This, you can use to help ensure determinism down the call stack. You might be thinking “so many rules to follow, some of which are not enforced by the language”, and you’d be mostly right.

I agree that probably most OOP developers can’t avoid creating spaghetti or non-determinism to save their lives – not without best practices. I have witnessed best practices completely stamp out spaghetti and non-determinism, but you need a combination of several of them. Such best practices are not taught by standard, and even when given the opportunity to be taught, there is resistance to learn. Experienced developers have to re-wire their habits formed over the years, and for Junior developers, they would have a hard time wrapping their heads around advanced concepts without mentorship.

I also acknowledge that OOP is an enabler of some of the most egregious anti-patterns and code smells, like the God Class, Singleton Class and Feature Envy, to name a small few. And then there’s little training on how to avoid these all-too-common mistakes.

There are valid, agreeable points in your article, but it is presented as a bit extreme or absolute, and also is missing some facts. This creates an “us versus them” divide…something to consider if you want to convert level-headed OOP developers into the FP way of thinking.

--

--

Jeffrey Bakker
Jeffrey Bakker

Written by Jeffrey Bakker

Professional geek. Wannabe cyclist.

Responses (1)