Hugoware

The product of a web developer with a little too much caffeine

Archive for April 2009

Whatever Happened To Try Before You Buy?

leave a comment »

Something that drives me nuts is having to pay for something before you can check it out. Normally in an actual store this is no big deal. You can try on clothes before you buy them. You can try out different electronics before you commit.

But why is it that software, especially websites, expect you to sign-up before you see their product? Why do you rarely find ‘demo’ versions of software anymore. Why do I have to commit before I can see what I’m getting?

That’s something that’s always bugged me. I’ve wasted money on console games and BlackBerry games just to find that they don’t work as advertised.

That was something I wanted to make sure to avoid with jLinq. How can I expect anyone to want to download and figure out yet another Javascript library without any help? People want to see the benefits of a product before they commit their time (and money) to it.

The jLinq demo page is geared to help people see the immediate power of the library without making them setup a site or build test data just to see how it works. The page is not only littered with examples, but each of the examples has a button to click on and run it right away.

Now granted, this isn’t exactly the usability that Steve Krug would brag about, but it takes a step in that direction.

Why is the software world forcing the buy before you try mentality?

Written by hugoware

April 30, 2009 at 1:03 am

Just What Is jLinq?

with 7 comments

A while back I had a project that required a lot of sorting and selecting of information that pretty much wasn’t going to change. I started out by writing a couple sorting functions and all was good.

But as any developer knows, the requirements began to change and sorting alone wasn’t good enough. Steadily, the requirements went from sorting by type, to sorting by type or name, then type, name or date…

Sooner or later I had to start including query terms in each of my sorting functions! Quite literally all of my efforts had been wasted. My only thought was “this would be so much easier with LINQ”… 

And why not? It was a perfect candidate. And so with some effort, jLinq was quickly born.

Now you may have noticed, this isn’t the first project like this. Some people have put together some neat little query languages, like JSLINQ. What sets jLinq apart is simplicity and extensibility.

A lot of examples of other query languages I’ve found look something along the lines of…

var result = new JSLINQ(records)
  .Where(function(r) { return r.Age < 5 && r.Name == "Jim" })
&#91;/sourcecode&#93;

I'm not picking on JSLINQ, but to me it seems a lot like using the code below...

&#91;sourcecode language='jscript'&#93;
var results = &#91;&#93;;
for (var item in records) {
    if (records&#91;item&#93;.Age < 5 && records&#91;item&#93;.Name == "Jim") {
        results.push(records&#91;item&#93;);
    }
}
&#91;/sourcecode&#93;

I'm making some unfair assumptions here, don't let my explanation drive you away from JSLINQ. I've haven't used enough to critique how it works. I'm basing this off of code samples I've seen.

Regardless, I wanted jLinq to focus on a couple things...

<h2>Simplicity</h2>
jLinq focuses more on writing your comparisons in advance, for example, consider the command 'greater()'. It is used like the following...


.greater("nameOfField", someValue)

But the command checks all of the following…

  • If the field is a number, is the number greater than the value provided?
  • If the field is a string, is the string length greater than the value provided?
  • If the field is an array, is the element length greater than the value provided?
  • If it is anything else, just try (field > value)

The specifics of how those values are checked remain hidden in the command allowing better abstraction for queries.

Secondly, because queries tend involve more than just one comparison, jLinq has methods such as ‘or()’, ‘and()’ and ‘not()’ that all work with extended functions automatically.

Extensibility

It’s a good day when a programmer realizes they can’t make a project the best it can be on his own. Extensibility was built into jLinq from the start. In fact, the entire jLinq core library is built from extension methods! This way developers can create share their jLinq functions and libraries with others!

jLinq allows you to extend upon the existing jLinq library, extend into separate namespaces on the jLinq library or even create your own jLinq library from scratch (for example, a jLinq/jQuery library is in the works).

Extending  jLinq is simple. Consider we wanted to add in a pre-built function for even numbered values.

jLinq.extend({
  name:"isEven",
  type:"query",
  count:0,
  method:function(query) {
    return ((query.value % 2) == 0);
  }
});

And then accessed within a query like…

var results = jLinq.from(records)
  .isEven("age")
  .select();

Now here is the scary part…… that is really about as hard as it gets!

I’ll blog more about the full detail of jLinq, but as for now please ask me any questions that are on your mind!

Written by hugoware

April 28, 2009 at 3:35 am

jLinq – Going Online!

with one comment

This blog is focused on being about general development along with a lot of discussion about my projects I’m currently working on. I’ve cleared out all of my other blogs and created this one so it can be a broader discussion about development than the others could be.

jLinq is the main project I’ll be posting about for now. jLinq is similar to LINQ for .NET, but it is used in Javascript. It’s especially useful for working with medium sized arrays of information that won’t be changing.

Most of the time people use AJAX to make calls to their server and download the information they need. jLinq allows you use many of the same functions you use in LINQ, but against existing data on the page. 

One of the most important parts of jLinq was that I wanted it to be easy to extend. In fact, at one point the whole jLinq library was wiped and started over and built around an extensibility framework! I wanted the extensibility to work so well that even the core functions of jLinq was built around it!

I’ll blog more about using jLinq, but for now the best thing you can do is try it out on my website! Please leave me feedback about what you think!

Documentation is still in progress, but there are a lot of handy tutorials that will get you started!

Written by hugoware

April 26, 2009 at 5:46 am