Sunday, July 08, 2007

Starting a Rails Life

My rails life seems to be starting out similar to my php life. It all began with an internal application for my dad. He has a music instrument sales, rental and repair business and he initially did everything on paper to keep track of customers, instruments and billing. I took it upon myself to create a web based application for him to keep track of all of it. It was my first php application written in php3 and run on a small server here in the house. It is amazing that it is still running and he still uses it.

That was 7 years ago and looking back at the code now I cringe. Sometime in between there and now it was upgraded to php4 and it looks like that was a hack of a job. But since then my php life has expanded to the point of it no longer being a challenge. So what else would be a better way to start my Rails life than to revisit my dads billing application and recreate it with rails. Of course fixing all the issues with the current billing process and adding some additional features to make life easier.

To the right is a screen shot of the current functionality and design. I am currently just working on getting the layout squared away so functionality can be added without having to stop and think how it should look.  So far only 56 lines of code have been written and about 4 hours have been spent on the project, 2.5 being spent coming up with a design and 1 hour spent implementing and tweaking it. So far rails has been a dream come true.

Coming from php which is mainly mirrored from C++ I have always been use to the long hand conditionals. One thing that rails offers is the "unless" command. Compacting an if statement into one line that can be read without much difficulty. Here is an example of its use, probably not the most efficient but I am sure it will get tweaked once more come into play.
<%= ' class="selected"' unless controller.controller_name != 'customer' %>

Blogged with Flock

Friday, July 06, 2007

Making web development fun again

Web Development is a passion and like all passions they can become stale after a while unless you continuously look for a new technique to keep it fresh. I have become officially bored with PHP, dont get me wrong it is a great language but after developing in it for over 8 years you start to look for something new and exciting to get that same rush that you get when you learn and implement some new functionality.

Of course PHPSimpl has been a good release for me, it has really given me an outlet to expand my knowledge and take pride in building something that benefits more than just my development life. I am not stopping development on PHPSimpl, actually I think my additions and bug fixes will get increasingly quicker and better. I cannot leave PHP behind because the web is currently pretty much glued together with it.

I have fallen in love with Rails. After using a ton of PHP frameworks none of them really seamed to be straightforward and seamless. Rails on the other hand is not as get up and go as php it has all the requirements I have been looking for in a framework. Some of the excitement is from getting to learn a new language and the structure of a Rails app just make sense.

My dream has come true, No More Slop! PHP is like a blank piece of paper and a pencil, the graphite stays on the paper but it can go in any direction at any time. Its great for when you are feeling creative but horrible when you have to read someone else's paper, it might as well be in a different language. I have always tried to create some structure from PHPSimpl since I lead a team of three developers and we maintain 160+ sites.

I played around with Rails about 9 months ago while reading Agile Development with Rails and it really got me thinking about what else is out there. At that time I didn't take it too serious since I was already deep in a redevelopment which needed it badly. After a few months of PHP development on a large application that was not mine initially I was burned out. This past week I picked up Build Your Own Ruby on Rails Web Applications and read the whole thing, wow 400 pages I know... but the book was well written and went through the basics all the way to deployment. I recommend it for any developer looking for a change, even if you don't start developing in Rails it gives great insite on how the web should be and can be applied to any language. Agile Development with Rails is a little more intence and is a definite follow up read.

My Current Rails Envy:
  • MVC with a real structured generator
  • Database Migrations
  • Templating engine built in
  • Testing built in
  • Plugins
  • One line Scaffold for those quick apps
  • Fixtures
  • Simplicity of WEBrick
  • Logging like a mad man
I am in the process of changing to a more Rails friendly host and I will most certainly be writing my Rails entries. Its like starting my web development life all over again, its refreshing.

Blogged with Flock

Wednesday, June 27, 2007

Stress testing a site with Apache's ab tool, part 1

Apache's AB tool is a great way to really put stress on a server. I have compiled a list of the parameters I use to test my sites and applications.

First we have to make sure AB can hit the desired page and get the desired results. The most basic page is the homepage of a site, use the command below to send as many single requests as it can in 1 second
ab http://example.com/
But that is great and dandy but what happens if we want to try to stress a page that hits the database and has to do some actual dynamic work
ab http://example.com/search.php?q=Trees
Last but not least what if the site is behind a login that is an http form and not an htaccess form? That is where POST variables come into play, it is a little trickier but doable. Here is the command I use to hit a page behind a login.
ab -p ~/Documents/post.txt -T application/x-www-form-urlencoded -e http://example.com/manager/
Here is what my post.txt file contains:
email=test@domain.com&password=testing&submit=Login
Next we need to get these results to a file so we can work with them and have a record of progress as we tweak our site. It can be done with the "-e" parameter. An example is below:
ab http://example.com/search.php?q=Trees -e ~/Documents/results1.csv
What that does is hits the search page and puts the results in the results1.csv file. It is useful to put the file at the end of the command since you will want to change the filename on each run to keep a history of your results.

The csv file is separated into two columns. The first is the percentage complete and the second is the time in ms that it took to get to that percentage.

The first thing you want to look at is the zero percent. This is your latency, it is the amount of time it takes to fulfill the first request. You want this number to be as low as possible. I am running my site on a development server on my local network so the times will be lower but at the end I will show the results from the testing server.
ab -p ~/Documents/aci_post.txt -T application/x-www-form-urlencoded -e ~/Documents/aci_output.csv -kc 10 -t 10 http://aci/manager/makes.php
Hold tight, more coming soon...

PHPSimpl 0.8.1 Maintenance Update

Cleaning up after a release.
Thanks to everyone who has been using and testing PHPSimpl. After our first official release we wanted to squash some bugs, here is a list of the updates in 0.8.1:
  • Slightly Updated Example
  • Fixed the form label "?:" issue
  • Better support for tables without a primary key
  • Fixed the SimpleFormat to display values properly and renamed it to Nice()
  • Change DB now counted as a query
  • View() now goes off the default field display first
  • Security Updates related to SQL injection
Its a Recommended Update
Questions or Comments? Feel free to leave them in the PHPSimpl Group. There is always someone to help available. By the way we love feature requests, keep them coming.

Friday, May 11, 2007

PHPSimpl 0.8.0 Final Released

Everybody Dance! PHPSimpl has reached its 0.8 release!
We have been working hard the last few weeks to get PHPSimpl release worthy and the day is finally here! Included in the release are:
  • SetOption now accepts objects
  • Compressed the JS and CSS for the calendar
  • Change the time fields to human readable format
  • Fixed issue with Save() and display_order
  • Minor bug fixes
  • A more robust example
  • Full documentation for the classes with final API's
Want to try it out?
Questions or Comments? Feel free to leave them in the PHPSimpl Group. There is always someone to help available. By the way we love feature requests, keep them coming.

Thursday, April 26, 2007

PHPSimpl 0.8.0 RC1 Released

PHPSimpl 0.8.0 is feature complete and is posted on Google Code. The release candidate will be up for about a week and we will not be adding any more features or API changes. We are only concerted with bug fixed and security issues. Please download it if you are interested in giving it a try and let us know what you think. The final will be out in about a week and we are hoping to have a more feature complete example in it.

The Links
Please submit any bugs to the Issue List.

Wednesday, April 18, 2007

PHPSimpl 0.8.0 Beta 1 Released

The first beta PHPSimpl has been released to the public. You may be wondering why we decided to start at 0.8, well we have put together a Version History in the wiki and also a short Road Map. We have been using some form of a DbTemplate at WSU for a while now it just has not been public. Over the past two years it has continued to grow and strengthen. After submitting it to google code initially we knew it still needed some work and we took on the challenge of creating a solid framework that could be easily implemented and rapidly create applications with minimal configuration.

The Links
Remember this is just a beta, there is still some polishing to do. Although it is working this is still considered Beta software. Please submit any bugs to the Issue List.