-
Get a monthly update on best practices for delivering successful software.

acl9 is a an authorization library for rails applications. It is one of the widely used library if not the most widely used now. Our experience with acl9 shows that it might be heavy weight if your authorization needs are simpler (which most projects are) but could be useful for other projects.
If you've used acegi/spring-security for authorization in your java apps, you know that acl9 is very similar in principle and hence very powerful. In addition to primary roles, it provides object level permissions which are stored in a generic way separately from the objects being controlled, all without the need for handcoding/distributing your authorization columns in each authorization-object tables.
One place where acl9 differs from acegi is how it doesn't differentiate between a role and a permission. Acegi signifies roles as global permission level which allows you to do certain things (some action on any object of a given class). Where as, a "permission" controls whether your can take that action on a certain object of a class or not. Acl9 calls them all "roles" (primary-roles and object-roles). As you can imagine, a given user may have a few roles in system but end up with lot and lots of permissions in system depending on how many objects user owns etc. This may seem like good idea at first but it presents a unique problem which is not apparent at first. Since roles and permissions are not conceptually separate in acl9 - and that a user can have lots of them (few roles and lots of permissions) - prevents us from loading and caching them in memory. Why do we need to keep them in memory? Because you are querying user's primary roles most often in your rendering of pages.
For example, consider navigation-bar which is common in most applications. Different users are presented with different tabs in navigation-bar and this bar gets rendered on each request/response cycle. Whether to render a particular tab is conditional to whether a user has certain role (primary role in particular) or not. Since acl9 cannot keep all roles (and permissions) in memory, it has to perform database query every time it has to find whether a user has_role?(admin) or not. Given that there can be only a few primary-roles that the user will have in any system, it seems in-efficient to not cache them and go to database each time.
The solution would be to separate these primary-roles from permission-roles and cache them for each request. In acl9 this means overriding User.has_role? and user.has_role!.
class User
def has_role?(role, object = nil)
if object || !Role.primary?(role)
super
else
primary_roles.collect(&:name).include?(role.to_s)
end
end
def has_role!(role, object = nil)
super
@primary_roles = extract_primary_roles if(Role.primary?(role))
end
def primary_roles
@primary_roles ||= extract_primary_roles
end
def extract_primary_roles
self.role_objects.select { |r| r.primary? }
end
private :extract_primary_roles
end
That does it. You cache the primary-roles and leverage those for has_role? queries.

This year's Day of Mobile had a number of interesting tracks, including the ever popular hack-a-thon.
In the hack-a-thon, developers worked alone or in teams to build applications that targeted any one of the mobile platforms (iPhone, Blackberry, Android, Palm, Windows Phone) and presented their applications to the attendees to win prizes.
Our own Mike Laurence, who won the in in the open source category for developing an iPhone application for the Lighthouse issue tracking service. In three hours.
How? By using our recently released Core Resource Framework, a local/remote resource management framework that accelerates the creation of API clients, our soon to be released DynamicCell project, and integrating with the Lighthouse API. Pretty sweet.
I talked to Mike about it afterwards, and here's what he had to say:
"Three hours is a pretty short time to develop an application, but this was a good chance to test out the Core Resource framework. I've been working on the framework itself for the last five months or so; for the hackathon I decided to see if I could actually make a working app in 3 hours. I ended up creating a Lighthouse account (bug tracking website) for the project, and because Lighthouse has a nice API, that's what I used as my source. I did get an app up and running in 3 hours, which was pretty exciting. It even looked decent, due to the other open source project I announced (DynamicCell.")
The Core Resources framework is available now, and look for an announcement on the DynamicCell project in the next week or so.
We're building a fair number of iPhone and iPad applications now, and it's great so have someone like Mike on the team and contributing back to the community.
Topics: iPad, ipad development, iPhone, iPhone Development, iphone framework, Open Source

The midVentures25 event is happening this Thursday, and Pathfinder is proud to be sponsoring the event.
midVentures25 is the first Chicago-based startup demo day & conference: 25 of the best investor-ready early-stage startups will demo their products in an open-floor expo.
The top 5 startups will have a chance to pitch to an audience of entrepreneurs, VCs, angels, bloggers, media and Chicago's tech community. A panel of expert advisors will ask the tough questions -- ultimately choosing one company to win over $10,000 in services.
The focus of midVentures25 is to show the national technology and investment community that the Midwest has an abundance of early-stage innovators within the technology, consumer, and sustainability space. You can expect to engage thought leaders in education, art, media, business, science, and technology during the conference.
There are a lot of great innovations that continue to come from the Chicago community, as we know from the early stage clients we've helped towards success. We're looking forward to an event like this that brings the people that make this happen together. It should be a great evening.
Topics: midVentures25, Pathfinder Events, Startups
Day of Mobile is happening this Saturday, and Pathfinder is proud to be sponsoring the event.
This should be a very cool event , and we're excited about interacting with other mobile developers in the Chicago area. We look forward to seeing you there!
Day of Mobile is an all day event for mobile developers and enthusiasts that will take place at IIT on March 6, 2010. The overall goal of the event is to better prepare both Chicago's application development community and companies with mobile initiatives for the upcoming mobile revolution. We will cover a myriad of different topics relative to mobile development and strategy such as platform SDKs, cross platform development, multimedia, CMS/SMS, mobile business models and many more. The event will begin with a breakfast at 8AM and conclude after a keynote speech and hackathon awards ceremony at 4PM. Throughout the day, there will be talks running concurrently with one another in two adjoining ballrooms.
I started my first real Agile software development project in 1999. I'd been doing more traditional software development before then all the way back to 1980. I won't bore you with the details of those earlier projects, but my feeling was that there had to be a better way of developing software that didn't involve a senior technologist (me) telling a whole bunch of junior technologists what to do. It turns out I was right.
But almost from the start I got pushback from other people in the development organizations I worked in that Agile development was horribly wasteful. They pointed to Test Driven Development ("all those tests more than double your effort"), pair programming ("two developers doing the work of one?"), and refactoring ("you're rewriting the software every time at enormous cost"). Of course all of these objections were born not just out of a misunderstanding of Agile development, but a fundamental misunderstanding of how their own software development processes actually worked.
Topics: agile, refactoring, Technical Debt

Instead of a "loading" animation that we may bail out on, why not tell a story? I was impressed with this technique used by BMW. They are running banner ads on NBC's site which hypes the upcoming Olympic events. You see a car in the banner ad, you expect to click and see more car. But you don't. Instead, a blank white screen with just a few short words pops up. But the words tell a quick paced story. phrase by phrase, of what joy is. Joy is Timeless. Joy is Freedom. Joy is Innovation. And below those words is the "loading" indicator. 10%, 20%, 32%, and so on. A nice example of storytelling used in design - if you are going to make someone wait (or have to, because you are loading a high-end car video), consider getting them engaged with a story.
http://www.bmw.com/com/en/insights/technology/joy/bmw_joy.html
Topics: Advertising, Design, storytelling, strategy

Claude Shannon
So, it's little Stevie Jobs' birthday today. Certainly he's been influential in the world of digital computing. But when folks wax on and wax off about how great some of these more recent figures in computing have been, I like to remind them of some of the all-time greats. It just so happens that that today is also the 9th anniversary of the death of Claude Shannon. Who is Claude Shannon, you ask? How soon they forget, or perhaps they never knew.
Well, in his masters thesis at MIT in 1937, he observed that you could solve Boolean algebra problems using switching and relay circuits. OK, think about what that means. Wait for it...yes, he invented the modern digital computer. In 1937. In a masters thesis.
It was all downhill from there, of course. He only founded the field of Information Theory (central to cryptography, computational linguistics, and pretty much any kind of digital information processing). Yes, the digital revolution started with him.
Oh, and he also laid out the field of computer chess in 1950, describing the different ways a computer chess program could be designed. Sixty years later, his roadmap for the field has been dead on.
So, the next time someone celebrates Stevie's birthday, let them know about Claude Elwood Shannon.
Topics: Claude Shannon
I recently published the mort_calc gem at gemcutter.org. The code can be found at http://github.com/perry3819/mort_calc/.
The gem calculates the APR and monthly payment for a mortgage in the United States.
Calculating the monthly payment is straight forward.

C = Loan amount
E = Extra costs
r = monthly interest rate = interest rate / 1200
N = amortization term in months
An iterative approach is needed to find the APR. The equation for the APR follows.
Continue reading »
Topics: mortgage calculation, rails gem
There's still a lot of internet chatter about why you'd want a tablet anyway. I think there's a big space between the laptop and the iphone, and that in particular, the iPad, iPhone and iPod Touch will take over from a lot of purpose built devices that deliver specific high value functionality. Here are a few examples:

1. The daily commute. It's a simple matter of ergonomics here. I will use the iPad, sold with a cheap data plan when I'm sitting down on the El, rather than the iphone. Because it has a bigger screen, and it's already connected. I won't use my laptop, because it doesn't come with a data plan (or only an expensive one that I won't buy), and it's pretty uncomfortable to use in a cramped row of seats. I'll use it instead of a laptop because the form factor works much better, and because I will have bought the data plan bundled with the iPad.
2. The eBook reader. I'll use it instead of a Kindle because it will be good enough (or better), and I can do a lot more than read with it. My guess is there will be more people that read on the tablet than who buy a dedicated reader. (Just as there are more people who do photo sharing on facebook than on flickr.)
3. In the Kitchen. If I'm in a situation where a sealed, mess resistant device with a big screen is a big advantage (like a kitchen) then I will use the tablet. I will prefer it to the iPhone because it's bigger and I can look at it while I'm doing something else, and I will prefer it to a laptop because the keyboard will not get gunked up. There are already devices retailing around $300 to store and retrieve your recipes in the kitchen - an iPad with the right recipe app will run rings around that.
Continue reading »
Topics: apple tablet, iPad, iPhone, Mobile, purpose, purpose built devices, tablet
Gwarred Mountain over at Climax Studios has posted a very thoughtful blog post about software development methods and the appropriateness of Agile Software Development. I was ready not to like this article, what with the title and things like this:
If I have to sit through another meeting with some little "agile" toe-rag defending their train wreck of a project then I may end up forcibly ramming a kanban where the scrum does not shine.
But then I thought about all of those fresh-faced management consultants we've run into recently -- who have read a book about agile -- trying to teach us how to do it. Well, yes. I've had some uncharitable thoughts myself. Continue reading »
It is very easy to misunderstand software and it's capabilities. Although people and software often perform the same tasks, they often do so in very different ways and achieve very different results. The results software can achieve are sometimes surprising, even amazing. But what computers can do is still quite limited. Making software development decisions based on an incomplete understanding on how software works, or drawing unwarranted equivalence between humans and computers, can lead to comical or even disastrous consequences.
It is with this in mind that I wanted to revisit one of my favorite topics: chess engines -- the computer programs that play a game of chess. Chess and computers were back in the news with a mainstream article by the mother of Kris Littlejohn entitled The Role of Computers in Planning Chess Strategy. Her son, Kris, helps current US Chess Champion Hikaru Nakamura prepare his openings for torunaments and matches and he makes use of various software (chess databases and engines) for this purpose. It's a well written article and well worth a read.
I've been an avid chess player for many decades and have also written a number of chess playing programs over the years. So it really tickles me how when then world champion Gary Kasparov lost to Deep Blue in a match back in 1997, many folks predicted that chess as a human past time would die. over a decade later, the situation is even worse for the humans: the best GM's can not hope to defeat the best programs, even at material odds. Yet the game is more popular than before. Part of the reason is online play thanks to the Internet. Another reason is that these strong chess engines make for primitive coaches. So the future of chess is safe for now.
Topics: chess
A few weeks ago, I wrote about the Skype Video Phone, part of a trend towards trading needless complexity for simplicity and ease of use. It's also on the wrong side of another trend: The trend away from single purpose mobile devices to flexible mobile platforms.


For a while there was a trend towards more and more purpose built digital products, from ebook readers to portable picture frames and pocket size digital cameras, all the way to to digital recipe readers ($299) and tablet pcs with tough cases, handles and barcode scanners for the medical industry.
The iPhone, the iPod Touch and the soon to be launched iPad signal a reverse of that trend. Apple has designed and built flexible platforms that combine the ease of use and simplicity that single purpose devices with the flexibility of general purpose devices, and that is proving to be a compelling value proposition.
On the iPad, for example, you can easily get as good or better a recipe reader experience as you would with the demy digital recipe reader, a better digital picture frame or slide show experience than with a digital picture frame, likely as good or better of an ebook reader experience, and likely as good or better of a bar code scanning medical tablet experience.
How is that last possible, when the iPad does not come with a bar code scanner? The solution will likely be through peripherals built into functional cases. As an example, take a look at the digital checkout devices like Apple's own EasyPay touch (used at Apple's retail stores), Verifone and Morphie - that combine a magnetic card reader, a bar code scanner and a battery in a case for an iPod touch.
Continue reading »
Topics: ease of use, iPad, iPhone, Kindle, Mobile, purpose built devices, simplicity

Tiling a Polygon
One of the most challenging problems I came across working on a .NET PDF Annotator and Editor application was to tile a 2-D polygon and also accurately determine the number of tiles that fill the surface of the polygon. The tiling part was not as much of a challenge as the counting part. The tiled polygon was to be rendered on a PDF document since the application in question is a PDF Annotating and Editing tool. We looked for anything the third party .NET PDF rendering/manipulation API that was used could provide for the tile rendering but there was nothing unfortunately.
Continue reading »
Topics: .NET, C#, Drawing, GDI+, Window Forms Development
We've discussed the benefits of Agile development before and that the iterative approach to building the architecture -- where you explore architectural issues (very few apps are completely new and unknown) a little bit through each iteration -- is an effective method for arriving at a good application architecture. What is less obvious is the psychological benefit to working in this way.
It's frankly been a while since I've participated in a large waterfall project directly (one benefit of working for a firm that does agile software product development), but I regularly talk with folks who are still in the corporate trenches doing things the old fashioned way. One thing that hasn't changed is the BIG ARCHITECTURE wrestling match up front. Management wants to know the architecture, the guys with "architect" in their job titles want to know the architecture (so they can criticize, natch), the project manager(s) want to know the architecture. How will we scale? How will we ensure security? More useless brainpower is spent on this ultimately fruitless task -- solving problems that end up being no problem at all -- than almost any other activity in the project.
Topics: agile, Divide and Conquer, Stress, waterfall
Sphinx (and its rails plugin thinking-sphinx) is my choice of search engine on ruby/rails project. It is powerful yet super easy to setup.
However, testing Sphinx code is not easy at first. Since Sphinx works by leverging database commit hooks, it cannot be tested within the bounds of unit testing framework that rails provides. This is understandable because, in rails testing, a transaction is started before each test that is bound to rollback after the test is finished. Since the test data is never committed, sphinx doesn't get a chance to index anything and cannot be tested.
The documentation for sphinx testing suggests using cucumber for integration testing. To me, cucumber test are still miles away from the smallest piece of sphinx code (inside Model) to be tested. So, I turned to how transactional code is tested in rails framework for some cue.
Here is what I ended up with:
class TransactionalUserTest < ActiveSupport::TestCase // any transactional test needs to have this self.use_transactional_fixtures = false context "with no users in database" do setup do // clear the existing data for our test - not sure if this affects other test but we use machinist instead of fixture files, so we should be good here. User.destroy_all UserProfile.destroy_all end context "with a few users created" do setup do @john = @david = nil // any data for sphinx test should be wrapped in transaction so sphinx can see these changes User.transaction do @john = User.make(:first_name => "John") @david = User.make(:first_name => "David") end end should "find user with first name john" do // start sphinx server ThinkingSphinx::Test.run do // give sphinx an opportunity to index newly added data (required before calling search) ThinkingSphinx::Test.index assert_equal([@john], User.search("john").collect) assert_equal([@david], User.search("david").collect) assert_equal([],User.search("cheese").collect) end end end end end
Isn't it nicer to be able to test sphinx code in isolation