Sep 19 2008

When you write code, does it make sense?

I’ve inherited some pretty bad code over last year. It’s not necessarily bad code, it works, it’s just not pretty and the more developers who have touched it between it’s original creation and when I open it, the worse it is. There’s usually no commenting of methods or variables, only a small note at the top of the file stating information such as author name, date, and in some rare cases a brief description of what the file does. So when I open a old file and see completely mangled un-commented code, it makes me want to rip my hair out. It takes me a lot longer to figure out what each variable is used for and what each method does then it would of taken the original and sub-sequent developers to simply comment their code.

I’m not sure why previous developers chose to omit comments, it doesn’t take that long to do. I dropped Dreamweaver for Eclipse a month or so ago as my my primary IDE. All I have to do is type /* and it creates a comment block. Dreamweaver (I believe) has a button that will create comment block (I always just typed my comments). Another thing I do is leave white-space in my code. I break code inside methods into chunks, fore example after I type an array or variable I follow it with a line-break as long as the next variable is not related to the previous. Some people would argue that the additional white-space adds unneeded size to the file. Personally I’d rather have a slightly larger file that I can follow six months from now, than one that’s smaller and compact.

So, how do you write your code? Do you comment it? Do you utilize white-space to increase readability? Or do you compact it as small as possible? Why?


Sep 1 2008

PHP was not my first choice, but it was my best choice.

I don’t think anyone knows this, but PHP was not my first choice of server-side development language. ASP was, and I mean classic ASP. When I was 14 I had already been reading web design books for a few years and HTML was getting boring. I was using tables and Paint Shop Pro 7 and found that I could only do so many things. I had a couple of websites on Angelfire, nothing of any real interest though. So I picked up a ASP for Dummies book (I had a lot of the Dummies series on web development as they were cheap and easy to follow) and shortly after buying it returned it as I hadn’t realized that I needed a server to run it (or how much said servers cost a month).

It wouldn’t be until I was 17 that I learned about PHP and started playing around with it, and it wouldn’t be until I was 19 that I felt I had a good (not great) understanding of it. I still don’t have a great understanding of it, but I’m learning a lot at Inovat. Probably one of the coolest thing I’ve learned at Inovat is using a foreach loop to dynamically create variables from array keys ( foreach($array as $key=>$value) $$key = $value ). I use that in almost every project at some point. I played around with Rails in college a little bit, nothing all that exciting was created.

PHP is the language that helped me get a job, I showed both PHP work and Actionscript2 work during my interview, the AS2 didn’t hurt or help me, it was just there. I showed off a custom PHP Content Management System and a site that ran on it, and I think that really helped. Since starting at Inovat my PHP development has gotten better, I can hand off a PHP file to someone and they can follow it (except for my first MVC endevour, that was a train wreck).

Are you working with what you started with, or have you moved on to something else and why did you move on? I really want to know.


Aug 31 2008

CodeIgniter, Blue, and No Work Examples

Tonight I relaunched my “portfolio” site. This time with no work examples or promises that they will soon arrive. Something else that’s new this go round is the overall color of the site. It’s sporting a very cool blue background instead of the normal white background that I always end up with.

Upon first glance you’re probably going to say it’s really simple, and well you’re right, from a design standpoint it is extremely simple. However from a technical standpoint it’s a bit more complex. It’s running the PHP open-source MVC framework, CodeIgniter. CodeIgniter is a bit overkill for a site that doesn’t have a database, multiple pages, or a Content Management System. But the reason I decided to use CodeIgniter was for future plans of mine. If I want to add a page it will only take me about 5 minutes to do so.

The contact form was another reason I chose to use CodeIgniter. The contact form uses CodeIgniter’s form validation library to make sure every required field is filled in and they are filled in correctly. The framework then processes the form and sends me an email.

There are a few items I want to add to the site, one being a short-list of clients (ones from work, etc) just so there’s some note of clients I’ve worked with for potential clients to see, though no actual portfolio. There’s actually one really large client I would like to use, I’m not sure I’ll be able to display it. But I should be able to claim it as I put a lot of work in on it.