A Better setTimeout

If you’ve ever used JavaScript’s setTimeout and setInterval methods. you’ve probably found them just a bit … inadequate.

  • Both return an integer rather than an actual handle.
  • If you’re using both setTimeout and setInterval, you have to remember whether the integer value is a timeout or an interval in order to call the appropriate clearXXX method.

Continue reading

Advertisement

Defining Return Objects in Javascript

… or, Prefer this scope to closure scope, Prefer stub scope to this scope

JavaScript is a very flexible language like Perl, and so gives you many ways to carry out the same task. Take something simple like writing a function that returns an object. How many ways can you think of to do that?

If you’ve heard of the Module Pattern, you might think that this is a well-settled question. But the Module Pattern gives you lots of leeway in implementation. In this post I’ll take away most of that wriggle room.

Continue reading

Reflections on NationJS 2013, part 1, the Morning Sessions

My morning began pleasantly with an easy drive from Columbia to Silver Spring. Kudos to the House Republicans who shut down the federal government just so I could have a faster commute to NationJS! I can’t say how much I appreciate having congressman who know how much I hate sitting in traffic and are willing to go to such great lengths to convenience me. As I write this now, it’s been nearly two weeks of the shutdown. I guess I forgot to tell my Tea Party friends that NationJS was only one day.

This very first NationJS was being held at the Silver Spring Civic Center, right next to the Silver Spring Metro Station. I parked right across the street for $1 an hour. Probably not the cheapest spot, but it won’t break the bank.

Breakfast was provided — muffins, bagels, coffee, juice. Quite a few people were there early, which surprised me. There were also plenty of extension cords, but I’m glad I brought my Haskell laptop, so I didn’t have to constantly worry about trying to find an outlet.

The following are my impressions of the four morning sessions I attended. They are in no way meant to be anything near a complete transcript.

New Rules for JavaScript by Kyle Simpson

Kyle started off the keynote with the statement “I’m known for strong opinions” which was a good sign. He introduced some of the projects he was working on such as

How to Get a Running Start on a Legacy Project

… and Plant the Seeds for Organizational Change

I’m on a contract that may start winding down in a couple of months1, and so I’m starting to both look backwards and forwards to think about what I’ve learned and what I can do better.businessman_with_the_notebook_1 One of the ways that I think I can do better is to change my attitude toward taking on legacy projects.

In the past, I’ve always been fairly picky about my assignments — I choose assignments which will stretch me as a developer. I also use the interview as an opportunity for me to scope out the employer to see if there are any organizational or development process dysfunctionality that will keep me from doing my job effectively. As a result, I usually shy away from legacy projects.

But I’ve grown more confident in my ability to effect change in an organization, and so here are my list of things to do for getting off to a quick start on a legacy project.

Work the Way You Want to from Day One

… even if you haven’t convinced everyone that your way is the right way way

Coming onto a new project, you can’t always work the way you want to. There are legacy anti-patterns you just have to follow if you want to keep your job, and it doesn’t do you any good to be the new guy who’s always complaining. But the good news is you can just add your best practices on top of the bad ones you have to follow….
Continue reading