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 Related:  Vancouver, BC

Send json HTTP post with bash JSON to JSONP: Bypass Same-Origin Policy Download source code - 39.3 KB Introduction In my last article (Prepare a JSON Web Service and access it with JQuery), I had explained JSON, how to return JSON data from a Web Service, and how to use a JSON-enabled Web Service with JQuery. In this article, I will explain how JavaScript Object Notation with Padding (JSONP), an extended concept from JSON, can be used to solve cross domain issues. What and why JSONP? AJAX is a key technology in web 2.0 that is being used widely in web sites. Same-Origin Policy Same-origin policy is a concept in browser-side programming languages (such as JavaScript) which allows accessing resources in the same site (same domain) but preventing accessing resources in different domains. Use a Proxy Web Service As XMLHttpRequest (in AJAX) doesn’t allow cross domain calls, the common approach is to use a proxy Web Service to access third party data. Figure 1: Using a proxy Web Service to access data from a different domain Use IFrame How JSONP works? References

Deep Habits: The Importance of Planning Every Minute of Your Work Day December 21st, 2013 · 153 comments Time Blocking The image above shows my plan for a random Wednesday earlier this month. Notice that I leave some extra room next to my time blocks. I call this planning method time blocking. This type of planning, to me, is like a chess game, with blocks of work getting spread and sorted in such a way that projects big and small all seem to click into completion with (just enough) time to spare. Three Concerns Sometimes people ask why I bother with such a detailed level of planning. Sometimes people ask how time blocking can work for reactive work, where you cannot tell in advance what obligations will enter your life on a given day. (Another smart strategy in this context is to give open-ended reactive blocks secondary purposes: e.g., “process client requests; if I have downtime during this block, work on project X.”) Sometimes people ask if controlling time will stifle creativity. Conclusion

How To Stop Being Lazy And Get More Done - 5 Expert Tips Before we commence with the festivities, I wanted to thank everyone for helping my first book become a Wall Street Journal bestseller. To check it out, click here. Some days the to-do list seems bottomless. Just looking at it is exhausting. We all want to know how to stop being lazy and get more done. So I decided to call a friend who manages to do this — and more. Cal Newport impresses the heck out of me. He has a full-time job as a professor at Georgetown University, teaching classes and meeting with students.He writes 6 (or more) peer-reviewed academic journal papers per year.He’s the author of 4 books including the wonderful “So Good They Can’t Ignore You.” And yet he finishes work at 5:30PM every day and rarely works weekends. No, he does not have superpowers or a staff of 15. Below you’ll get Cal’s secrets on how you can better manage your time, stop being lazy, get more done — and be finished by 5:30. 1) To-Do Lists Are Evil. To-do lists by themselves are useless. Here’s Cal: Sum Up

Green Tea Press: Free Computer Science Books free-programming-books/free-programming-books.md at master · vhf/free-programming-books Productivity Hacks From Startup Execs 6 Things The Most Productive People Do Every Day Ever feel like you’re just not getting enough done? Know how many days per week you’re actually productive? About 3: People work an average of 45 hours a week; they consider about 17 of those hours to be unproductive (U.S.: 45 hours a week; 16 hours are considered unproductive). We could all be accomplishing a lot more — but then again, none of us wants to be a workaholic either. It’d be great to get tons done and have work/life balance. And who better to ask than Tim Ferriss, author of the international bestseller, The 4-Hour Workweek? (Tim’s blog is here and his podcast is here.) Below are six tips Tim offered, the science behind why they work, and insight from the most productive people around. 1) Manage Your Mood Most productivity systems act like we’re robots — they forget the enormous power of feelings. If you start the day calm it’s easy to get the right things done and focus. Here’s Tim: I try to have the first 80 to 90 minutes of my day vary as little as possible. Research shows email:

Related: