2011.09.30

AMD is better for the web than CommonJS modules

I’ve seen a few libraries and tools later using different kinds of ways to
handle dependency management, some of them are very similar to the way that
CommonJS modules looks like:

Read more…


2011.09.03

Single entry point redux

A couple months ago I posted about using a single entry point for JavaScript applications and how it could simplify the HTML logic and also make dependency management easier. A couple people asked if I had some example and the only examples I had were client projects which I couldn’t share the source code…

I’ve just answered a question on the RequireJS mailing list and used a Gist to explain how single entry point works and how it improves the code structure and simplify dependency management.
Read more…


2011.05.19

Crossroads.js: JavaScript Routes

The project isn’t that new anymore and was already featured on a couple places but I think I should also create a post just in case someone missed it and also to register the release.

Crossroads is basically a routing system used to map strings to functions (usually URL fragments), it acts similar to a pub/sub (event listener) but uses Regular Expressions and dynamic string patterns to identify listeners. The main feature is the robust and flexible string validation/match/parsing system.

The greatest advantage of Crossroads when compared to other similar libraries is that it is not directly tied to server requests (in case you are using it on the server-side) or to the window.location (if you are on the browser). Another important advantages are the flexibility and the support for advanced use cases, provided by different kinds of validation rules and multiple listeners to each route. – It gives you flexibility to do any kind of action you want and doesn’t do anything you don’t ask it to do.

Check the project page and examples to know more about it. It can be specially helpful for large websites and single page apps – as I mentioned on my previous post.

I hope you enjoy, contributors are welcome.


2011.05.09

Single entry point FTW!

Many programming languages and environments require a Main Class, Main function or Main file as an entry-point to the program, it’s where the execution starts and also usually where you have access to command arguments. JavaScript on the browser isn’t one of those environments tho, and I think it is one of the reasons why many applications become a real maintenance nightmare. I believe that the “Main File/Function/Class” approach can help a lot to increase extensibility/maintainability and favor a good structure even for languages that doesn’t require this practice.

Many back-end frameworks started to adopt this technique over the past years, most of them have some sort of URL redirect that points to a “index” file or a router that decides which actions should be executed and which files should be loaded instead of having a single file for each page or section. This kind of abstraction increases flexibility a lot since you can just keep adding new pages/sections/features without having to care about the code structure, it also reduce code duplication since you don’t need to create a new file for each new page…

Flash projects have a Main Class which is the entry-point for the application and also works as the root node where all the child elements are attached (similar to the body element of an HTML file) and it helps you keep the code flow organized since you are sure that your Main Class constructor is executed before any other code, programs get easier to understand since it follows a logic order.
Read more…


2010.11.28

JS-Signals: Custom event/messaging system for JavaScript

I’ve just released a new open source project called JS-Signals. It’s an event/message system similar to pub/sub and DOM2 Events but that doesn’t rely on strings to broadcast/subscribe to events, it has also some extra features that usually aren’t available on the other systems.

JS-Signals was heavily inspired by Robert Penner’s AS3-Signals but it is NOT a direct port, which means it has a different implementation and features. I’ve also stolen borrowed a few ideas from Joa Ebert fork ;).

Make sure you read the comparison between the different event systems and the usage examples.

Download it and get more info at http://millermedeiros.github.com/js-signals/.

Ideas and contributors are welcome!