best coding techniques

Started on the old forum in December 2010 · view the original in the archive · old links redirect here

7 replies · 602 views · started 15 years ago · 1 min read

4 participants
frostymarvelous Senior · 266 posts #1

Ok. I know these are skills you gain with experience because I can see my code is more organised and cleaner than it was a year ago when I started. I however see better code everyday and wish to get better. Is there some kind of document with guidelines? For those of us who are self taught, I think this would be a great asset. There is only so much you can learn from reading code. Thanks.

Perfection comes at a cost

I accept liberty!

metulj Super moderator Principal · 1,726 posts #3

frostymarvelous wrote: Ok. I know these are skills you gain with experience because I can see my code is more organised and cleaner than it was a year ago when I started. I however see better code everyday and wish to get better. Is there some kind of document with guidelines? For those of us who are self taught, I think this would be a great asset. There is only so much you can learn from reading code. Thanks.

check link in my signature... you might find some usefull ebook...

It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt. ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ ! ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.

キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

frostymarvelous Senior · 266 posts #4

Thanks. Lemme check.

Khan. I know. What I need is a title or something. There's a lot of junk out there.

Perfection comes at a cost

I accept liberty!

CreativityKills Lead · 833 posts #5

To write cleaner codes i use tabs for indentation not spaces. I do if( ! $arg === TRUE) { {TAB HERE}echo $arg; }

makes it easy to find missing closing braces. I use caps for php constants like: AND, NULL, FALSE, TRUE, OR etc. I also make sure that i do stuff like:

function ego($ego) { {tab here}return isset($ego); }

not

function ego($ego) { {tab here}return isset($ego) ? true : false; }

frostymarvelous Senior · 266 posts #6

That's not what I actually mean. Though that's seriously advisable as well as commenting.

To get an idea of what I mean, take a look at yourls, sphider or php search. There's this level of organisation I can't seem to muster. Yourls is cool, I code like that now but the others including CF image hosting codefuture.co.uk/projects/imagehost/ is just extreme.

Perfection comes at a cost

I accept liberty!

frostymarvelous Senior · 266 posts #8

CreativityKills wrote: ?? I still dont get you

Take a Look at any of the scripts I posted above. When you look at them, look at the organisation. The folder structure. The way they use functions. Generally, the way they create includes. I'm sure its some kind of fallback from c++ or more advanced coding language experience. The thing is, php just does not encourage good programming skills. Its like html. Almost anything will parse.

Perfection comes at a cost

I accept liberty!

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close