Oct 292014

Web_programmerOver the past year I have had several projects at work (I feel like a real live consultant now) and I have used a few new technologies and tools on those projects. The skills that have really come a long way are my JavaScript skills.

I know what some of you might be thinking, “WTF, JavaScript?!?”

Yes. JavaScript. It’s not as cumbersome and taboo as it was back in the 90s. There are new tools and frameworks out there that have actually made JavaScript not only easier but … dare I say it … fun?! The library that has made JavaScript easier, for me, is jQuery, which I have been using for a couple years now and I won’t write any JavaScript without it. There are two frameworks that I have played around with recently that have really made JavaScript kind of fun: Knockout and AngularJS (I know these are not the only two but they are the only two I have spent any time using).

I think I have gone on before about how much I enjoy the magic behind jQuery. I even saved a few on snipplr which have had a few strangers favorite, although I could probably improve on most of them with the newer versions of jQuery. Using jQuery will definitely make your web page feel very dynamic and that seems to be the paradigm we are going for these days. A “web site” is quickly becoming a legacy term and we are evolving into developing “web apps” – which is essentially a website that functions as if it were something running on your desktop (instead of in your browser). I’m sure the evolution and massive adoptions of tablets and mobile devices has been a major catalyst.

The jQuery syntax and plethora of plugins really makes developing web apps much easier and adds a level of enjoyment to it. In fact writing your own jQuery plugin doesn’t require any additional software or new syntax, they are still js files that just use existing jQuery syntax. I have yet to write one myself, but I really want to, someday … if I can think of a worthwhile plugin to write. I have noticed a drawback about jQuery lately; the more complex you make your page the more JavaScript you have to write. I have a couple of sites where there is more JavaScript code then actual markup and trying to find a specific function to modify can be an exercise in perseverance. When JavaScript code becomes increasingly verbose, that’s when frameworks like Knockout and AngularJS come in handy.

I’d like to go on about Knockout and compare it to AngularJS but I haven’t spent a lot of time recently enough with Knockout and I have spent quite a bit of time the past couple of weeks with Angular. I mostly started looking into Angular because its one of those terms that has been mentioned quite a bit around the office. Many folks have talked a lot about using it and it has been implemented at my next assignment. I wanted to go beyond just watching the Pluralsight videos and reading the tutorial on the website. I wanted to see if I can get it working on a website. Therefore I made one of my websites the guinea pig 🙂

Angular uses “directives”, which are essentially special attributes added to HTML tags that only mean something to Angular which tell Angular where it will be applying changes or reacting to events. While you can still use jQuery to handle some of your pages events, in Angular the controller will contain the majority of the code that needs to be executed. It does add a bit of brevity to your html pages.

If you have done any development using the MVC pattern your attention may have latched onto the word “controller”. In Angular you are essentially using an MVC pattern (although you will often see it referred to as MV* when folks speak of Angular). Your controllers are still written in JavaScript but I often create a controllers.js file and keep all my controller code there. Therefore, if you need to make a change to some logic and you know its going to be in a controller, it will be easier to find the bit of code you are looking for to make your change. No more scrolling through lines of JavaScript code, or hitting Ctrl-F to find a specific function (unless you are using several controllers, in which case I would encourage you to create multiple controller files).

I’ve only really just begun to dive into Angular and I’m already enjoying its power and brevity. As I continue to witness and invoke its prowess I’m sure to be inspired to write some more, however I’ve run on enough for now but I encourage you to check out all of the things I talked about (if you haven’t already).

minion_keboard_smI could get so much more accomplished if I only had minions!

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>