preparation ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
thomasd1
Forum Commoner
Posts: 80
Joined: Sat Nov 22, 2003 2:48 pm
Location: Belgium

preparation ?

Post 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:
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post 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 :?
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post 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!
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post 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..........
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post 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.
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

thats a good idea microthick
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
User avatar
aquila125
Forum Commoner
Posts: 96
Joined: Tue Dec 09, 2003 10:39 am
Location: Belgium

Post 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...
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post by Paddy »

Or don't so people have to pay you to come back and alter code rather than someone else. ;)
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

Post 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 !! :)
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post 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 ;)
User avatar
Saethyr
Forum Contributor
Posts: 182
Joined: Thu Sep 25, 2003 9:21 am
Location: Wichita, Kansas USA
Contact:

Post 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
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

Post 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
markbeadle
Forum Commoner
Posts: 29
Joined: Tue Dec 02, 2003 2:50 am
Location: Aachen, Germany

Post 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
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post 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!
Post Reply