Loose Coupling

I’m enjoying reading Nicholas Zakas’s Professional JavaScript for Web Developers – in particular chapter 24 – “Best Practices.”  One of the places where I would like to do a better job is in bringing some of the loose coupling techniques I’ve used at previous shops to my new work.  In the realm of Web Development, Zakas’s assertions include:

Decouple HTML/JavaScript

“One of the most common types of coupling is HTML/JavaScript coupling… each represent a different layer of the solution: HTML is the data, and JavaScript is the behavior.  Because they are intended to interact, there are a number of different ways to tie these two technologies together…. JavaScript that appears inline in HTML…is too tightly coupled….. HTML and JavaScript can also be too tightly coupled when the reverse is true.”

“This…has to do with keeping the layers separate and being able to easily identify the source of errors.”

“Markup can be included and hidden when the entire page is rendered….  Another approach is to make an Ajax request to retrieve additional HTML to be displayed.”

Decouple Application Logic/Event Handlers

“An event handler should interrogate the event object for relevant information and pass that information to some method that handles the application logic.” (This makes it easier to debug if the problem is in the event handler or in the application method – and you can invoke the application method independently.)

Sublime Home and End Keys

So, I just bought a full size Apple keyboard for my setup and I’m loving having Page Up and Page Down keys again.  By default Sublime doesn’t have Home and End mapped though.

I found this article and added these lines to Preferences > Key Bindings – User to enable Home and End:

{ "keys": ["end"], "command": "move_to", "args": {"to": "eol"} },
{ "keys": ["home"], "command": "move_to", "args": {"to": "bol"} }

and now all is right with the world, or at least Sublime 🙂

A Magazine Called Rainbow

Ah, back in the days when magazines would arrive with programs for you to type in (when you were too cheap to buy the cassette or floppy disk).


And my personal contribution to that issue 🙂   (The code went on for another page or two.)