Ryan Regalado

Website Developer / User Interface Designer
Nov 17, 2012


Delegation pattern is where an object, instead of performing one of its tasks, delegates the task to an associated helper object. The helper object is known as a delegate and is given the responsibility to execute a task for the delegator. This pattern is one of the fundamental abstraction patterns that underlie other software patterns such as composition, mixins and aspects.

Nov 15, 2012

From Secrets of a JavaScript Ninja book

// named function
function myName() { return true; }

// anonymous function
var myName2 = function() { return true; }

// anonymous function defined as property
window.myName3 = function() { return true; }

named functions can be defined after the function is called within a scope and it will be evaluated. This is also called forward-referencing, a property that anonymous functions don't have since they are assigned to variable or a property which can't be forward-referenced.

forward-reference in regards to functions means that no matter where in the scope that a function is defined, it will be accessible through that scope.

// testing function calls and if they are available when called
assert(myName(), 'works even though defined below');
assert(myName2(), 'doesn't work since defined below and assigned to variable');

function myName() { return true; };
var myName2() = function() { return true; };
var myName3() = function() { return true; };

assert(myName3(), 'works since defined before this assert called');
Nov 14, 2012

serialization converting an object structure into text/binary form suitable for storing onto disk or transmitting over a network.

deserialization is the reverse process. Eg., a javascript object into json string

{foo: [1,4,7,8], bar: "baz"}

// serialize into json string
{"foo": [1,4,7,8], "bar": "baz"}
Nov 13, 2012

lambda expression An anonymous function that you can use to create delegates or expression tree types. You can write local functions that can be passed as arguments or returned as the value of functions calls. They are particularly useful for writing LINQ query expressions, or .NET's feature to query and update data for various data stores.

Nov 12, 2012


A programming language is said to have first-class functions if it treats its functions as first-class citizens(an object, entity, or value), or an entity that can be constructed at run-time, passed as a parameter, returned from a subroutine, or assigned to a variable.

First-class functions are a necessity in a functional programming style, in which use of higher-order functions is a standard practice.

In mathematics and computer science, higher-order functions (also functional form, functional, or functor) is a function that does at least one of the following:

* take one or more functions as an input
* output a function
Nov 4, 2012

To try for IE

More from Secrets from a JavaScript Ninja book. A cross-browser function to implement logging in debugging

function log() {
    try {
        console.log.apply(console, arguments);
    catch (e) {
        try {
            opera.postError.apply(opera, arguments);
        catch (e) {
            alert(Array.prototype.join.call(arguments, " "));
Nov 2, 2012

Javascript Timers

  • JavaScript engines only have a single thread, forcing asynchronous events to
    queue waiting for execution.
  • setTimeout and setInterval are fundamentally different in how they execute asynchronous code.
  • If a timer is blocked from immediately being executed it will be delayed until the next possible time of execution (which will be longer than the desired delay).
  • Intervals may execute back-to-back with no delay if they take long enough to execute (longer than the specified delay).
Nov 1, 2012

Book notes

Starting to read this book from John Resig. It's promising as it cites core of Javascript regarding objects, function, and closures, and how the use of timers and regular expressions in popular javascript libraries can help you write better web applications.

I've been digging into coding cross-browser javascript for my current place of work at BlackLine so I'm looking forward to learning more of how John contributed to the jQuery library and insights from those efforts.

Things to consider

  • Best practices: testing and perforamnce analysis
    • simple assert function will do


Robert Frost wrote that good fences make good neighbors, but in the world of web applications, indeed any programming discipline, good tests make good code.

On Testing

Good test exhibit 3 characteristics:

  1. Repeatability - tests should be highly reproducible and have the same results.
  2. Simplicity - tests should focus on one thing.
  3. Independence - tests should execute in isolation, break them down in smallest possible unit, which helps determine the source of bugs
Oct 25, 2012

Designing MongoDB Schemas with embedded and bucket structures

I found this link to a blog article on how to define your MongoDB schema and make choices for embedded and non-embedded structures, as well as the use of buckets.

The main takeways are at the conclusion:

  1. The nature of MongoDB and storage strategy is that you have the ability to change the structure. This allows you to move from simple to more complex strategies at will
  2. Starting simple, can maintain development velocity early and migrate to a more scalable strategy as the need arises. I like this as I will be testing a small feature for the mytestimony web app project I want to implement.

More and more I'm liking MongoDB because of the easy nature of working with JSON data, and MongoDB's api for database queries are straight forward.

Oct 24, 2012

some notes

Just wanted to record what I did to get command-T working on a windows machine. There were problems with the ruby and gcc compilation of the plugin so I needed to make sure I had the correct versions of each to what the command-T plugin was built.

So some steps:

  1. Made sure I installed vim 7.3 with +ruby support
  2. Made sure I had a Ruby version of 1.9.1 that was used to compile command-T
  3. Had the gcc compiler so I can remake/compile the command-T plugin with ruby
  4. Run these commands in the ~.vim/bundle/command-t/ruby/command-t folder

$ ruby extconf.rb

$ make

And then I was able to ctrl+t while in vim and voila. yay :thumbsup: