Your bad coding habits
#1

Okay, so I've decided to create this topic due to a release I've made yesterday, which was out-of-shape and didn't work correctly.

Now I want to know what YOUR bad coding habits are.

I tend to skim through my codes very quickly without double checking or using smarter methods that are available. I also tend to do things in PAWN that can easily be done with another library (for example, boolean arrays and y_bits). I'm planning on improving these habits by the end of this year so I can script throughout my project more efficiently.

So what are yours?
Reply
#2

Well, mine may not seem like such a bad habit, however it is very time consuming. I literally check my code a million times (before compiling it) and put my mind in the computer and talk to myself about what it should do - then rage when it doesn't do it.
Reply
#3

well, one of my bad habits that I know is creating a string of 128 characters for any small part of the code. One user warned my about creating a string for character name with a size of 24, and since than, I try to think which size to pick
Reply
#4

Another one of my code habits is a form of "OCD" - I basically try for minutes on end to make my code look good before I can continue developing it. It's very dumb, but I'm sure more people than me have this habit too.

@nmader: I've done that a lot of times back when I was first starting out also! It's something that everyone does in their programming period at first, but then over time people compile and run scripts without analyzing it.

@Ivan25: I always think ahead of how many cells that I could possibly fit into a string when I needed it. In most cases, it's "64" or "128". I used to use "192" and "256" all of the time!

@Dragonsaurus: Good job for improving! I agree, I used to do that A LOT too. We all did it!

@Y_Less: 2) and 3) are my major bad habits for coding also. As people progressively get better in coding, the "NIH" syndrome kicks in! It's something that all advanced scripters do and it's completely normal (I get the raging part, it's constructive criticism and even I criticize people's scripts sometimes).

@ViruZz: I always test all of my code, but there's some times where I would only test 2/4 portions of a script and then release it. I just use my common sense to tell me if it would work or not!

@2KY: Me too! Sometimes, I would start up a project, and 2 days later I would delete it, start over or just plain simply abandon it.

@Hansrutger: Me too. I used to do that A LOT, but now I do it like this:

pawn Code:
if (Statement())
    return blah;
Or this:

pawn Code:
if (Statement()) {
    return blah;
}
Either way doesn't matter. It just looks much more cleaner, IMO.
Reply
#5

Quote:
Originally Posted by Emmet_
View Post
pawn Code:
if (Statement()) {
    return blah;
}
Used to have that habit from java but then I came here and for some reason had to learn to use
pawn Code:
if (Statement())
{
    return blah;
}
and now I'm using that in every language I'm programming in.
Reply
#6

I can't continue coding if there is even a small problem or a thing that I can't do, until I get how to do it and how it works. So there was a whole week that I spent to solve a really simple problem - I had to increase the size of one placeholder.

And I use to ask there (in the forums) the later I can.
Reply
#7

Quote:
Originally Posted by Emmet_
View Post
@Y_Less: 2) and 3) are my major bad habits for coding also. As people progressively get better in coding, the "NIH" syndrome kicks in! It's something that all advanced scripters do and it's completely normal (I get the raging part, it's constructive criticism and even I criticize people's scripts sometimes).
Agreed, as I say I'm trying to break the habbit now. Unfortunately, it does require that other people's can be up to scratch as well, which is frequently not the case in SA:MP at least - but there is some better quality stuff out there now (mainly if you dig about on Github).


Quote:
Originally Posted by Hansrutger
View Post
Used to have that habit from java but then I came here and for some reason had to learn to use
pawn Code:
if (Statement())
{
    return blah;
}
and now I'm using that in every language I'm programming in.
Not sure what you mean by "for some reason" - most languages have their own conventions. Java's is quite universal in that almost everyone does it the same way, I find other languages tend to be less consistent globally (but I'm with you - I never code Java using the first style brace).
Reply
#8

Because when I started coding in pawn, very long time ago when I only learned the basics, I saw all the functions that comes up in new script so I thought that you always had to do with that style and it has become a habit now that I always do the second style. That is what I meant with for some reason, that is, I guess, my reason for doing it now in both school and at home for fun.
Reply
#9

Quote:
Originally Posted by Emmet_
View Post
Another one of my code habits is a form of "OCD" - I basically try for minutes on end to make my code look good before I can continue developing it. It's very dumb, but I'm sure more people than me have this habit too.
Yeah. Excessively tabbing to line up comments behind statements. Sometimes even arranging sets of coordinates so the decimal points line up. Still, it's easier on the eyes when reading that same code again later.
Reply
#10

Not using chars where they would be apropiate.
Using strcmp for commands.
Using just roughly optimized array sizes.

All due to being lazy, as I always plan to optimize that stuff when the rest is working. However, I abandoned all projects I started in a while, so there werent any scripts making it far enough for optimisation in the last 1 or 2 years.
Reply
#11

Whenever I am scripting, I barely even look what I scripted before and wait for the errors to come rather fixing it at the spot. Don't know it's weird and it'd take me so long :3.

And some other users mentioned I as well put the string array to higher number unnecessarily.
Reply
#12

Quote:
Originally Posted by Vince
View Post
Yeah. Excessively tabbing to line up comments behind statements. Sometimes even arranging sets of coordinates so the decimal points line up. Still, it's easier on the eyes when reading that same code again later.
Something I use all the time for that. In Notepad++ and some other editors you can alt+shift+click to type on multiple lines at once. I can't really demo it, but click on one column on one line, then alt+shift+click on the same column on a different line and the cursor will extend between the lines and typing something will duplicate it on every line. You can also select vertical blocks in the same way just by not clicking on the same column on the second line.
Reply
#13

I like to think I don't have many bad coding habits anymore (I'm one of like only 20 people who actually know how to use the keywords). I was recently given the opportunity to look at code written for professional software and speak with the programmers. Since then I've taken many strives to better myself in every category from optimization to documentation. Sure, there are definitely things I would love to learn regarding PAWN, but I also respect its native limits so "stay within its bounds" so to speak.

As far as the development process, I never seem to finish a project for SA:MP. I always get distracted by trying to create other applications I would find more useful than a SA:MP server. Never having people to test your systems that require more than one player (and NPCs won't do) is an ego killer as well.
Reply
#14

Quote:
Originally Posted by Y_Less
View Post
Something I use all the time for that. In Notepad++ and some other editors you can alt+shift+click to type on multiple lines at once. I can't really demo it, but click on one column on one line, then alt+shift+click on the same column on a different line and the cursor will extend between the lines and typing something will duplicate it on every line. You can also select vertical blocks in the same way just by not clicking on the same column on the second line.
Well, I just learned something new with Notepad++.
Reply
#15

i would just quit when i get a error which i can't fix or the fking copyrights.
Reply
#16

Quote:
Originally Posted by Y_Less
View Post
Something I use all the time for that. In Notepad++ and some other editors you can alt+shift+click to type on multiple lines at once. I can't really demo it, but click on one column on one line, then alt+shift+click on the same column on a different line and the cursor will extend between the lines and typing something will duplicate it on every line. You can also select vertical blocks in the same way just by not clicking on the same column on the second line.
Oh, nice! I knew you could select vertically in Notepad++ by holding ALT and dragging the mouse, but I never knew you could type the same stuff on different lines. Many, many thanks! This is going to be so useful!
Reply
#17

Mine was being too stubern to try something new(zcmd and sscanf)
Making sloppy codes which ends up in errors that I had to sit with for hours because the one thing that was wrong was ''correct'' since I always did like that! untill I checked and saw I wrote something compleatly differant than what I should have..
But beginning to be better at that now
Reply
#18

I tend to skip commenting the code, but I'm improving on that.
Reply
#19

Boilerplate code and NIH syndrome, which have led to a quite hard-to-maintain code after 4 years of development on the same gamemode.
Reply
#20

Well I most-likely stop developing a gamemode after a month and then start again after a month again.
I got the same with mappings. But I'm now into a project which I'm really motivated for, so let's see how long I'll continue.

And when I create a code I most-likely use a way around it which is 100 times more difficult than is needed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)