Jump to content

How about this to HELP everyone?


Mr_J

Recommended Posts

Hi all,

Since I started programing in php, I found it very difficult to figure out WHY and WHEN and WHERE to use whatever I need to do. I managed to help someone recently. In the php section of the page, I did the following:

Validate($username,&$password,&$retro,&$acc);     //Describes what we are going to validate
    if ($retro == '3'):                               //1st retro=the error when the username is invalid
more php...
$mysql = mysql_connect('xxx.your-server.de', 'usrname','pw') or die("Could not connect : " . mysql_error());  //connect to server or error occured
    mysql_select_db("the_database") or die("Could not select database");                                        //select the database where usrs are stored   

Just in short, I added a lot of comments to explain exactly what I do and why I do it. I`m sure this is going to help him not only to understand but learn faster. I know there is no quick way about learning but like supposed most of us, Everything I know about programming I had to teach myself. I only finished school with no other qualifications or after school studies.

Lets make the world a better place as HELL can`t be this bad ;)

Just a thought...

Link to comment
Share on other sites

While commenting the code is indeed important, commenting every line of code, virtually translating programming language into human language, is not necessarily the best approach.

 

I can't disagree more, I wish when I first started to learn php, and asked for help on a forum someone had answered that way. It would have helped me tremendously. Even though I'm still learning, I use books, and code downloaded (which I dissect).

 

Every forum seems to answer a question with a question, why can't we just tell someone (at least the general direction) of finding the answer.

 

DG

Link to comment
Share on other sites

Comments really depend on your purpose. Sure, if you're writing a piece of code to explain something to someone, then it does usually help to add in plenty of comments - mainly because you've no idea of their level of expertise and general code reading ability; what may seem obvious to you could be very ambiguous to them.

 

However, i would never write code like that as general practice. Comments should generally be used to explain the purpose of an entire program/file/class/function or to explain and oddities/ambiguities in your code. For the most part, people can understand what your code is doing from reading it; there's no need to explain every line.

Link to comment
Share on other sites

I agree to all of you. My point I`m trying to make is that I found it difficult learning to program just because someone told me what to code. It worked but I had no clue why or what is going to happen.

Like I have mentioned, I have no qualifications and all of my knowledge came from self-propelled studies and of course the internet and forums.

Thanks for the patrisipation

Jaco

PS. I launched my 8th website this year and only started coding about 6months ago

Thanks for all you guys, you indeed are contributing to "MAKE THE WORLD A BETTER PLACE"

Peace

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.