Few Logical Programming Questions.

Posted: March 15, 2011 in Stay Hungry Stay Foolish..

I started coding 2 years ago, and this community has helped me a lot understanding many things which I was not aware of. However, many reputed coders instructed me of some patterns, the way I have to code and the way I shouldn’t write codes. Although I accepted their suggestion with gratitude, there was many thing I couldn’t understand.

I want your point of view to understand the few questions which has been running over my mind from the past few days.

MySQL

  1. Why is it that many coders gave me thumbs down whenever I used the * in the select statement? Why did they suggest using entityname.tablename even if sometimes I want almost all the data from a table?
  2. Is it okay if my code make a frequent trip to the database on a single page say about 5-8 request? To be more precise in a page I would want to update the value, insert the value, count the rows, sum up the values, and so on.I once made almost all the select statement as a single query and one of the reputed user of this community suggested me not to do it that way instead suggested me to use a user defined function. (BTW, user defined function helped me a lot to clean my code and understand the error more quickly). What is your take on this?

Frameworks

When I started learning PHP I knew little about programming and more about web, although I had learned the popular computer languages like C, C++, .NET, Java etc. in my college. It was just the formal and theoretical subject which I learned and when I knew I wanted to be a web developer internet was my best friend and the community helped me out.

Now when I have started my journey of learning programming I have set some goals and aims myself, I want to be a Pro PHP Developer, I want to Master the HTML, JS, CSS, MySQL etc. My question here is

IS FRAMEWORK EVIL FOR LEARNERS LIKE ME?

Here’s  The Answer:

MySQL

Using * is fine. When you start getting really complicated with MySQL queries – joining and comparing tables – then you want to look at using entityname.tablename just to keep yourself from getting confused.

The next question is too subjective. It depends on your server and the efficiency of your script. It also depends on how many people will be using the script. Obviously, as with anything, the less you use it the better. If you can do one sql query instead of 5 then do that, but if you’re only going to have a couple of hundred people viewing your blog then I wouldn’t worry too much. Its the same with functions. Obviously its much better to put everything into functions. This helps in the long run because you will only have to edit your script in one place to make changes. Lets put it this way – if you’re copying and pasting code then you should be using functions. But then if your script is only 1 file, 200 lines long, then I wouldn’t worry if you don’t want to.

Frameworks

Frameworks are difficult to gauge the usefulness of. Obviously learning things like Zend or Mage are powerful frameworks that will help you to create much more efficient and complex web projects. However, for learners it may confuse you. I would say definitely not to try and learn them until you get your head completely around PHP. Hopefully then you will have a great enough understanding that you won’t have a problem if you come across these. You miss the main point of a language if you learn a framework. For instance – you won’t learn javascript if you just learn jquery. You’ll learn a bit, but you’ll never completely understand it.

Thats my take, but its a very subjective question.

Courtesy:STACKOVERFLOW

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s