Software, life, and random thoughts
Home/Categories/Javascript/

Category : Javascript

  1. I finally got to mess around with PhantomJS and Jasmine, and couldn’t find a resource that gives clear, concise, accurate information, without language specific or build tool specific coupling, so I decided to write it myself. Fortunately, it is way simpler than I thought. PhantomJS PhantomJS is a standalone, cross platform command line application…
  2. A while back I wrote a blog post on coupling and the observer pattern. Looking back, I did a pretty poor job describing what it wrong about it. I will attempt to correct this. We all want simple and descriptive code. Code that is self documented. Code that makes sense, Code that tells us a story. Lets look at a kind of code I have seen many times…
  3. One of the good things about Backbone.js is it doesn’t tell us how to do things. It leaves it for us to decide what are the best practices for writing views (or any components). This is also one of the worst things about Backbone. it makes it almost too easy to take the wrong path, and write views that will be hard to maintain. The principle we…
  4. Code review is one of the most powerful tools we, developers, have in our toolkit. There are plenty of resources providing information on the value code review can add to any development team. However, most of the resources I have read, describe how to use code reviews as a tool to find bugs, or architectural issues that are hard to find in an…
  5. In my previous post, I covered the structure of a Backbone.js application using RequireJS. The next thing (or if you are a TDD fan, the first thing) we do is to run some tests on it. According to Coda Hale: Writing tests for your code may not reduce the number of bugs, but it will make fixing the bugs you inevitably find easier. Obviously, we can…
  6. Backbone gives us a very powerful set of tools. It gives us models, views, and routes - all event driven, consistent and beautifully embrace underscore.js functionality. Being a library rather than a framework, Backbone doesn’t give us application structure. That “glue” we need too initialize the app and glue all the pieces together. Since coding…
  7. RPN (Reverse Polish Notation) is a mathematical notation wherein every operator follows all of its operands, which was designed to reduce computer memory access and utilize the stack to evaluate expressions. The syntax looks like: A typical interview question would be to implement a RPN calculator since it is simple enough to resolve in less than…
  8. PubSub (or the observer pattern) is obviously the hottest pattern in client side development, and I would like to take a shot at trying to refine the best practices for using it in a flexible and robust way. The definition provided in the original Gang of Four book on Design Patterns states: “Define a one-to-many dependency between objects so that…
  9. I ran across PEP 20 — The Zen of Python by Tim Peters, and figured very little needs to be changed to make it a valid javascript zen: Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special…
  10. I ran into an old post by Philipp Lenssen on how good programmers are lazy and dumb. I totally agree with the title and most of the content. However, I believe that the lazy and dumb engineers are the better ones for a different reason: Lazy: Because code is liability, and by writing a lot of code, you are taking upon yourself (or your team…
  11. I ran into this old post by Jeff Atwood, that makes a good point. Reinventing the wheel is most probably the best way to learn about “wheels”, and about the problems they designed to solve. There is no better way to learn about anything than actually implementing it. However, consider a project that, say, 3 engineers are working on, and each one of…
  12. Edit, 6/26/2012: This post is my personal rant about interview questions. If you got here looking for actual programming interview questions, I can recommend these books: Cracking the Coding Interview and Programming Interviews Exposed. These books helped many engineers getting their dream jobs. It’s no secret I’ve been in a bunch of of interviews…
  13. Lets say you have a Backbone.js based messaging system on your application, and you want to stay synced with the server so you could alert your users when a new message arrives. You would like to call the server once every couple of seconds and ask for status updates. Or maybe your model represents an on going background task, you want to poll for…
  14. For a quick assignment I was asked to write the following program: In the language of your choosing build an application that, given an English language document as input, builds a data structure capturing the count of each word in the document. Bonus: Create an inverted index as well: a mapping of the words to absolute positions in the document…
  15. I am working on a backbone based search page, and was trying to figure out what would be a simple way to have both a state model and a URI that represents that state of the page (the search string, search parameters, user preferences, etc.). Thinking of mixing backbone routes and the application models seemed like an overkill, and would force me to…
  16. A simple yet powerful way to create backbone model calculated fields or “macros” For one of our applications, we needed a way to store “macros” in backbone models, that will return a calculated value, based on values we have in the model fields. I came up with a quick solution that seems to be good enough so far. the concept is, the same way you…

©2023 Uzi Kilon