🔒 Locked
Picky coders?
Advertisement
Original Post
I'm beginning to think I'm way too picky about how my code looks rather than what it does. How many of you guys are really picky with naming/commenting conventions and consistent layout? It seems like I'm spending more time keeping all of my files laid out in a consistent manner all with same naming/commenting conventions. And there have been a couple times where I like some other naming convention better to the point where I will take the time to change the names of the variables in every file. Since I'm just a hobbyist for the most part, this isn't really a big waste of time. Just wondering if I'm alone...
Naming conventions are a very useful aid to writing good code, but it's important to remember that they are just that, an aid. Refactoring old code just to match a style guide (i.e. The One True Brace style or CamelCase vs variables_with_lots_of_underscores) is a time vacuum. Sure if you're going back over some code for a legitimate reason (i.e. fixing a bug) it can be useful to tidy up the code, but making sure every if statement has a space between the if and the parentheses won't help.
That said, I've done this myself in the past. Sometimes you inherit a code-base that's so awful it actually saves time to go over it and make it more readable. So no, you're not alone.
Most programmers I've met (self included) are a little ocd by nature, so untidy code is irritating to them.
That said, I've done this myself in the past. Sometimes you inherit a code-base that's so awful it actually saves time to go over it and make it more readable. So no, you're not alone.
Most programmers I've met (self included) are a little ocd by nature, so untidy code is irritating to them.
You are not alone c_olin!
I think it's crucial to have tidy code. I'm very fussy, e.g I'll always put a space before an open bracket, and after a comma...but never within square brackets! My open curly bracket will always be on the same line, not the next...if I split a long line of code, the final close bracket will be exactly under the start.
It's great being a hobbyist, you can stick around the rules yet always have your exact style.
As for my house, it's quite messy lol...I am my work!
edit: now that I think about it, I've even employed sub-rules to my bracket obsession...with vectors i'll write "= vector(.x, .y, .z);" <-no initial space here, and with for I'll write "for (i=0; i something && this != that) {", but a call would be "Call ();"...the capital 'C' tells my peripheral vision it's not a variable!
I think it's crucial to have tidy code. I'm very fussy, e.g I'll always put a space before an open bracket, and after a comma...but never within square brackets! My open curly bracket will always be on the same line, not the next...if I split a long line of code, the final close bracket will be exactly under the start.
It's great being a hobbyist, you can stick around the rules yet always have your exact style.
As for my house, it's quite messy lol...I am my work!
edit: now that I think about it, I've even employed sub-rules to my bracket obsession...with vectors i'll write "= vector(.x, .y, .z);" <-no initial space here, and with for I'll write "for (i=0; i
I'm picky with naming and layout as well. For the former I'll sometimes rename classes and variables several times before settling on something I like--this is where refactoring tools are essential so that you don't have to manually edit the code.
The naming is a understandability thing for me. I've seen code that uses many names to describe one concept, and when it's foreign code all those extra names make it more difficult to learn the code and understand it.
The naming is a understandability thing for me. I've seen code that uses many names to describe one concept, and when it's foreign code all those extra names make it more difficult to learn the code and understand it.
Quote:
Original post by mutex
I'm picky with naming and layout as well. For the former I'll sometimes rename classes and variables several times before settling on something I like--this is where refactoring tools are essential so that you don't have to manually edit the code.
Speaking of refactoring tools, I know that Visual studio's IDE for C# makes refactoring easy. Does anyone know if Visual C++ has any hidden refactoring tools that I am not seeing, or are they exclusive to C#?
Im pretty much a beginner and Im already bothered by some of the ways brackets are used in coding I don't like it when they are placed right after a parenthesis, I like to give them their own separate line.
I'm picking with naming and layout, but I fail to understand how this causes you a significant problem - for me it just means I name and layout my code properly whenever I first write it or if at any stage I go back to refactor.
If I for some reason change my style it only gets applied to old code if I'm refactoring, no need to mess with the stuff that's already working.
If I for some reason change my style it only gets applied to old code if I'm refactoring, no need to mess with the stuff that's already working.
Quote:Are you not using an IDE with find/replace tools that make this reasonably trivial?
And there have been a couple times where I like some other naming convention better to the point where I will take the time to change the names of the variables in every file.
I like my code to be indented properly (apparently I use the Allman style, although I was thinking of switching to K&R cos it 1337er) but not so bothered about variable names. Usually end up being called "test" or "a".
Aye, they are important, just as much as the code does. Naming convention is very useful when you are working in a team. I used to tidy up my code a lot as I type. Now, I let my IDE do it. If you code in Java, IntelliJ does a great job in both refactoring and formatting your code.
I deal with a lot of legacy code at work (we're talking PS1 and older), so I tend to leave things as they are. Any new code I add tends to follow whatever naming convention was being used before I came along. I find it easier to read, even if the project as a whole doesn't use one convention. If I'm writing brand new code then I'll follow the naming conventions that the majority of my team follows.
In my personal projects I tend to write code following my own custom conventions. I keep it consistent but it's nothing crazy.
As for comments, I'll only use conventions if there's a reason (i.e. if I'm using doxygen to generate documentation based on source code).
Changing existing code only for conventions is pointless and you'll never get your real work done if you waste your time on that. Following conventions with new code is a good idea, but that really shouldn't take any longer than not following conventions.
In my personal projects I tend to write code following my own custom conventions. I keep it consistent but it's nothing crazy.
As for comments, I'll only use conventions if there's a reason (i.e. if I'm using doxygen to generate documentation based on source code).
Changing existing code only for conventions is pointless and you'll never get your real work done if you waste your time on that. Following conventions with new code is a good idea, but that really shouldn't take any longer than not following conventions.
I'm a little goofy about my log files. If I check my log file and see that I missed a newline or a space somewhere, I'll go back to the code, fix it, then compile and run it again just to see the change in the log file.
Oh and I may be alone here, but bracket obsession drives me crazy. Who cares where the bracket is?
I personally prefer it to be on the line after the function call (or whatever) as it's so much easier to visualize the open and close brackets since they line up in a column. I don't mind if people want to do it another way, but if I ever see someone wasting time to convert existing brackets to their preferred style, I'd probably lose my mind.
I personally prefer it to be on the line after the function call (or whatever) as it's so much easier to visualize the open and close brackets since they line up in a column. I don't mind if people want to do it another way, but if I ever see someone wasting time to convert existing brackets to their preferred style, I'd probably lose my mind.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement