Reputation: 21206
I am in a new team. I am shocked by their coding guidelines.
Example:
strName
iCount
structRectangle
listCustomers
retVal (for the return value... that is really biting me... how someone can do this)
They demand to write the datatype before the variable with the argument that this way the developer knows everytime what datatype the variable is without scrolling up to the declaration.
Well that is true, but my argument would be then a method should not be longer than 30 lines (else put code in another method) which fits into a common 24" screen...
But I am not totally convinced because there are things like Action<T>, Dynamic, Func<T>
in .NET. which force me too to go the same way and do "actionCustomers" for a delegate holding a method gettings a list of customers.
What advice can you give me as an alternative to e.g. "actionCustomers" which should render the argument of the team useless?
Upvotes: 1
Views: 118
Reputation: 395045
I would suggest that you adopt the coding style of the team you are coding with. They have adopted their style to deal with their own systemic problems. Unless you are in a position to judge their code (which it seems you are not) or you can appeal to a higher authority on code style (seems unlikely from your post) then, if you want to keep your job and demonstrate that you're a team player, you need to conform to the rules you've been given.
Why is datatype in variables bad coding style?
It's not. A relatively ancient form of it called Systems Hungarian Notation that actually encoded the type has received a lot of criticism for a lot of reasons, including redundancy, inconsistency, and poor readability. But that's not what you're dealing with. I sometimes find it helpful to include datatypes in my object names when I haven't fully decided on which container I'm going to use (list, no, set, no, dict... and usually in that order.)
Upvotes: 4
Reputation: 13652
Encoding the type of a function into the name (so-called Hungarian notation) is brain damaged—the compiler knows the types anyway and can check those, and it only confuses the programmer.
Linus Thorvalds, Linux Kernel Coding Styles
I really love that quote.
Upvotes: 1
Reputation: 160
This coding style is very useful when you are not using an IDE.
I often open old code files with Notepad++ (just to read it and convert to newer code, no need to open huge project to read one single file) and without this coding style, every time I see a variable, I have to search for its name inside the document just to find out its type. And that hurt my time schedule A LOT.
Long story short: you may not like the old school methods but they existed because people needed them. You will never know if one day you wish for it.
Upvotes: 1