Monday, March 31, 2008

Magento 1.0

See Magento 1.0 at its new home on bradley-holt.com.

Magento 1.0 has just been announced. Magento is an open source eCommerce platform based on Zend Framework. I've used several shopping cart applications in the past and have been very disappointed with all of them. Magento looks promising and I hope to demo it soon.

API Design

See API Design at its new home on bradley-holt.com.

Artima has an older (but still relevant and interesting) interview with Josh Bloch, a Sun Microsystems Architect. While the interview focuses on Java, Josh Bloch has some interesting things to say about software design in general. The main topic is thinking about design in terms of APIs instead of monolithic software construction.
Reuse is extremely important but difficult to achieve. You don't get it for free, but it is achievable.
The lure of object-oriented programming is the ability to reuse code. However, creating reusable code is not as simple as switching from procedural to object-oriented programming. One may make the switch from procedural to object-oriented programming and then be disappointed that object-oriented programming didn't deliver on the promise of reuse. Josh Bloch has a potential solution to this problem but it requires one to think about software in terms of public APIs.

Being disappointed with object-oriented programming, one may then decide to try agile programming, perhaps even extreme programming. One tenant of extreme programming is to "do the simplest thing that could possible work." Josh Bloch points out that this is easy to misconstrue:

The extreme programming proponents don't advocate writing something that will barely work as fast as you can. They don't advise you to forgo any design. They do advocate leaving out the bells, whistles, and features you don't need and add them later, if a real need is demonstrated. And that's incredibly important, because you can always add a feature, but you can never take it out. Once a feature is there, you can't say, sorry, we screwed up, we want to take it out because other code now depends on it. People will scream. So, when in doubt, leave it out.
He goes on to talk about other topics such as minimizing mutability, protected vs. private members, when to make a class final, and the copy constructor as a cloning mechanism. It is interesting reading if you are striving for the goal of reusable object-oriented code.

Saturday, March 29, 2008

Open Source Business

See Open Source Business at its new home on bradley-holt.com.

Cal Evans has a post talking about his experience at the Open Source Business Conference (OSBC). Just like many small businesses, especially web development shops, open source software is a critical tool for us at Found Line. However, I'd like us to be more then just consumers of open source software. It seems like most discussions about open source business focus on the large companies that sponsor open source projects. Where's the business model for small businesses in open source? Small businesses like ours typically don't start open open source projects but we can be a part of an existing project.

Sure, there doesn't need to be a "business model" for companies like ours to contribute back to open source. I certainly see the value in contributing back to open source and would like to do so even without any clear picture of how it's good for our bottom-line. But, in order for it to be part of a small companies business plan there needs to at least some basic understanding of how it contributes to the business' overall success. Here are few arguments I can make for why a small business should contribute back to open source software:
  • It helps to ensure that the open source software your business relies on survives and thrives.
  • It can help attract talent. With proprietary software there is a bigger risk that everything an employee learns and creates is left behind if they switch jobs. A job may look more attractive to a potential employee if they know that their efforts will not stay within a "walled garden." In other words, open source software and open standards are transferable skills.
  • Your business can have more of a "vote" when it comes to the direction and features of the open source software that you use. Those who contribute the most to open source projects get the most say in what direction the project goes in and what features are added. Features that are important to your business can be added to the software that you use.
  • You can claim that you are an open source contributor, not just a consumer. This can also communicate legitimacy and experience to potential clients.
These are just a few that I came up with. I would love to hear if anyone has additional benefits to add to this list.

Thursday, March 27, 2008

Standards

See Standards at its new home on bradley-holt.com.

I'm sure everyone has heard the phrase, "The great thing about standards is that there are so many to choose from." I think we finally have a coding standard for everything we do at Found Line - from PHP to CSS to web file names. We've gone through a couple of iterations and various options but here's what we've come up with.

For application code we've decided to simply follow the Zend Framework PHP Coding Standard. It gives us guidance on PHP file formatting, naming conventions, coding style, and inline documentation. If it works for a project like Zend Framework with a large number of developers it should work for us. Plus, I wouldn't be surprise if many applications start standardizing on Zend Framework conventions so following their standards should put us in a good position when doing integration work.

For id and class names in XHTML and CSS we've decided to adopt the microformats naming principle of dash-separated-lowercase-words. This is the only CSS naming convention I've seen that has a real purpose behind it. We will try to use names from existing microformat standards before coming up with our own. However, when we have to come up with our own names at least they will be consistent with the microformat names.

For files that will be web-accessible we've decided to use the dash-separated-lowercase-words standard as well. This is for a couple of reasons. First, it's consistent with what Zend Framework expects. Second, Matt Cutts recommends dashes instead of underscores as word separators.

PHP Users Group Meeting Last Night

See PHP Users Group Meeting Last Night at its new home on bradley-holt.com.

The Burlington, VT PHP Users Group met last night. Thank you Bluehouse Group for hosting and providing pizza and soda! Rob Riggen gave a talk on PHP Frameworks: 3 different ones and we went around the room talking about a PHP function or tip that helped us in the past. I decided to talk about the following very simple tip.

How many times have you done something like this:

if ($foo = 1) { }

when you meant to do this:

if ($foo == 1) { }

This is a common mistake to see. A developer accidentally uses the single equal assignment operator instead of the double equals comparison operator. Since PHP will successfully assign the value it will always return true which was not the intended result. A simple way to catch this mistake is to reverse the variable and the literal value:

if (1 == $foo) { }

This still has the intended effect of comparing the two values but if you accidentally use a single equal sign:

if (1 = $foo) { }

then you will get a parse error. Here we've introduced the concept of fail-fast into our code. We'd rather get a fatal error letting us know we made a typo then a potentially insidious and hard-to-find logic error.

Wednesday, March 26, 2008

PHP Users Group Meeting Tonight

The Burlington, VT PHP Users Group will be meeting tonight at 6:00 pm in Richmond, VT. The theme for this meeting is, "My Favorite Function." Come prepared to talk briefly about a PHP function (or tip) that has helped you out during your PHP development. I still haven't decided what my function or tip will be. Maybe it will be something really simple like the list() function which can save you a bit of typing or something more complicated like the Iterator interface.

Tuesday, March 25, 2008

Zend_Layout and Zend_View Enhancements Webinar

See Zend_Layout and Zend_View Enhancements Webinar at its new home on bradley-holt.com.

I missed the Zend_Layout and Zend_View Enhancements Webinar but the recorded Webinar and slides are now available. The Webinar covers a few of the cool new features that became available in the Zend Framework 1.5 release last week. These new features give web developers who are using Zend Framework a way to solve the problem of maintaining a consistent look-and-feel across multiple web pages. Solutions to this problem I've used in the past include:
  • Dreamweaver templates
  • PHP or Smarty includes
The problem with Dreamweaver templates is that a template change requires you to "burn" the change into all of the web pages that use the template. If you have lots of pages this process can get cumbersome or you may forget to upload all of the modified pages. Also, the developer in me cringes at the fact that we repeat the same (X)HTML code across multiple pages - even if Dreamweaver is handling this repetition for me. This just doesn't feel very DRY (Don't Repeat Yourself) to me.

PHP or Smarty includes help a lot with the DRY problem. However, you are now leaving it up to each script to decide where the page elements get included. You may accidentally include the header, for example, in the wrong place in one or more pages. Also, if you need to re-arrange the overall page structure you're stuck changing every single page.

Enter Zend_Layout and the Zend_View enhancements. Zend_View is an implementation of the two-step-vew design pattern and the Zend_View enhancements are a collection of view helpers that are useful alongside Zend_Layout. Check out the Webinar and read Matthew Weier O'Phinney's article on Using Zend_View Placeholders to Your Advantage.

Monday, March 24, 2008

Plain Old Semantic HTML (POSH)

See Plain Old Semantic HTML (POSH) at its new home on bradley-holt.com.

I didn't realize someone had coined a clever phrase for this concept. The basic concept of POSH is creating (X)HTML that is semantic, or structural, rather than presentational. Most people experience the web as a visual medium and thus assume that it is a visual medium. Many web development tools (such as Dreamweaver's WYSIWYG editor) reinforce this misconception. The web is in fact a structured medium and one facade to that structure is its visual side that most of us experience every day. People without the gift of sight, search engine robots, and other web crawlers don't experience the web visually. In order to make the web available to the widest audience possible we need to build websites with proper structure first. Then we can add presentation via CSS and behavior through a JavaScript library such as jQuery.

Here are the basic steps to make your next website POSH:
  • validate your (X)HTML - invalid markup is not very POSH at all;
  • use tables only for tabular data, never for layout;
  • use existing elements and attributes if they fit the semantics of what you're creating (e.g. ul, li, dl, dt, dd) instead of generic div or span elements;
  • use class and id names that are semantic, not presentational (e.g. MainNav is semantic but LeftNav implies presentation and is not so POSH);
  • use as little (X)HTML as possible to markup your content.
For those who claim that this is too limiting when it comes to design I suggest you check out css Zen Garden. Very POSH, very cool. Every single design you can pick from uses the same structured XHTML page - the only thing that changes is the CSS style sheet.

Earlier I mentioned something about adding behavior with JavaScript. My favorite JavaScript library is jQuery. jQuery lets you unobtrusively add JavaScript behavior to your (X)HTML pages using simple CSS selectors. This means no inline JavaScript code in your (X)HTML - no onclick or onmouseover event handlers cluttering things up.

POSH + CSS + jQuery (or another unobtrusive JavaScript library) is very cool indeed. But it's more than just cool. It makes your websites easier to maintain and it opens the door to concepts such as microformats - data that is both human and machine-readable. Are you ready to get POSH?