There’s more than one way to do it… but only one works!

I just found a perfect example of something that really annoys me about software frameworks, API’s, toolkits, and programming languages in general.

I call it “There’s more than one way to do it… but only one works!”

Today’s example is from ExtJS – an extremely powerful framework for building applications in Javascript. I had an instance of Ext.Panel with borders on it and wanted to turn them off.

So in the documentation I found the following three methods:

1. border : Boolean

True to display the borders of the panel’s body element, false to hide them (defaults to true). By default, the border is a 2px wide inset border, but this can be further altered by setting bodyBorder to false.

2. bodyBorder : Boolean

True to display an interior border on the body element of the panel, false to hide it (defaults to true). This only applies when border == true. If border == true and bodyBorder == false, the border will display as a 1px wide inset border, giving the entire body element an inset appearance.

Before choosing the herbal remedies for nichestlouis.com order levitra online weak ejaculation treatment, you should know the effectiveness of the ingredients and how long it has been going on. Being selective is a good thing when it comes to marriage and “settling down”, but, just because you do tie the knot does not mean life discount cialis is over with 2.2 kids, a dog, SUV and a mortgage to go with an expanding waistline as you advance towards a mid-life crisis. Don’t increase or decrease the dosage without consulting cialis sale your doctor and take low fat low carb recipes. The man will get viagra in uk erection easily. 3. hideBorders : Boolean

True to hide the borders of each contained component, false to defer to the component’s existing border settings (defaults to false).

In my case, only door #3 worked, but it took me a while to figure that out.

It seems to me that it would be better if the API only offered one way to control borders. If I don’t want borders on my child components, I can turn them off in the child components. I’m willing to live with slightly less power in exchange for clarity. Or, if all of the methods actually worked as expected, I could live with that too.

I could cite countless examples of this issue. This probably isn’t even the best example, since these different methods probably are legitimate for some use case that I haven’t run across yet. I’ve seen many cases where some API methods simply do not work at all, while others do, with no explanation.

This will probably become a chapter in my upcoming book series on software development “gotchas” … stay tuned!

1 thought on “There’s more than one way to do it… but only one works!

  1. Bit of a hunch that that API ended up getting developed by multiple people at different times. When there’s not a clear guiding principle behind API design (don’t duplicate functionality, long names, etc) you end up with a bit of a mess. Very few people ever have the guts to go back and clean up that mess, hiding (perhaps rightfully so in many cases) behinds “backwards compatibility” issues.

Leave a Reply

Your email address will not be published. Required fields are marked *