View Full Version : [php, javascript, and actionscript] Programming methods/styles, what's yours?
FuRom
09-23-2007, 11:35 PM
With everyone learning programming in many different ways, no one has a uniformed script with everyone else in the programming community. This topic is targeted to those that program in PHP, Javascript, and actionscript because those three languages are so similar. Personally, I program in every lanuage in a style that I like to call "dirty script". It's generally not organized like other people's coding making it a bit hard for others to read because they aren't used to it.
In php I'll use minimal variables, I try to make everything as ready for any possible future updates as possible. I query SQL a lot and I don't put unnecessary data in the database. While doing this, I forget to format my code with white spacing so it'll be readable.
In actionscript, I think my coding is pretty standard. It's just the same old, same old, because actionscript is pretty uniform no matter what. I do however stay away from using the eval() function and such useless stuff.
virtubots
09-23-2007, 11:57 PM
I'm the same way with HTML and PHP, where I write it in a way that I read it best, I don't do the proper indentations that others seem to prefer more.
- Mike.
Tigress
09-24-2007, 12:22 AM
I use a very clean and easy-to-read method of coding, with indentation and brackets getting their own lines and so on. Even my SQL queries are placed on multiple lines to make them more readable. I have a habit of GPLing little bits of code for others to use, and in any case I cannot guarantee that I will be the only person who ever works on a particular script, so it's best to make it as easy to edit as possible. I don't use comments too often, but I place them in areas to explain the otherwise potentially obscure workings of a function.
Generally my syntax and so on are second-nature and I don't really think about what I'm doing (the IDE I use automatically handles indenting, actually), but I can get irritated very quickly if I have to work on the code of someone who doesn't indent properly, doesn't make new lines where necessary, etc...
I also use objects/classes a lot, and outside of classes have lots of miscellaneous functions to handle various tasks for me so that I don't have to repeat the same bit of code a million times (and also to make that bit of code easily editable, sitewide). Looking at my main function library, I have approximately 1500 lines of functions.
FuRom
09-24-2007, 12:31 AM
I make my work very clean when I do expect others to use it. I edit with wordpad, so no auto indentions.... I get irritated a lot of the time when I'm editing or adding onto other people's work. No one ever thinks of people adding things in the future.
dc277
09-24-2007, 05:58 AM
Sometimes for PHP I'll add little comments so I know where { goes with }, so it's easier to work with.
jlp09550
09-24-2007, 07:21 PM
PHP and Javascript. :]
I was about to post one like this but I saw this one.
Chevy
09-24-2007, 07:25 PM
I make my work to my taste in "cleanliness" also. Some people say my coding is messy, others say it is clean, I think it is perfect xD
The brackets on their own line is really annoying to me x.X
Patrick
09-24-2007, 09:58 PM
I've developed my own indentation system that I can read best. Anything bracketed like a condition, loop, etc all gets indented by one tab. They keep getting indented by another tab so long as I need to. I don't put beginning brackets on their own line however. So my style is somewhat like this.
if ($condition == true) {
echo "This is true";
while ($whatever == $something) {
// do something
}
}
Let it be known that I despise coding that isn't indented.
jlp09550
09-24-2007, 10:10 PM
I make my work to my taste in "cleanliness" also. Some people say my coding is messy, others say it is clean, I think it is perfect xD
The brackets on their own line is really annoying to me x.X
Heh, one thing I'm not good at-- organizing PHP scripts, AKA "clean scripts".
Tigress
09-24-2007, 10:15 PM
I've developed my own indentation system that I can read best. Anything bracketed like a condition, loop, etc all gets indented by one tab. They keep getting indented by another tab so long as I need to. I don't put beginning brackets on their own line however. So my style is somewhat like this.
if ($condition == true) {
echo "This is true";
while ($whatever == $something) {
// do something
}
}
Let it be known that I despise coding that isn't indented.
Although I also dislike code that isn't indented... how is that "developing your own indentation system"? That's standard indentation...
Patrick
09-24-2007, 10:17 PM
I don't know what the "standard" way to format your code is. All I know is I started coding like this:
if ($one == $two)
{
if ($three == $four) {
while ($yes==$no) {
}}}
And progressed over time into what I use today. If its the standard, then good for me. But I did develop it on my own.
Also, I was under the impression that this was standard:
if ($something == $somethingelse)
{
return true;
}
else
{
return false;
}
FuRom
09-24-2007, 11:00 PM
Lol, my scripting is like this these days:
require_once('classfilename.php');
$var = new classNAME;
$var->action1();
$var->action2();
$var->action3();
$var->parse_final_result();
and behind that is a huge class that is semi-clean:
global function action1(){
echo 'We\'re taking our first action!';
for($i=0;$i<4;$i++){
$varname[$i] = $i.'blah';
}
}
there is generally minimal to no indentation as far as anyone can tell. This is a big reason no one likes reading my scripts no more. When I start something fresh, I always make a class and run through the class' functions. Hence; I call it dirty script because people have issues with reading through classes for some reason.
There are many times that I just feel like coding straight forward or I'm forced to because of the job already having pre-existing scripts. The coding turns out standard indenting, because I expect people to actually read the code.
juddster
10-07-2007, 10:54 PM
I've developed my own indentation system that I can read best. Anything bracketed like a condition, loop, etc all gets indented by one tab. They keep getting indented by another tab so long as I need to. I don't put beginning brackets on their own line however. So my style is somewhat like this.
if ($condition == true) {
echo "This is true";
while ($whatever == $something) {
// do something
}
}
Let it be known that I despise coding that isn't indented.
Although I also dislike code that isn't indented... how is that "developing your own indentation system"? That's standard indentation...
Sorry for the messed up quoting...I kinda screwed up at the beginning...
I have to agree with Tigress on that one...I have been indenting like that for the past 8 or so years now...it really isn't any one person's way of indenting:P...sorry to burst your bubble
~juddster
Laska
10-15-2007, 09:04 AM
I code in notepad++
Functions and Classes = <3
Comment code when working with others.
Sensible short variables names.
I used to use horrible variable names such as $stop_hammer_time or $monster_mash which had no actual relation to the script, but just what I was thinking of at the time.
online.education
10-21-2007, 11:25 AM
If I'm just modifying an existing script, first, I try to follow its style. If it's using Hungarian notation, then that's what I try to use ... first.
Generally speaking, I prefer spelling out all variables using English language. To me, this is the style that I can read the code most comfortably.
vBulletin® v3.7.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.