On not-so-smart coding standards

github logo ・1 min read

Sometimes bad naming conventions are biting us. Long before I joined the project someone decided that every class should have a 'C' prefix to its name. So, instead of Window we have CWindow etc. And all those reside in files named without the initial 'C'. This rule has a very nice side effect.

Can you guess what class is in the file called Logger.cpp? :)

twitter logo DISCUSS (3)
markdown guide

A certain large organisation in Seattle may have something to do with your pain: docs.microsoft.com/en-us/windows/d...

Personally I prefer to prefix my symbols with their intended scope, not their type, as type-checking is a tooling/language task, not mine, whereas poor structure is definitely my problem :)

Oddly 'Hungarian' notation (as above) includes one scope-prefix 'm_' for member variables of a complex type, but nothing else, the rest is all type indication. Strange.


Yeah, certainly that organisation has a lot to do with a lot of things. :) But someone has to decide to use that particular style in that project. And nobody really can tell me why. I've heard a very nice therm for that: Cargo Cult Programming.

As for scope prefixes, I'm big fan of Uncle Bob's clean code, and usually, I try to write classes and methods so small, you don't need any prefixes to visually separate things. :)

Classic DEV Post from May 22 '19

Coding Best Practices, Chapter One: Functions.

Code best practices, how to write readable functions.

Alexey Voinov profile image
Seasoned programmer still curious about it.

👋 Hey dev.to reader.

Do you prefer sans serif over serif?

You can change your font preferences in the "misc" section of your settings. ❤️