OOP in Javascript examples

Andres at Web 2.0 Technologies has a very informative post about how to use object oriented techniques to implement a robust event broadcasting and listening in javascript.  Follow his advise an dmake your code more reusable.

 What do you want to invoke when the checkbox object changes state? If you’re programming it
in a non-reusable way, you can hard-code the action directly into the onclick event:
if (state==checked) do X; if (state==grayed_out) do y; etc. If you’re programming it
as a reusable component, you need a more flexible solution.

Assessing software project risk.

ACM today released a survey of IT/software development projects to identify the most common causes of failure and developed a tool to assess what the risk of failure for a given project is.

As part of a multiyear research program on software project risk, we asked MIS directors in 60 organizations to make 720 separate project evaluations (see “How the Study was Conducted”). The purpose of the study was to understand the relative importance they ascribed to the software project risk drivers described earlier. The results revealed that the most critical risk driver was the choice of methodology—a result that we were not expecting—followed by customer involvement, use of formal project management practices, similarity to previous projects, project complexity, and requirements volatility (see Figure 1).

It’s interesting to note that of the six key drivers of failure, complexity ranks #5. While the most important driver was “choice of methodology”, which means that one approach is not always going to work across different engagements. For a small projects, a more iterative methodology might be a better fit but you should keep in mind the budgeting and staffing implications that would result.

For example, a methodology such as rapid prototyping relies on iteration to uncover novel or poorly understood user needs. In contrast, a structured methodology emphasizes structure over iteration and might be more useful for managing larger projects where requirements are better understood.”

Finally, #6 emphasizes that getting requirements right is both difficult and important. All software projects struggle with this to one extent or another.

“Building a system on volatile requirements is like attempting to build a structure on a foundation of sand. Tweaking an unfinished system to match shifting requirements requires additional programming effort and expensive reworking. Even if requirements are correctly elicited, there is no guarantee that they will remain unchanged over the project trajectory. Both changing business environments and fickle customers can contribute to requirements volatility. A certain level of requirements volatility has come to be expected in software projects, which may explain why this factor emerged with the lowest weighting among the six drivers of project risk in our study.”

I’m not sure of the value of their 1 minute risk assessment tool to produce a number that “predicts” project risk score. (). Different folks could score the factors differently but it could be a valuable way to evaluate project performance along the way (identify areas of concern for managers and developers to focus on) and at the end of a project.

Viacom channels back on Dish Network

Doc Searls has a good summary about Viacomm and Dish Network settling their recent spat over carrying Viacomm’s bundle of channels. Unfortunately, financial terms of the deal were not disclosed.

Why not? I think it’s because nobody who makes most of their money on advertising wants to see consumers become customers. Viacom, for example, is primarily in the advertising business. The programming they sluice down channels to consumers is just bait. Most of what they sell is best-guess numbers. They can’t begin to think about selling programming directly to viewers or listeners, partly because that’s not their business, but mostly because they don’t want advertisers to know specifics about actual viewing and listening – such as how often people tune away from advertising, or skip over it with their TiVos. Meanwhile the cable and satellite services are mostly in the business of satisfying habits.

But speaking as a consumer who would rather be a customer, a la carte is what I’d like. I think that’s exactly where we’re headed in the long run. And that the inevitability of advertising loss is the deeper issue behind the dispute between EchoStar and Viacom. That loss is will be felt on the supply side, by Viacom.

I think 95% of viewers would welcome being able to choose what channels they get and paying only for them. But the Viacom’s of the World don’t have any incentive to give it to them. Here’s a list of the channels I watch or want:

  1. Local over the air channels (get it via antenna now anyway)
  2. ESPN/ESPN2 (for MLS games although I might get the MLS DirectKick package this season.)
  3. Comedy Central – for the Daily Show.
  4. Fox Sports World, Fox Sports World Espanol
  5. ESPN Deportes
  6. TechTv
  7. And that’s pretty much it…

Regular Expressions are your friends.

Two and a half years ago, when I first dove into web development, I wasn’t very familiar with regular expressions. They certainly didn’t look regular to me, looked more like someone’s keyboard exploded. Now, having figured out a thing or two about them, I came across the following lines:

		$pos = strpos ( $this-&gt;user-&gt;privs, 'del');<br />		if ($pos===FALSE)<br />		{ // edit not found in string privs<br />			return FALSE;<br />		} else {<br />		// figure out where the string ends by looking for a comma, return that substring<br />			$next_comma = strpos( $this-&gt;user-&gt;privs, &quot;,&quot; , $pos);<br />			if ($next_comma===FALSE) $next_comma=strlen($this-&gt;user-&gt;privs);<br />			$len = $next_comma-$pos;<br />			$epriv = substr ($this-&gt;user-&gt;privs, $pos, $len);<br />			return $epriv;<br />

Which I was able to boil down into the following:

    if ( preg_match(&quot;/del_[a-z]+/&quot;, $privString, $match) )<br />    {<br />        return $match[0];<br />    } else {<br />        return false;<br />    }<br />

MS compares PHP to ASP

However, MS conveniently limits the scope of PHP to the single PHP download and not to the overall PHP community. The overall point I got from the MS arguments is ASP.NET: we give you more in the base distribution. Whereas for PHP you’d have to know where to look for good 3rd party classes and scripts. Personally, I’d like the ZEND folks to keep focused on the making the ZEND engine better.Some of their critiques:

It is important to note that currently no product such as the Zend Accelerator exists for ASP.NET. The binary code that is generated by the CLR is already as optimized as possible; no add-on product is necessary to achieve maximum performance. In other words, ASP.NET is providing for free what PHP users must purchase from Zend.

There are a number of free add-on optimizers as well.

It is important to note that currently no product such as the Zend Accelerator exists for ASP.NET. The binary code that is generated by the CLR is already as optimized as possible; no add-on product is necessary to achieve maximum performance. In other words, ASP.NET is providing for free what PHP users must purchase from Zend.

But with PHP you also get PEAR.

PHP provides database access through a set of built-in functions. These functions and classes must be compiled into your PHP binaries in order for them to be accessible in your PHP scripts

Unless you use a DB Abstraction library like PEAR:DB or ADODB.