Golden Hammer

If you only have a hammer, you tend to see every problem as a nail. ~Abraham Maslow

WordPress has been very good to me for the blogging and social media sites that I’ve worked on lately. Now, I have a commercial project not related to social media; my plan was to use WordPress as the foundation. My partner in this venture has asked several times about the wisdom of that choice.

My argument went as follows:

  1. The three WordPress projects I have done recently have been successful.
  2. I already know WordPress from said projects.
  3. WordPress has tons of plugins. (OK, I admit this one is not on-point.)
  4. WordPress provides authentication and authorization which are HARD to get right.
  5. Although the client has an existing website, it is static only. And the web application could conceivably be extended to allow the client’s customers to interact with the site.

These arguments came about mostly because WordPress was the only hammer in my toolbox. Now that I’ve broadened my scope, other tools appear superior.

Client-Side MVC Frameworks

For the past week I’ve been investigating MVC Javascript frameworks, some of which is chronicled on this site. I’ve spent nearly 16hr with ExtJS4.1, and it is clear that a lot of thought and experience went into the design. Because so much is done for you by the framework, there is very little imperative code. This makes it hard to debug: since constructing the MVC framework consists of specializing existing classes and setting parameters as part of an associative array, there is not really any place to start debugging when the framework doesn’t come together.

Here’s an excerpt from the ‘very simple’ introductory MVC app:
[php]Ext.define(‘AM.controller.Users’, {
extend: ‘Ext.app.Controller’,

views: [
‘user.List’
],

init: function() {
this.control({
‘userlist’: {
itemdblclick: this.editUser
}
});
},

editUser: function(grid, record) {
console.log(‘Double clicked on ‘ + record.get(‘name’));
}
});[/php]

Cross-Framework Shopping

The site TodoMVC offers an interesting and valuable comparison of a large number of JavaScript frameworks all implementing a simple To Do list. There is a clear App Specification and an open invitation to submit implementations with different frameworks or submit bug fixes or improvements to existing frameworks.

Unfortunately, you cannot see all of the code on TodoMVC.com; you have to download and install it on your own web server to see the wiring. I’ve set it up on this server, both to show how things work and to make enable code browsing. Check out the working apps or browse the code (TODO).

What I learned from spending quality time with TodoMVC is that the different frameworks aren’t all that different from one another on the surface or in the features provided. The differences mainly lay in style, documentation, and how the functionality is presented. Looking at ExtJS in that light, it has outstanding documentation and is well-designed, as I said. At this point I’m going to say my difficulties with the MVC framework likely stem from:

  1. Inexperience with JavaScript and client-side coding
  2. Inherent difficulty with large scale, consistent, robust client-side coding

Better the Devil You Know

Getting specific effects on WordPress can be frustrating. For example, plugins get to inject their CSS after the theme, which means that if a plugin sets its own CSS then nothing you do in the theme CSS files effect the look of that plugin. This violates the whole separation of content from presentation concept. For a couple of sites, where I needed plugins to match the theme or look a certain way my choices were

  1. Edit the plugin. This is the most direct way but it also means that updating the plugin loses my changes.
  2. Create a plugin for the specific purpose of modifying the CSS of other plugins.

Neither is desirable. I ended up creating plugins to change the CSS of other plugins. This got me thinking about architectural limitations in WordPress and inherent problems using it in an application domain for which it is not intended. I realized that I was following the anti-pattern Golden Hammer. At that point, rather than Googling for more plugins to try and patch WordPress to be an application framework I instead searched for application frameworks. It wasn’t Google that made me take another look at Zen, it was Dreamweaver.

Before yesterday, I already knew that Dreamweaver supported PHP and MySQL along with Adobe’s own widget set, Spry. I’ve always used Dreamweaver as a coding tool with preview. Yesterday, I began trying to use it as a layout tool. This brought me to lynda.com looking for a training video on using Dreamweaver as a layout tool. There was a spot-on tutorial called Dreamweaver with PHP and MySQL. Looking through the TOC, it appeared to cover what I was looking for. It also mentioned setting up Zend.

Zend

I had taken a quick look a Zend a couple of times. It’s so large that it is difficult to know what you are looking at.

Once upon a time, there lived six blind men in a village. One day the villagers told them, “Hey, there is an elephant in the village today.”

They had no idea what an elephant is. They decided, “Even though we would not be able to see it, let us go and feel it anyway.” All of them went where the elephant was. Everyone of them touched the elephant.

“Hey, the elephant is a pillar,” said the first man who touched his leg.

“Oh, no! it is like a rope,” said the second man who touched the tail.

“Oh, no! it is like a thick branch of a tree,” said the third man who touched the trunk of the elephant.

“It is like a big hand fan” said the fourth man who touched the ear of the elephant.

“It is like a huge wall,” said the fifth man who touched the belly of the elephant.

“It is like a solid pipe,” Said the sixth man who touched the tusk of the elephant.

They began to argue about the elephant and everyone of them insisted that he was right. It looked like they were getting agitated. A wise man was passing by and he saw this. He stopped and asked them, “What is the matter?” They said, “We cannot agree to what the elephant is like.” Each one of them told what he thought the elephant was like. The wise man calmly explained to them, “All of you are right. The reason every one of you is telling it differently because each one of you touched the different part of the elephant. So, actually the elephant has all those features what you all said.”

“Oh!” everyone said. There was no more fight. They felt happy that they were all right.

From www.jainworld.com

I’m just starting to look at the Zend elephant, but I have already seen that it includes modules for both authentication, Auth, and access control, Acl.

Enhanced by Zemanta

1 comment on “Golden Hammer”

  1. Pingback: Stabilizing the Mix | BranchPoint, Inc.

Leave A Reply