123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|704|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Off Topic -> Discuss :How to code Properly

Fri, 15 Jun 2007, 16:09
Jayenkai
I've been meaning to post this for a couple of days, but haven't gotten round to it.
Tonight, though, I'm bored out of my brain, and really can't be bothered coding, so figured I might as well take the time to post it.

What caused me to post this topic is what happened here.

DiablosDevil You should NOT capitalize a non-constant.

Jayenkai I prefer to symbolise which is which using a more specific manner, like placing "C_" before the variable name.

Hotshot it is very old code!



What happened there, is this.
1) Someone posted something.
2) The first ever comment that user has received on this forum was "No, you should code like this"
3) The second comment was yet another method to code.
4) The original poster makes up an excuse as to why it looks a bit tacky.

At first I thought nothing of it, but then throughout the day it started nagging away at me. I have somewhat of a terribly guilty conscience..

I've coded for years, but only got online when I was 19. I found the internet a daunting place, but I managed to survive. I made little Sielts and built up a Pulp site.
When I finally found Blitz, and dumped DarkBasic which kept resizing my desktop and moving all my icons, I joined up at BB.com.
I got told off for my style of coding.. So I gave up and headed to BC instead.


When I was building up this site, I popped on over to a php site and asked a question regarding the BBCode's "Code" boxes (which you'll probably remember took AGES to get right!)
The code I showed wasn't real code, it was pseudo code, suggesting the method I was using/hoping for, and asking how I could achieve it.
The only reply..
"If this is your code, I am sure it doesn't work!"



I'm worried that we might be getting like that, so I'd like to bring the whole issue to everyone's attention, and have everyone discuss it openly.

-=-=-
''Load, Next List!''
Fri, 15 Jun 2007, 16:31
spinal
Reminds me of when I was trying to get the DS Rumble Pak to work....

I posted the following...

I'm using it as

always false


Then I got the reply...


This is not going to get you anywhere...

you need some function in the 'if' and 'else' so if there is one inserted...




-=-=-
Check out my excellent homepage!
Fri, 15 Jun 2007, 16:55
HoboBen
Sorry (lost!), what are we discussing? How to code or how not to argue about how to code?

-=-=-
blog | work | code | more code
Fri, 15 Jun 2007, 18:12
caffeinekid
Jay, that's not how you tell people how to not tell people how to do something.

My philosophy is thus:-

If code works and does what you want then it's right, if it doesn't do what you want it to then it's wrong - anything else is just fluff.

-=-=-
www.tcksoft.co.uk
www.retroremakes.com
Fri, 15 Jun 2007, 18:25
Jayenkai
I PM'd Diablo the other day to ask if it was OK to post this, worried that he might think I'm getting a dig in..
It's not a dig at Diablo, and I hope he understands that, it's just that... Sometimes we have to take a step back and realise that we were all there once.

And like you said, if code works, then that's good enough, right!

-=-=-
''Load, Next List!''
Fri, 15 Jun 2007, 18:41
caffeinekid
Now indenting... That's another thing entirely.

-=-=-
www.tcksoft.co.uk
www.retroremakes.com
Fri, 15 Jun 2007, 20:10
magicman
Im with caffeinekid, If the code works who cares how crummy it looks!

-=-=-
Stuff... Yeah...
Sat, 16 Jun 2007, 02:28
power mousey
I don't sweat it.
I code and learn and relearn how to code
and with some good indentation and basic rules.
I learn as I go...so I and maybe others can read or use it.
You never know...2 weeks from now you may not
know what you did or have trouble retracing your
steps. And this is important,. Like, in a programming job of some kind. Comments, docummentation and boiler plates too.
Sat, 16 Jun 2007, 07:44
JL235
I'm not trying to have a go at anyone's code. In the same way people may suggest improvements in the performance, functionality or structure of a persons code, I'm just suggesting improvements in people's style of coding. Improvements which in the long run can help.

I don't mean anything bad or negative about people's code, but if I see room for improvement I'll suggest it. I agree though that just putting down people's code is wrong.

There is nothing wrong with pseudo code, and I think we should discuss more solutions to coding problems more in writing rather then code. But you should also never be sloppy when writing actual code, even if it's only small and is never going to be used.
Sat, 16 Jun 2007, 08:35
caffeinekid
BTW I was serious about the indenting. I don't know how I coped on the Spectrum with line-numbers and no formatting anymore.

If code isn't indented to show the structure then I literally cannot read it. I have trouble reading my own code at the best of times so I have to make it as easy on the eyes as possible, usually anyway.

-=-=-
www.tcksoft.co.uk
www.retroremakes.com
Sat, 16 Jun 2007, 09:18
power mousey

awwwwww caffeinekid, I agree with you.
That is true.

and DiablosDevil, its cool too.
Yet, I would like some people...whether friends
and others...to get on my case for coding.
In other words, I like feedback and criticism
whether negative, positive, constructive, and
otherwise.
tell me and show me how to make the code and also the program better or even how you would do it.
Believe me, I can take it.
I just don't sweat it.


cheers
power mousey
Sat, 16 Jun 2007, 19:52
Scherererer
I think that its important to have some standards for style, and that we should do our best to make our code look, if nothing else, clean and readable. I'm not saying we should all have code where constants are all caps and functions start with such and such a case; I just mean that we should have variable and function names that make sense, and indentation and spacing that is practical and readable.

I'm not going to call anyone on coding style, and I don't think that's what Diablo was aiming for, but I think we should all try to have good style. I used to just kinda code as long as it worked, but as I grew as a coder I improved my style and cleanliness and I really did notice a difference. Not only does it reduce the difficulty of reading for others, but it does for yourself too. I remember opening up some of my earlier games and going "wtf was i thinking, i don't know what's going on here".

Good luck and good coding to all!

-=-=-
YouTube Twitter
Computer Science Series: Logic (pt1) (part 2) (part 3) 2's Complement Mathematics: Basic Differential Calculus
Sun, 17 Jun 2007, 07:30
Teasy
*LoL*!
For me it was the other way around.
I used to find style more important than getting it working.
Now I'm trying to get it working no matter what style
For example using a quick and dirty style on small projects and a little more elaborate style on larger projects, but only if it's absolutely necessary.
It sure as heck increases my productivity!