background preloader

Designing Better JavaScript APIs

Designing Better JavaScript APIs
Advertisement At some point or another, you will find yourself writing JavaScript code that exceeds the couple of lines from a jQuery plugin. Your code will do a whole lot of things; it will (ideally) be used by many people who will approach your code differently. They have different needs, knowledge and expectations. This article covers the most important things that you will need to consider before and while writing your own utilities and libraries. We’ll focus on how to make your code accessible to other developers. Peter Drucker once said: “The computer is a moron.” Table of Contents Fluent Interface The Fluent Interface1 is often referred to as Method Chaining (although that’s only half the truth). Aside from major simplifications, jQuery offered to even out severe browser differences. Method Chaining The general idea of Method Chaining6 is to achieve code that is as fluently readable as possible and thus quicker to understand. Command Query Separation Going Fluent Consistency Callbacks

Teaching my 5 year old daughter to code… | In The Attic So I decided to try and teach my 5 year old daughter some basic logical thinking and development principals. My little girl's shown a keen interest in what I do for a job amongst other things recently. She's a great reader and writer for her age and so I started looking around for a simple scripting language or similar that I could teacher her. Now the thing to remember about kids is this, no matter how smart they are they all have the attention span of a gnat! 3 seconds max, if it's not interesting then they're not interested, period! I spent the next 45 minutes talking to her about how to make the robot move, at first she thought it was a game and that she had to click on stuff but she quickly got the hang of it. Here she is trying to figure out how many squares to make the on-screen robot move. This is the program before script execution. This is the program after execution.

Getting Started with Node.js on Heroku node Table of Contents This quickstart will get you going with Node.js and the Express web framework, deployed to Heroku. For general information on how to develop and architect apps for use on Heroku, see Architecting Applications for Heroku. Prerequisites If you’re new to Heroku or Node.js development, you’ll need to set up a few things first: A Heroku user account. Local workstation setup Once installed, you can use the heroku command from your command shell. heroku login Enter your Heroku credentials. Press enter at the prompt to upload your existing ssh key or create a new one, used for pushing code later on. Write your app You may be starting from an existing app. var express = require("express"); var logfmt = require("logfmt"); var app = express(); app.use(logfmt.requestLogger()); app.get('/', function(req, res) { res.send('Hello World!') Declare dependencies with npm Heroku recognizes an app as Node.js by the existence of a package.json file. Declare process types with Procfile Console

About Put cash bounties on coding tasks and tough tech questions. It's fast and easy. Creating a bounty on a task or question takes place on a single form. Solutions come quickly. High quality solutions. Solutions are publicly visible. Bountify has ultra-low minimums. Bounties on Bountify start at $1, whereas project outsourcing services may start as high as $500. If you receive no solutions, or you aren't happy with those that you did receive, your bounty goes to charity of your choice. Bountify is geared towards programmers, but anyone can use it to post tech questions or tasks.

Developer Network From game jam to mobile and Firefox OS I love participating in game jams, where game developers get together to craft games in a very short amount of time. I thought it would be cool to take one of my past Game Jam games, Metal vs Hipsters, and port it to the mobile web and Firefox OS. Adapting ... Web Push notifications from Irssi Our main communication tool at Mozilla is IRC. I’m running an IRC client called Irssi under screen on a server constantly connected to the network.

Crumble - jQuery Feature Tours Crumble allows you to quickly and easily build feature tours for your website or app using small bubbles! The bubbles are visually interesting, will draw attention and due to the small size make sure that you will write using concise language that visitors will read. The tour itself is defined as a standard ordered list in your html, making it accessible. Demo The demo is running on this page! Check out the source, or read the documentation here to find out more about how it works. Download Crumble can be downloaded from the public repository on github. Crumble depends on grumble.js to generate the bubbles, you can download it here Contact

NowJS and Node.js Tutorial – Creating a multi room chat client | Aditya Ravi Shankar Node.js is a server side environment for Javascript. NowJS is a framework built on top of Node.js that connects the client side and server side Javascript effortlessly. The core of NowJS functionality lies in the now object.The now object is special because it exists on the server and the client.This means variables you set in the now object are automatically synced between client and server. Also server functions can be directly called on the client and client functions can be called directly from the server.All in realtime. You can have a working HTTP server up and running in Node.JS with just a few lines of code. This little snippet of code will create an HTTP server, listen on port 8080, and send back “Hello World” for every request. Using NowJS, communication between the client and server side is just as simple. Client Side: <script type="text/javascript"> now.ready(function(){ now.clientSideVariable = 'someValue'; now.serverSideFunction(); }); </script> Server Side: 1. 2. 3. 4. 5.

The Data Visualization Beginner’s Toolkit #2: Visualization Tools (Note: if you are new to this series, the DVBTK doesn’t teach you how to do visualization. Rather it is meant to help people find a less chaotic and more effective path towards the acquisition of the necessary skills to become a data visualization pro. To know more, make sure to read the introduction to the series first.) The DVBTK #1 introduced books and study material to make sure you acquire the right knowledge in the right order. Studying is the first step and there’s no level of practice that can substitute for it. That said, it is extremely important to realize that good visualization cannot happen without practice. But if you want to do visualization you need some tools right? Here is the guidance. And there is more to come! I felt you needed to know more about each tool, so I decided to interview (at least) one data visualization professional with proven and long-lasting experience with it. Golden Rules of Visualization Tools First of all you need some fundamental rules. Damn it!

Serving Static Files from Node.js Posted: 5/6/2011 12:14 PM In the last post I showed you how to get started with Node.js on Windows. Easy, wasn’t it? Remarkably so since there was no install requirement. Note, for posterity's sake, that all of this is based on node.js as of version 0.4.7. Making Things Easier Last time we got started by unzipping the file that contained all the node files. Computer > Right-click and hit properties > Advanced System Settings (on the left) > Environment Variables > System Variables > Path > add “C:\Program Files\Node” So now the files that we use can be in a directory all their own and you still only have to type “node.exe server.js” to get started. And another tip, keep Fiddler open while you mess around with node. Serving Up A File So starting a server and returning some Html hard-coded in Javascript is awesome like we did last time, but it would be even better if we could do this by serving up Html files. First, let’s create a very basic html page. Serving Up Files And voila!

Related: