Page 1 of 2

preparation ?

Posted: Tue Dec 16, 2003 6:03 pm
by thomasd1
hi,
i started with php a month ago
i would like to know what you "pro's" do when you start writing a script. (eg: a small forum or something) do you make preparations 'n' stuff?
i'm a new to the game so if you want, please give me some good practical tips for writing php, i would apprieciate that.

thanks :wink:

Posted: Tue Dec 16, 2003 6:13 pm
by DuFF
Outlines are very important. Before starting the coding you want to be sure of what you are trying to accomplish and exactly how you are going to achieve it. This can vary between deciding which files do what to actually writting down psuedo-code for all the functions you plan to use.

It is much easier to be able to get almost everything right the first time then it is to realize an error in logic or layout and have to scrap a lot of work already done.

Try to get all of your ideas down on paper first and then over time add or get rid of things you want/don't want. If you are using OOP then you would want to plan what classes do what, think of some functions you may want to use, etc, etc . . .

Trust me, haveing to recode more than half your site is not fun :?

Posted: Tue Dec 16, 2003 7:11 pm
by Paddy
I always write requirement documents before doing any web work. Not only is it a good outline to follow when you are coding but it is also important if you are doing a project for a client. Getting a client to sign off what you are going to produce will mean that when the client wants changes done you have an option to charge them. Clients always change their mind. Argh!

Posted: Tue Dec 16, 2003 8:34 pm
by dull1554
i on the other hand go head first into programing, i find that if i have a idea i forget it by the time i get a pen and piece of paper, i got straight to my pc and code it, the only time i plan is when im writing a script for someone else, when i know exactly what im doing, and how im gonna do it, when i code for myself i genneraly code small snippets and piece them together later in the game, this is my approach (a bad one but my approach never the less). good luck with you php endevor..........

Posted: Tue Dec 16, 2003 8:39 pm
by microthick
I think after a while you develop the ability to "code in mind", meaning that you figure out the program flow in your head and piece by piece can break it down, also in your head.

I still use a pen and some paper for more complicated system flow charts.

If anything, the most important thing to settle before you code a line is your database schema. Make sure you have illustrated all your tables, all your table attributes and the relationships between the tables.

Posted: Tue Dec 16, 2003 8:44 pm
by dull1554
thats a good idea microthick

Posted: Wed Dec 17, 2003 2:30 am
by twigletmac
The best thing you can do is to spend some time thinking about what you are trying to accomplish and to have a good idea of your general direction before you start coding. Once you've got the code working don't stop there, go back to it and see where you can make it more efficient and clean it up a bit (much easier once you've just written it than 3 months later).

Mac

Posted: Wed Dec 17, 2003 3:27 am
by aquila125
and use comments.. even if it's your own site...

Cleaning up your own code can be a <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> job without any comment...

Posted: Wed Dec 17, 2003 3:41 pm
by Paddy
Or don't so people have to pay you to come back and alter code rather than someone else. ;)

Posted: Wed Dec 17, 2003 3:56 pm
by Draco_03
Hey my advice is :...start easy... something step by step

like for exemple.. start by outputting stuff in your browser.. ..
after try to increment a variable.. and output it in yoyr browser
then learn about form (post and get methode)
after try to save texte in a file
.. after beiing able to read write create a external file play around with array..
array are very important.... there like a table with rows and column

that shoukd take you some time.. after you have to learn to connect to mysql retreive some data and [play around a bit..

and when u touched every these points (i m taoking in general)
try to use them all in a project.. like a phonebook you create a database with your friends (and there numbers) and you access it from a DB and you output on your browser

then of course you play around like how to add name and delete personne.. give right to someone.. so they can log and see THERE numbers, so its becoming not just your phonebook but maybe for the whole family,...
hehe you get the point i think.. nyways ...
i now i had fun doiing all that.. :) but if only i had more time to work !! :)

Posted: Wed Dec 17, 2003 7:23 pm
by d3ad1ysp0rk
No offense, but I think you should slow down when you type. Spelling mistakes aren't a big deal here and there, but if your code is full of them like your post is, it'll be a female dog to try and correct everything ;)

Posted: Wed Dec 17, 2003 8:08 pm
by Saethyr
be sure once something is coded and not working, KEEP IT SIMPLE! Check your ; and " and '. These little bitty pieces of your code can cause huge headaches and force you to stare at a 4 line function for 6 hours then abuse your forehead on the table.

Code: Select all

//comment comment COMMENT!!!!
Commenting will make it 100 times easier when you go back to change something. Try to remember what a function does a year after you wrote it is harder then chinese calculus and will cause hella headaches.


Outlines are a good thing. Writers do it for a reason, I know your probably thinking, hell, I know what I want, but I bet at some point everyone on here reverts to paper at some point to make sure something "seems right"


Lastly, PHP is an entity, She demands ALOT of time and patience, she is addictive and revolting at the same time. She loves and hates, she lives and breathes. She gives life and takes life.......wait thats god....but, seriously, if you have a significant other, say your goodbye's now and get it over with, PHP commands you to release your worldly possessions and follow her to the darkside!


Saethyr

Posted: Thu Dec 18, 2003 8:40 am
by Draco_03
LiLpunkSkateR wrote:No offense, but I think you should slow down when you type. Spelling mistakes aren't a big deal here and there, but if your code is full of them like your post is, it'll be a female dog to try and correct everything ;)
hehe no offense takin but i don't code the same way i type... i wish i could but i'm too much of a noob to type fast when i code, i usually type line by line slowly :P

Posted: Thu Dec 18, 2003 9:45 am
by markbeadle
I find it useful when coding to produce an outline of the requirements with comments (Top level pseudo code if you like)

I then place the code between the comments to perform the requirements

That way, if you leave your code for a while you can see where you left it. Also the requirements are good for a baseline for your final annotations.

All the best with coding

Posted: Thu Dec 18, 2003 3:31 pm
by JAM
Giving practical tips and how to actually type code is a different subject. However, the two have one thing in comment;

There is no 'good or bad way', per se. I have thought a couple of people the basics and I think I covered all the ways. One needed everything perfectly on paper (he actually could code on paper, but on the screen... yuk ;)). Another one could produce 15 pages of code in 2h, then sat for 1h correcting spelling, indents etc. Others used both the paper and non-paper version.

Personally I write down 'Topics to cover' on paper, think about where the main work lies and statt coding soon after that. I think you need to try it out yourself to get a hang of your own path to success. =)

The only thing that is a must, is to either bookmark the online PHP-manual (or download it locally) and USE IT frequently.

Good luck!