Author Topic: How not to write C++  (Read 1410 times)

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-1
    • View Profile
    • Email
How not to write C++
« on: July 22, 2018, 08:31:22 AM »
There is this older, I guess abandoned roguelike called Avanor. I was reading the source code and thought to remind people about how NOT to write C++ where Avanor is a great example. It's "easy" I guess to criticize an older project, but it's not that people wont make this mistake over again, they do it all the time.

The main problem with Avanor's code is that it's not C++, it's C wrapped in classes in a bad way. It's using none of OOP principles and in particular there are no traces of datatype classes, instead (almost) everything is plain old variables stuffed into large-ish classes. The code itself is old school large if/switch structures (typical in C code). I think Avanor points out perfectly the inability of a programmer to understand OOP (or any specific paradigm). If you just use classes to fill in with procedural code it's not OOP at all. Classes are only used as simple data containers, a lot like structs.

I think we need to make people somehow more aware of this issue, because it has a big impact on source code quality which can make the project fail after it becomes too difficult to maintain.