HN user

daniellmb

32 karma

Senior Front End Engineer, JavaScript Architect and Entrepreneur

http://www.linkedin.com/in/daniellamb

[ my public key: https://keybase.io/daniellamb; my proof: https://keybase.io/daniellamb/sigs/NTfD3BXKOmdq_TzXtWdijidndb-Ojv0adW5XFPXCMsM ]

Posts4
Comments6
View on HN

She's already on an iPad why not use the built-in "Reader View" in Safari? This is exactly why it was built, to simplify web pages for reading. No need to build a custom solution to reformat websites.

If you already understand both jQuery and AngularJS, it may seem a little silly to compare them. Like comparing a motor to a car. Yet, this article will help those that know about jQuery, and want to learn more about the strengths AngularJS has to offer. Specifically, the comparison shows what both of these tools are good at, and empowers you to know what one best fits the needs of your application.

There are a several factors that will help you decide whether or not to use AngularJS. In my opinion it's not so much how complex the user interface is, although that is certainly relevant. The first thing to consider is where you want to put your application logic, server-side or client-side. The more things you want to push down to the client, the more likely AngularJS will better fit your needs. Are you creating a single page application where url-to-resource routing is done in JavaScript, or will that be handled server-side? Will you be merging data with templates on the server, on the client, or both? I suggest you look at the "too long; didn't read" chart in the article, and see if you need the features AngularJS provides. How important is it to you that your client-side code is testable? While it is possible to unit test jQuery code, the way most developers write nested callbacks tightly coupled to event handlers, does not lend itself easily to isolated testing. Finally, you need to decide if your team wants to embrace the declarative style of application development advocated by AngularJS. Such as using the directive ng-click vs. $(elm).click(). This will most likely require a change in mindset, and should be carefully weighed.

Using the NODE_ENV is nice simple solution but when you need more there is a great dependency injection module called rewire that adds a special setter and getter to modules so you can modify their behavior such as: inject mocks for other modules or globals like process, leak private variables override variables within the module.

This is especially nice because you don't need to add any special if statements to the module code you just load your module under test using rewire instead of require.

// file: test-stats-rewire.js

var rewire = require('rewire');

var assert = require('assert');

var stats = rewire('./stats');

// leak private method sum for testing

var sum = stats.__get__('sum');

assert.equal(sum([1]), 1);

assert.equal(sum([1, 2, 3]), 6);

Great start! Here are a few other books I've read recently and marked the crap out of because there is so much good information in them.

  - JavaScript Patterns by Stoyan Stefanov
  - High Performance JavaScript by Nicholas C. Zakas
  - High Performance Web Sites by Steve Souders
  - Even Faster Web Sites by Steve Souders
Here are a few I haven't read yet but are on my to read list.
  - Object-Oriented JavaScript by Stoyan Stefanov
  - Pro JavaScript Design Patterns by Dustin Diaz, Ross Harmes