Posted by & filed under Uncategorized.

Keep it simple, simple (Keepin’ it polite). Sometimes during development one may lose sight of simple solutions. For example one might find a situation in which you think that using division or multiplication is simpler than addition and subtraction. I’m pretty sure this is a fallacy most all developers fall into at some point, especially when trying to meet a deadline.

The Problem

Recently I was reviewing a web application prior to release (Zend Framework 2). It had three roles and each one had different content on the landing page. If you had all three roles, role #1’s display would show. If you had role #2 and role #3, role #2’s display would show. If you had just role #3, role #3’s display would show. To navigate each of the displays you would either need three user accounts or would have to change a single account’s list of roles twice. This division of displays created additional work. In addition, an oversight in requirements missed the fact that a user could be assigned more than one of the roles. With this implementation it was impossible. The developer had divided all of the interfaces.

The Solution

Replace division with addition and subtraction. Instead of looking at the page as three separate displays, think of each page as a set of components where each component requires a permission or role for display. In the controller action collect all of the data that the user has permission to access. When displaying the view, display all of the components that the user has access to. Each component is added or subtracted from the display. This results in a page where the admin can see everything (easy to review), users can have more than one role, and it will be easier to maintain in the long run.

Remember, division and multiplication is built upon addition and subtraction.

What do you really think?