Spare Cycles

Helpful Tip #348: Hooking Eclipse 3.3 into a local JBOSS 5 instance for debugging

December 18, 2008 · 3 Comments

I set up a JBOSS v. 5 instance on my home computer today so I could play with its new micro-container format and its implementation of EJB3.

I wanted to add it as a server in Eclipse’s list of avaiable runtime environments on my machine, but when I pointed Eclipse to the JBOSS installation, it complained about a missing JAR (mail.jar) in the default configuration’s lib dir, and I was unable to add the server to Eclipse.

After some Googling (yes, googling), I found this bug. Once I patched my local installation with the jboss5.serverdef file attached to the bug I was able to associate the server with my Eclipse projects. I could then use Eclipse to start/stop the server, run in debug mode, and view the JBOSS server log.

→ 3 CommentsCategories: Java · Tips
Tagged:

Debugging JavaScript Events with Visual Event

December 13, 2008 · Leave a Comment

I recently came across a handy tool for JavaScript debugging called Visual Event. Of course, modern JavaScript development would hardly even be possible without FireBug. And most advanced JS-based rich internet applications heavily leverage one of the major JavaScript framework libraries (e.g. YUI, jQuery, scriptaculous, etc.).

One of the limitations of Firebug in run-time debugging is it doesn’t have a good way to inform you of what methods are subscribed a DOM element’s events. If an element in the DOM is clicked on, moused over, value changed, etc. a JS event is fired. Any number of functions may be listening for that event and may get executed.

As applications become more complex, event subscriptions are spread across many files and those subscriptions can be conditional on particular logic flows. It becomes more and more difficult to determine what actions are  performed during certain events.

Event messaging is not consistent across browsers, and there is no W3C specified container that can be used to store and reference the document’s event listeners. As a result, each of the major JavaScript frameworks has its own mechanism for storing and executing event listeners.

Enter Visual Event. Written in jQuery, it’s compatible with YUI, MooTools, and of course jQuery. When run, it overlays the elements of your page with icons for each type of basic event associated with a DOM node that has listeners.

Here’s a basic DIV element with the text “Pull the trigger”:

On the left hand side is the basic DIV, on the right hand side is the visual event overlay. The DIV background color has been highlighted, and three icons have been displayed, each representing a listener and the type of icon indicates what event it is listening on.

This DIV has three listeners: one each for the click event, mouseover event, and mouseout event.

In these images there is also a red icon partially hidden, and this appears to be one of the jQuery listeners associated with Visual Event. This is unnecessary and adds noise to the tool, which has the potential to confuse the user.

If you click on any of the icons, an overlay is displayed that contains the source code for the listener:

overlay2

All in all, Visual Event is a very quick and handy JavaScript event debugging tool, and gives you information that you would have to gather manually through logging or alerts in standard debugging.

It’s not without its limitations however:

  • It only supports a sub-set of JavaScript libraries
  • It doesn’t work in IE
  • It doesn’t support custom events, but only handles the standard user interaction events supported by the browser
  • The listener display doesn’t indicate what file the function is located in, or it’s true line numbers

It’s important to note that this is a young tool, still classified as ‘beta’, and despite its limitations it can still come in extremely handy.

I wish I’d had it two years ago :)

→ Leave a CommentCategories: JavaScript · RIA · Uncategorized

Differentiation in Cloud Computing

October 14, 2008 · 2 Comments

The term “cloud computing” is a big fad right now. Lots of people use this term without a really solid definition of what it is. I’ve been thinking about it a lot lately, and a personal definition that I’ve been using a lot more is “horizontal computing services”.

Horizontal computing services refers to system architecture components that allow a software service to operate. For instance, data storage, processing power, network access are all examples of horizontal layers in an application stack that allow web software/services to operate. They’re common whether you’re running a photo-sharing site, a news aggregation site, or a video sharing site.

Maintenance of these layers is generally not scalable as a web service grows. In many cases, the maintenance of a horizontal computing service is outside the core competency of the organization that requires it.

Horizontal computing services remove this friction for application level developers. By abstracting these services, companies can focus their resources on excelling on application development.

There is a broad, long tail market available for horizontal computing service providers. The current main players in the market are Amazon, IBM, Google, Microsoft, Yahoo!, Akamai, Apple, etc. We’ve seen each of these companies release products that endeavor to capture some portion of the horizontal computing service market.

There are a couple of reasons that these companies are the ones to jump into this market, as opposed to newer, start-ups in the space. These are all giant companies who have established some form of these services to solve problems for their own internal purposes. The work that’s been done to date has largely been the open-sourcing, or exposing of these services that are used internally by these companies to the rest of the world to take advantage.

Another reason is that the cost of establishing one of these services in inevitably quite high up front, and is unlikely to be achieved by initial private investment. The cost of operating such large and massive services over time is going to mean diminished margins as well. I would be surprised if in 5 years there are any more than 3 or 4 major players in each of the horizontals mentioned above.

As a result, any player that is going to try and establish itself in this market over the next 5-10 years is going to have to differentiate itself in order to succeed. Here are four key traits that will allow providers to stand out to consumers:

  • Metric granularity. Presumably, the primary business model for horizontal services will center around utilization. The more a user utilizes a service the more they will have to pay. Extremely granular reporting and metrics on usage will be valuable to a user to determine how they can utilize the service efficiently.
  • Free for entry level usage. Basic level usage of a service should be free. A key to long term market domination will be to allow developers to use the services for free, and begin talking money when low thresholds are hit. Free services will be tested out and played with by developers more. And once they start developing a tool for a service, they are more likely to stick with it.
  • Utilize object-oriented principles. Overloading, extensibility, modularity. These are key principles of object-oriented programming, and should be key elements for a horizontal computing service. A service provider can develop a robust API, but they should allow application developers to inject their own specific logic into the service level API by making it extensible for the developer. This has the advantage of flexibility and power for the application developer, and may lure them into the unwitting position of locking themselves into your system.
  • Services need to be interoperable. Amazon’s storage service is compatible with Google’s processing service, and this is the way it should be, even though Amazon offers a competing service. It allows the developer to build their application for hte best-of-breed services. An all-or-nothing locked-in service stack is little more than a distributed dedicated server with metered pricing.

What else do “cloud” computing services need to offer, both to set themselves up as the platform of choice for the next generation of applications, but also to set themselves apart amongst their competitors?

→ 2 CommentsCategories: Technology · Web 3.0
Tagged:

First Impressions on the New iPhone

July 15, 2008 · Leave a Comment

I’m finally an iPhone customer. My wife and I spent Friday morning in line and got the last two white 16g models that the store had. Here are a brief overview of my impressions both good and bad:

– 3G is a game changer in the mobile market. Having this speed of connectivity available opens up all kinds of possibilities for mobile computing. It underscores the importance of using broadcast spectrum for all carriers, public and private, to create a level playing field where carriers and manufacturers can innovate. Once we can move across the country or globe on a standard network and receive truly uninterrupted high speed mobile connectivity our communications experience will be transformed. The iPhone 3G gives us the first glimpse of that

– Disappointed in the lack of syncing for Notes, To-Dos, and calendars that are auto-generated by notes. This just feels like Apple hasn’t caught up with the little features. I can understand that for a 1.0 release, but not the 2.0 release. I’ve been syncing notes and To-Do lists with my phone for almost four years now, ever since iSync first came out, first on my Nokia and then on my Sony Ericcson phones.

– Location services are awesome, but the functionality is spotty. Every now and then the phone fails to geo-locate me. In order to fix this the phone has to be restarted. This happened to Chandra out of the box. At first we thought her GPS was broken, but after reading up and finding that the phone uses multiple methods to geo-locate we realized it was probably a software problem.

– It’s almost passe to mention this, because it’s so obvious, but the iPhone is the platform for mobile development now. I know that Apple probably won’t do this, but I think they should begin looking into licensing the SDK to other phone manufacturers. This will give app developers greater reach. It would increase the customer base for the App Store, iTunes, and the user base for Safari. This increased software user base would probably lead back after several years to increased purchases of Apple hardware.

– Satellite radio should be scared. With Pandora and Last.fm on my iPhone, I now have personalized radio stations with more interactivity for free or dirt cheap anywhere that I have coverage. Broadcast radio is so dead it’s not even worth mentioning. But why would I plunk down money for satellite radio now? Because it gets coverage where 3G doesn’t. As coverage increases this reason will go away.

– Docking with a separate computer is a hassle. I don’t mind that I can only sync with one iTunes library. But I should be able to connect my iPhone to a different computer, not sync it, and use that computer to enjoy the media on my iPhone without lots of threats of erasing my iPhone. If the phone is already synced with one iTunes library, just don’t try to do any sync activity with a new computer unless I manually prompt it.

Given the mix of positive and negative here, I’m really hoping that Apple moves to a more iterative release cycle for the base software of the iPhone. Roll-out enhancements and improvements for things like To-Do syncing and more reliable location services. Don’t try to shove it all into a major massive release once a year.

Looking forward to a lot of mobile computing and media.

→ Leave a CommentCategories: Technology
Tagged:

Find the HDTV Antenna that’s right for you

June 29, 2008 · Leave a Comment

I read an article this morning talking about how HDTV picture quality is better over-the-air (OTA) than it is through cable or satellite TV. This is generally because it’s not compressed as much.

I’ve had OTA HDTV for about 5 years and absolutely love it. The downside of OTA signals is that they can break up in bad weather, or if the signal requires a semi-directional antenna to pick it up. This can be doubly frustrating when paired with a TiVO or DVR device. If you have an indoor antenna that’s pointing the wrong way and is recording something, your playback is going to suck.

AntennaWeb is a web site helps take some of the uncertainty away. Enter in your address and it will output information about the channels available in your area, the type of antenna best suited to receive those channels, the distance from your house, the compass bearing, and the HZ frequency assignment!

This site has already convinced me that I should get a new multi-directional antenna, as opposed to the semi-directional one I have now. No more recording of muddled digital garbage when the antenna is pointing away from the signal tower.

As an aside to this, I find this to be a REALLY clever sales conversion opportunity. If I were a big-box electronics retailer with an antenna inventory, I would add a widget to my site with this same capability. If I’m Amazon, and I know my customer’s address and that they have a history of purchasing HDTV related items, then I would build this feature into my web site. It creates the demand to influence a sale

→ Leave a CommentCategories: Technology
Tagged: ,

Advanced JavaScript: Namespaces, Closures, Self-Invoking Functions, and much, much more…

June 29, 2008 · 8 Comments

In the past year that I’ve been working at Yahoo! I’ve found myself more in the role of UI Developer in web application development.

This involves developing the client-side display, the client behaviors, request and response handling with server-based actions which may interface with a series of back-end or 3rd party services. HTML and CSS are used for content mark-up and styling. JavaScript is used for manipulating the client data and display based on user interaction. AJAX is leveraged heavily to interact with services. A Java based action layer sits on the server and acts as the controller for request dispatching, and interfacing with various services.

Given JavaScript’s heavy usage in this structure, I’ve learned a lot about JS limitations and powers. For years I generally avoided doing any kind of development that relied heavily on JavaScript. It’s implementation across browsers was disparate, and errors were impossible to debug. Things have obviously improved drastically in the past few years.

An increased usage and reliance on JavaScript means it’s very important to write “enterprise-level” code in a language that doesn’t always assist you the way Java or Python do in this task. One of the things I’ve always disliked about JS is its confusing variable scoping.

This article will cover a series of concepts in advanced JS usage which can help developers avoid problems caused by poor scoping. These concepts include:

- Namespacing
- Self-Invoking functions
- Closures

First, let’s cover the concept of namespacing in JavaScript. Normally, you can define variables in JavaScript in two different methods:

myFirstVar = "some value";

var mySecondVar = "some other value";

In the case of myFirstVar, this is a global variable, no matter where you define this it will be available to all other JavaScript code in the page/screen where it occurs. Using this method to declare variables is extremely messy. With large applications you can easily eat up a lot of memory if you’re declaring global variables all over the place. Also, there’s a strong chance that during the execution of your code, you will encounter a collision where the same variable is getting used for different intended uses.

The second case: mySecondVar uses the “var” keyword to limit the scope to the current executing block of code, and all blocks of code within the current one. If mySecondVar was inside of a function or a conditional block, then it would be local to those blocks of code. In the case above, it’s essentially another global variable.

To avoid polluting the global scope, we’ll use an object structure with a semantic naming pattern to store all code that we need available on a global scope, but we’ll run much less risk of code collision and we’ll have a smaller memory footprint.

Let’s pretend we’re writing code for dgmlive.com. We’ll create a global JS object called DGM:

var DGM = {};

We can add functionality as children to this object. We could for instance create a series of objects that correspond to data entities that we use in dgmlive.com, and those objects would contain data and behavior specific to those entities. Examples include:

- DGM.Artist
- DGM.Recording
- DGM.util.DownloadConfirm
- DGM.widget.MediaPlayer

Now, we’re still going to have situations where we’ll want to declare variables that don’t naturally fit into a namespaced object structure. But we don’t want those variables to have a global scope. This is where self-invoking functions come in.

Normally in JavaScript, you define a function at some point in your script, and later invoke it. With a self-invoking function, it’s executed when the definition is parsed by the browser / client. Variables declared inside of a self-invoking function using the “var” keyword only have a scope local to that self-invoking function. Here’s what a self-invoking function looks like:

(function() {
    // All your JS code goes in here
})();

A functional example:

(function() {
    var myThirdVar = "Try to get at this outside this function";
})();

alert(myThirdVar); // undefined

Let’s take these concepts further and incorporate some object oriented programming principles to our JavaScript code that aren’t explicitly provided for with basic JavaScript.

Let’s build a basic version of the proposed DGM.Artist object. Here’s the code:

var DGM = {}; // only global property, the root of our namespace

(function () { // Self-invoking function

/**
* Creates a new artist object
*
* @param Object an initial configuration for this artist
* @constructor
*/
DGM.Artist = function(
/* Obj */		oConfig
) {

    // Define private members
    var _name = oConfig.name;
    var _givenName = "";
    var _surName = "";

    // Private logic method
    // A not-so-good way of getting first and last name from a single name
    var _splitName = function(name) {
        var names = name.split(" ");
        _givenName = names[0];
        _surName = names[1];
    };

        return { // publicly accessible API

            getName : function() {
                return _name;
            },

            setName : function(newName) {
                _splitName(newName);
                _name = newName;
            },

            getGivenName : function() {
                return _givenName;
            },

            getSurName : function() {
                return _surName;
            }

        };

    };

    var robertFrippConfig = {
        name : "Robert Fripp"
    };

    var newArtist = new DGM.Artist(robertFrippConfig);

    alert(newArtist.getName());
    alert(name);
    alert(givenName);

    newArtist.setName("Bobby Willcox");
    alert(newArtist.getName());
    alert(newArtist.name);
})();

Ok, there’s a lot there. Let’s walk through it a little at a time:

var DGM = {};

That’s the start of our namespace object. We’ll add children to it and avoid polluting the global namespace.

We then start a self-invoking function:

(function () {

It’s not really necessary to wrap the declaration of DGM.Artist in a self-invoking function, since this is just going to have the same scope as DGM, but it’s a nice touch. We do need the self-invoking function to contain the instantiation of DGM.Artist.

We declare DGM.Artist as a function, but we’re going to use it as an object constructor. It returns an object with a specific sub-set of functions that we want to make publicly accessible.

	DGM.Artist = function(
		/* Obj */		oConfig
	) {

        ...

        return { ... };

We create an instance of DGM.Artist using the new statement:

var newArtist = new DGM.Artist(robertFrippConfig);

Now let’s look closer at DGM.Artist. JavaScript doesn’t support different traditional OO member accessibility (i.e. public, protected, private). But we can use the “var” keyword and JS scoping to our advantage in this instance.

Variables declared with “var” inside of DGM.Artist constructor method are local to that method, and not accessible to JS outside of the method. However, the variables themselves persist inside each instance of that object. So, we can use traditional accessor methods (getters/setters) to manipulate those variables from outside. This behavior is called a closure.

This gives the programmer some power over how an object’s properties are manipulated during run-time. However, this shouldn’t be construed as any type of security measure to protect sensitive data.

So, getting back to the example, we set up a series of private variables which will contain data for each instance of DGM.Artist that we create:

                // Define private members
		var _name = oConfig.name;
		var _givenName = "";
		var _surName = "";

I’ve used the convention of putting an underscore in front of the member names. This does nothing other than visually indicate to the programmer that these are intended as private variables.

In the return block of the constructor method, I build an object which has a series of methods which can be used to manipulate these private variables after the instance is created:

return { // publicly accessible API

			getName : function() {
				return _name;
			},

			setName : function(newName) {
				_splitName(newName);
				_name = newName;
			},

			getGivenName : function() {
				return _givenName;
			}, 

			getSurName : function() {
				return _surName;
			}

		};

Take a look for a moment at the setName() method. This is used in the instance to change the name of the artist if necessary. Inside of setName() we call a private method _splitNames() defined in DGM.Artist constructor, which takes our name string and splits it into a given and a surname.

===

I hope this gives you some sense of how to avoid scoping problems in your JavaScript development, and also gives you some sense of how to use closures and object-oriented JavaScript to unleash some of the power that JavaScript has available.

→ 8 CommentsCategories: JavaScript · Tutorial
Tagged:

URLs as Sentences

March 14, 2008 · Leave a Comment

I was reading Chris Shiflett’s blog today and found out that Omniti.com just updated their web site, and instituted a really clever approach to URL mappings. Instead of using them to mirror the hierarchical file structure of their applications, they’ve constructed simple, grammatically correct sentences like http://omniti.com/is/hiring.

Given the fact that most enterprise-level web sites are re-writing URL requests and delivering the information to an application on the back-end, there’s little need to reflect any type of file structure in URL addressing any more. It would be interesting to see if this were implemented on a wider basis, whether it might have a broader effect on finding information across the internet.

Most search activity on-line is geared towards filtering based on relevant content. But, addressing a service or commodity in this manner on-line might give users a stronger tool in locating information and products that are relevant to them.

→ Leave a CommentCategories: PHP

My First Experience with Silverlight

March 2, 2008 · 1 Comment

This afternoon I decided to check and see if I could catch a Cubs spring training game on MLB.TV.

Once I navigated to the day’s viewing schedule and clicked to watch the live contest vs. SF. I was surprised that I was given the option to download Microsoft’s Silverlight software so that I could use a media player built with Silverlight. One of the advertised features was that it was Mac compatible.

While MLB.TV has always been mac compatible to some degree, it’s been woefully lacking versus what the windows version felt like.


MLB.TV Silverlight Example

I was pleasantly surprised by the speed and features available in the player. The line score and box score have been added as widgets next to the video player. Mousing over the video gives you options to resize the video. Overall the speed and responsiveness of the video are strong.

The video itself still appears to be using Microsoft’s WMVcodec. At 400k it’s pixel-y and choppy.

The plug-in installation was relatively painless. I wasn’t prompted to select which browsers will use the plug-in. I simply installed the Silverlight application, then restarted by Flock 1.1 beta and right away it was able to play the silverlight application in Flock.

Yesterday, I downloaded the new Adobe AIR SDK and the trial IDE. In terms of RIA platforms, I’m more interested in Adobe’s AIR at this point, mainly because I’m somewhat familiar with Flex and ActionScript. But Silverlight’s support for JavaScript and Ruby might compel me to give it a try.

In the end, it’s unfortunate that there isn’t a true standards-based platform (coming out of W3C DOM and ECMAScript) that can compete with these proprietary offerings. Adobe’s open source release of the Flex SDK gives them the edge on this front, and for open source developers, it makes AIR a more attractive platform. Of course, Silverlight’s .Net integration makes it much attractive to developers who are wedded to the MS platform.

→ 1 CommentCategories: RIA · Technology

Flock Adds Webmail Integration

February 22, 2008 · Leave a Comment

Well, I’m about a week behind the times on one of my favorite web 2.0 softwares, Flock. They’ve just released a 1.1 beta that includes a number of new features. Most notably, there is now support for Yahoo! Mail and GMail in the browser.

You can grab the beta here (fair warning: the account set-up won’t last when the “official” release is out).

I know this isn’t much of a post, and I’ve been neglecting this blog since I started it. So this post is a bit of a concession.

→ Leave a CommentCategories: Web 2.0

WordPress Misses Opportunities

January 27, 2008 · Leave a Comment

So, when I started this blog this morning. I knew off the bat that I didn’t want to set-up and manage another wordpress installation on my own host. Primarily because I don’t have SSH access on my host, and having to update wordpress over passive FTP every time there’s a new release is a real pain.

I then checked to see if sparecycles.wordpress.com was taken. It wasn’t so I set it up. I’ve been toying with the configuration on and off during the day.

One of the things I love about wordpress is its external API that allows developers to create widgets and plug-ins to easily incorporate features and content from other services. There are thousands of these. But apparently they are only for plugging in to the downloaded software version, and not the wordpress.com blogging service.

Additionally, I have to pay an upgrade fee in order to manually modify the theme that I have applied to my account.

This seems like a real loss for the service.  I haven’t read much criticism on this, but I’m assuming the decision behind this lies in security. I can see wordpress being very cautious or resistant to hosting third party content on their servers. But with a cautious approach and some ingenuity I would think that some of these limitations could be overcome.

WordPress.com, given the underlying software and community, has the position and power to become the Facebook of blogging services. The apparent lack of user-powered creation and customization is a missed opportunity.

Of course, I’ve only been playing with this for a few hours. So there may be a way, but it’s not obvious through the admin interface, which would be a different kind of loss.

→ Leave a CommentCategories: Technology