Ben Allfree :: Painless Programming

Guaranteed results for iPhone, Rails, PHP, .NET, Flash, and more

Next-Driven Development in Rails

November 1st, 2008 · No Comments

TDD says: Do the simplest thing next.
NDD says: Do the thing you need next the simplest way you can.

Tags: , , , , ,

Show me this in ActiveRecord

October 10th, 2008 · No Comments

This is an example of a query ActiveRecord can not generate (but I wish it would):

PostSearch.find_by_sql(”
select
ps.*
from
post_search ps join posts p on p.id=ps.id
where
post_search.id #{self.id} and
abs(length(body_excerpt)-length(body_excerpt))

Tags:

Rolling your own framework is good

September 20th, 2008 · No Comments

I’m building PrestoScript in Ruby and the more I get into it, the less I am in anyone’s framework but my own. Why is that? Is there a certain class of problems that are frameworkless? I’ve been thinking lately that generalized frameworks could be a farce. I always explain to clients that Ruby on Rails [...]

Tags: , , , , , , ,

Beyond Ruby’s ActiveRecord

September 12th, 2008 · 2 Comments

ActiveRecord is one of the hidden treasures of the Rails framework from which Rails derives so much of its productivity. It features beautiful uses of the Ruby language, especially Ruby’s dynamic programming features.
ActiveRecord also makes it easy to be inefficient though. Efficient data access is not something that happens magically, and if ActiveRecord is left [...]

Tags: , , , ,

Web harvesting

May 30th, 2008 · No Comments

I was talking to a client today who has business plans that revolve around harvesting data from web sites. How do you do it? Here’s my step-by-step process:
1) Crawl for links
2) Fetch link content
3) Index link content
4) Transform link content
If you design your system that way, you end up with something that can be scaled [...]

Tags: , , ,

Rails for PHP

March 20th, 2008 · No Comments

Well, it looks like Akelos (http://www.akelos.org/) is taking the lead in the “Rails for PHP” race. It seems to have a better MVC architecture than cakePHP, especially where ActiveRecord is concerned.
MVC frameworks are an important design concept for modern Web 2.0 applications. I frequently consult on this topic and have a lot to say, too [...]

Tags: , , , , , , ,

A testable PHP MVC pattern

February 5th, 2008 · No Comments

I like cakePHP, but it’s not as testable as I would prefer. So, I made my own.
As it turns out, ADODB for PHP supports the ActiveRecord pattern, which is much more to my liking than cakePHP’s data model solution. Also, cakePHP requires .htaccess support which I do not always have when hosting on IIS. Third, [...]

Tags: , , , ,