• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

From 35 to 17

LPH

Well-known member
#1
As you probably know, I'm just learning PHP. So bare with me. My evenings are filled with watching video tutorials from Lynda, reading books, websites, and code snippets from others, as well as trying out samples on a local install.

Today, I was proud to install my first PHP framework. CodeIgniter was chosen because it was free and the first one to look like it had good docs.

Once CI was installed then I changed some configurations to work with WordPress as well as my PHP project. Next, multiple database configuration needs to be done.

For now, I was practicing PDO statements.

The first lines of code done in Coda 2 by hand were over 35 lines (the old mysql_connect methods) - with plenty of comments to make sure I'd remember later what was happening.

Today, that same code was put into CI and sits at 17 lines - mainly extra lines so I could read it. The actual code is only 5 statements.

Not bad for a novice.

What is your best code efficiency? When you look to make code more efficient, do you follow a plan of attack - look for obvious ways - or do you just read through until you see something that can be done better?
 

rellek

Well-known member
#2
I usually write code in the way I think it's best at this time. I might reconsider it when I need to review it because of feature enhancement or things like that, but I do not write code and try to optimize it later.
 

SneakyDave

Well-known member
#4
Codeigniter is a great framework to learn from, but it's progress has been a little slow coming around to PHP 5.3. If you have the basics of CI and other frameworks, you might want to try Faravel. I've been migrating a lot of my projects to it, and the contributors to CI seem to like it quite a bit.

http://laravel.com/

But that's just my personal opinion. Good luck to you. Sometimes those frameworks are a lot of work just to start learning PHP, but at least you're diving in head first.
 

Shamil

Well-known member
#5
In terms of code efficiency, I look to remove as many logic statements as possible, or should I say, displace them from whatever is using it.

Given that I am, by standard, working with objects, whatever I'm doing is quite easy. I normally do follow a plan of attack - an agreed set of standards by our team. We've to take into account both PHP side and MySQL efficiency - but also, security.