<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom">

  <title>In search for the next abstraction</title>
  
  <link href="http://ivanjovanovic.com/" />
  <updated>2012-04-27T00:08:53+02:00</updated>
  <id>http://ivanjovanovic.com/</id>
  <author>
    <name>Ivan Jovanovic</name>
    
  </author>

  
  <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/IvanJovanovic" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="ivanjovanovic" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">IvanJovanovic</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><entry>
    <title>Programming Languages Are Simply Not Powerful Enough</title>
    <link href="http://ivanjovanovic.com/2012/04/26/programming-languages-are-simply-not-powerful-enough" />
    <updated>2012-04-26T22:09:00+02:00</updated>
    <id>http://ivanjovanovic.com/2012/04/26/programming-languages-are-simply-not-powerful-enough</id>
    <content type="html">&lt;p&gt;These days I&amp;#8217;m reading &lt;a href="http://thinking-forth.sourceforge.net/"&gt;Thinking Forth&lt;/a&gt;.
A gem among programming classics now available for free under CC
license. It is remarkable in the way it explains the thinking principles
behind building elegant programs. The book is based on Forth programming
language, which has very small amount of primitives and even for someone
who never had experience with Forth before it is not blocker to grasping the
essence.&lt;/p&gt;

&lt;p&gt;It is known since the early ages of programming, most elegant programs
are built as layers of &amp;quot;languages&amp;quot; or &amp;quot;dictionaries&amp;quot;. These are represented by abstractions in
a program in order to facilitate expressing the ideas in a way
that is more related to the domain. Although this looks very native and
obvious, it is extremely hard to reach to the level where this becomes
natural in practice. Aforementioned &lt;strong&gt;Thinking Forth&lt;/strong&gt; dedicates parts to
explaining this principle.&lt;/p&gt;

&lt;p&gt;Over my programming experience I have noticed one undeniable fact.
Application development starts becoming significantly harder in the
moment when level of abstraction in the application gets
insufficient. I called it &lt;strong&gt;locking application down to the level of
abstraction&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Motivation for this post comes from a quote:
&lt;blockquote&gt;
    &lt;strong&gt;In fact, you shouldn&amp;#8217;t write any serious application in Forth; as a language
    it&amp;#8217;s simply not powerful enough. What you should do is write your own
    language in Forth (lexicons) to model your understanding of the problem, in
    which you can elegantly describe its solution&lt;/strong&gt;
&lt;/blockquote&gt;&lt;/p&gt;

&lt;p&gt;One simple example from everyday life: Imagine that you don&amp;#8217;t have in
your vocabulary notion of a &lt;strong&gt;sum&lt;/strong&gt;. Therefore, if you would like to tell
someone to do a sum of some things you would always have to express the
process of summation in details instead of just telling &lt;strong&gt;and then you sum these numbers&lt;/strong&gt;.
If you would like then to express more complex concepts that are based on
summation, you would not be able to because you will be locked down to
the level of abstraction which is broken. Your language will not be
powerful enough to express complex ideas.&lt;/p&gt;

&lt;p&gt;As the quote says, which ever is your favorite programming language, it
is just not powerful enough to express complex concepts. It has a ways
to enable you to define primitives and means to combine them in order to
build higher levels of abstraction, but it is our job to express the
abstractions of the domain for the best economy of the expression.&lt;/p&gt;

&lt;p&gt;For the further reading there are valuable resources going deeper in this topic
like &lt;a href="http://mitpress.mit.edu/sicp/full-text/book/book.html"&gt;Structure and Interpretation of Computer
Programs&lt;/a&gt; which is
probably one of the best resources on principles of reasoning about
elegant program design.&lt;/p&gt;

&lt;p&gt;One exceptionally good resource is the Guy Steel&amp;#8217;s keynote from OOPSLA&amp;#8217;98 conference
about &lt;a href="http://video.google.com/videoplay?docid=-8860158196198824415"&gt;Growing a Language&lt;/a&gt;.
It clearly shows how language encapsulates power of expression or lack
of it and how it affects our ability to make beautiful and elegant
programs. As well it shows how ubiquitous the concept of growing a
languages is.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>“Nobody Cares About Your Software” Is a Very Dangerous Point of View</title>
    <link href="http://ivanjovanovic.com/2012/02/11/nobody-cares-about-your-software-is-a-very-dangerous-point-of-view" />
    <updated>2012-02-11T12:47:00+01:00</updated>
    <id>http://ivanjovanovic.com/2012/02/11/nobody-cares-about-your-software-is-a-very-dangerous-point-of-view</id>
    <content type="html">&lt;p&gt;I work for the company that is building its own software for the purpose of
bringing some value to its users. So, we don&amp;#8217;t sell software but we sell
what software does.&lt;/p&gt;

&lt;p&gt;I noticed that people are regularly throwing overgeneralizations and
telling that bringing value is the only important thing. At the end that
is not false. What is usually missing is understanding how quality of
software that is meant to bring value affects the process of producing
the value. By making decisions about the software platform you are inducing
heavily the ways you convey the value. You are enabling yourself to
communicate some messages but from the other side you are restricting
yourself for the others. Most probably lot of technical decisions on the
platform will heavily affect how you bring the value to the end user.&lt;/p&gt;

&lt;h2&gt;Lets dissect overgeneralized Nobody&lt;/h2&gt;

&lt;p&gt;Most of the people are big generalizators. When they want to say
something, it is easier to tell it in more general way, because getting
into details need explanations and can remove focus from the point. That
works for some cases, but there are cases when we can&amp;#8217;t simplify things
more than the problem allows.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nobody&lt;/strong&gt; in this case means &lt;strong&gt;Nobody that is willing to pay for our
service&lt;/strong&gt; cares about how it works in the background until it is
satisfying their expectations. In case of web development, simply said
&lt;strong&gt;Your users don&amp;#8217;t care about your software&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;When does it happen that our users have to care about our software&lt;/h2&gt;

&lt;p&gt;Lets see, why would our users be forced to care about the software.
That usually happens when software starts to get into their way. Lets
take one invented example sketch.&lt;/p&gt;

&lt;p&gt;Imagine two step process of filling the form on your website. You fill
in the first step, then click &lt;code&gt;next&lt;/code&gt; to go to the next step and fill the in second
step. You did not fill in properly second step and the process returned
you to refill first step again in order to do everything correctly.
Wat!!! Your website just made my day. And the days of lot of other
customers.&lt;/p&gt;

&lt;p&gt;The history of this feature usually goes something like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Product owner comes with really great idea of multistep form, and with the deadline for yesterday.&lt;/li&gt;
&lt;li&gt;Engineers explain that their framework don&amp;#8217;t really support multistep
forms, but they will make it work somehow.&lt;/li&gt;
&lt;li&gt;They make it work somehow, exactly as described above.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Here is important to see the relation of the state of this particular software and
technical explanation of this problem with the effect on the user&lt;/strong&gt;. And
obviously, user really doesn&amp;#8217;t care that your framework doesn&amp;#8217;t have
expected features and that you don&amp;#8217;t really know or have no time to
implement it properly.&lt;/p&gt;

&lt;h2&gt;5 Whys of this problem&lt;/h2&gt;

&lt;h4&gt;Why does user have to go to the first step again?&lt;/h4&gt;

&lt;p&gt;Because we didn&amp;#8217;t have time to properly implement the multistep form
behavior.&lt;/p&gt;

&lt;h4&gt;Why didn&amp;#8217;t you have time to implement it properly?&lt;/h4&gt;

&lt;p&gt;Because our framework didn&amp;#8217;t support this option and we had to implement
it in a very short time.&lt;/p&gt;

&lt;h4&gt;Why didn&amp;#8217;t you choose framework that has a bit more features?&lt;/h4&gt;

&lt;p&gt;Because we didn&amp;#8217;t really get time to plan properly migration to a new
framework. We took someting that we where most familiar with.&lt;/p&gt;

&lt;h4&gt;Why didn&amp;#8217;t you take your time for such an important decision?&lt;/h4&gt;

&lt;p&gt;Well, there are other things to do, and we just thought this is going to
be enough for now and did not think that much about future. We thought
that we&amp;#8217;ll be able to add features we need, but then we got understaffed
and we didn&amp;#8217;t find new employees fast so we had to do everything in a
hurry &amp;#8230;.&lt;/p&gt;

&lt;h4&gt;Why is that, it looks more like a management and staffing issue&lt;/h4&gt;

&lt;p&gt;Because, you know, in our company we have attitude that &lt;strong&gt;Noboday cares
about software, we only care about bringing value to our users&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;The other part of Nobody&lt;/h2&gt;

&lt;p&gt;At the beginning we extracted &lt;strong&gt;User&lt;/strong&gt; of our software from the
&lt;strong&gt;Nobody&lt;/strong&gt;
that we introduced at the start of the story. So, if we said that user doesn&amp;#8217;t want to
care about our software, what should others in the process than do.&lt;/p&gt;

&lt;p&gt;Well, in my opinion that is what building business that is relying on
a software product to deliver some user value is all about. &lt;strong&gt;Others
should care that user can fulfill his goal by using software and not
caring about software itself.&lt;/strong&gt; In fact what user is paying us for is to
care about the things he doesn&amp;#8217;t want to care. Unfortunatelly, when user
starts to feel that software is getting into his way, lack of care for
software has probably got too far away to fix in an easy way.&lt;/p&gt;

&lt;p&gt;Just to prove my point I have to list some responsibilities of standard
roles in a company that produces software of any kind.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Management&lt;/strong&gt; should care that service company provides is satisfying
and that users are not leaving for the competition. They should as well
care that software is maintainable with reasonable
price because they pay that maintainence at the end, stable and reliable
and that it produces more happy than unhappy uses, easy to understand
and documented well so they can expand the team fast, people are
educated for the position they do so they don&amp;#8217;t introduce stupid things
into the codebase, environment is optimized for long time work of this
kind, motivation is high &amp;#8230; mostly non-technical things that make life
of people that produce software confortable and make environment in
which software is built stable and predictable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Product owners&lt;/strong&gt; should care that they can use software as the modeling
tool for easy prototyping and trying out new ideas, that quality of the
product is not restricted by the software fallacies, that software is
not just visible implementation but as well statistics gathering tool
through which they can develop business ideas and prove some theories
they might have &amp;#8230;. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Engineers&lt;/strong&gt; should do their best to learn and understand the software
building and how to produce more quality, maintanability, flexibility
and stability with the least effort involved and with lowest resources.
We as engineers should as well really understand the domain we are working on and be
aware of the environment in which we operate, company strategy and short
and long terms goals &amp;#8230; and lots of other things.&lt;/p&gt;

&lt;p&gt;Goal of listing all of these responsibilities is not to make proper or 
correct list but to give a glimpse at the fact that lot of them are
related to actual state of the software, its health and health of the
environment specific for software production. &lt;/p&gt;

&lt;p&gt;At the end I come to the baseline of the article. It is my opinion that
in a business that is bringing value to the user using software product &lt;strong&gt;all we
have to do is to make users of our software not care about the
software. And the way to achieve this is that you as company
that is giving software tool to the users should care about that software so
they don&amp;#8217;t have to.&lt;/strong&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Random Hacks of Kindess comes to Zürich</title>
    <link href="http://ivanjovanovic.com/2011/10/12/random-hacks-of-kindess-come-to-zurich" />
    <updated>2011-10-12T22:39:00+02:00</updated>
    <id>http://ivanjovanovic.com/2011/10/12/random-hacks-of-kindess-come-to-zurich</id>
    <content type="html">&lt;p&gt;After great weekend I spent during &lt;a href="http://www.rhok.org/event/basel"&gt;RHoK #3 in Basel&lt;/a&gt;
I decided to join the RHoK Switzerland organization and help making next event
in Zürich even more awesome.&lt;/p&gt;

&lt;p&gt;Last Tuesday, I had a pleasure to present next &lt;a href="http://www.rhok.org"&gt;Random Hacks of
Kindness&lt;/a&gt; event in front of the Zürich
&lt;a href="http://webtuesday.ch/"&gt;Webtuesday&lt;/a&gt; community and here I wanted to share
slides from that presentation with a bit of context.&lt;/p&gt;

&lt;h2&gt;TL;DR for the impatient&lt;/h2&gt;

&lt;p&gt;RHoK #4 is going to happen in Zürich on 3rd and 4th
of December 2011. You should join because it is never bad time to invest
your time and expertise for the good cause. You can join by registering
through &lt;a href="http://www.rhok.org/event/zurich-switzerland"&gt;Eventbrite form&lt;/a&gt;
on the official event page. You can see more details about the RHoK
community on the &lt;a href="http://www.rhok.org"&gt;official web site&lt;/a&gt;. For following
up with new information follow &lt;a href="http://twitter.com/#!/rhokch"&gt;@rhokch&lt;/a&gt; on Twitter&lt;/p&gt;

&lt;div style="width:425px; margin-left:150px;" id="__ss_9664033"&gt; &lt;strong style="display:block;margin:12px 0 4px"&gt;&lt;a href="http://www.slideshare.net/ivan.jovanovic/rhok-presentation-zurich-webtuesday" title="RHoK presentation Zurich webtuesday" target="_blank"&gt;RHoK presentation Zurich webtuesday&lt;/a&gt;&lt;/strong&gt; &lt;iframe src="http://www.slideshare.net/slideshow/embed_code/9664033" width="425" height="355" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"&gt;&lt;/iframe&gt; &lt;div style="padding:5px 0 12px"&gt; View more &lt;a href="http://www.slideshare.net/" target="_blank"&gt;presentations&lt;/a&gt; from &lt;a href="http://www.slideshare.net/ivan.jovanovic" target="_blank"&gt;ivan.jovanovic&lt;/a&gt; &lt;/div&gt; &lt;/div&gt;

&lt;h2&gt;So, what makes RHoK different&lt;/h2&gt;

&lt;p&gt;Comparing to other hackaton based activities that I noticed, RHoK stands
out with the systematic orientation towards permanent and sustainable
impact over longer future. It is obvious to see that for a weekend of
hacking big problems can&amp;#8217;t be solved. Knowing that RHoK tends to attack
this problem particularly by building strong relation to organizations
and individuals that are closest to the problems being solved. In Basel, for example,
we had on site representatives from &lt;a href="http://www.caritas.ch"&gt;Caritas Switzerland&lt;/a&gt; and
&lt;a href="http://www.humanityroad.org/"&gt;Humanity Road&lt;/a&gt;. This way, from one side
RHoK helps Subject Matter Experts (as we call them) be strong problem
owners and drivers for the change, and from the other side RHoK brings
needed knowledge to attack these problems with high quality.&lt;/p&gt;

&lt;p&gt;Of course, you can bring your own idea to the event and try to motivate
others to join you bringing it to life or you can just hack on it
yourself. Only constrait is that at the end of the weekend you&amp;#8217;ll have
to present what you did and explaing why it matters to be solved.&lt;/p&gt;

&lt;h2&gt;RHoK is a competition event&lt;/h2&gt;

&lt;p&gt;The weekend event itself is a competition. At the end of the weekend,
you will, with your team, present what you came up with. Our sponsors
provide prizes for the winners. So if you are competitive even more
reasons to come.&lt;/p&gt;

&lt;h2&gt;Bringing needed knowledge to the problem&lt;/h2&gt;

&lt;p&gt;The way hackatons usually happen is around focused communities. For
example, Ruby/RoR community meets once a month and hacks on things they
are interested in, usually not oriented towards the humanity related
problems. Although this is great, this approach lacks some pieces in
order to sustainably solve big real world problems. RHoK as a concept
tries to bring ALL the knowledge needed not only the technical one. That
is why we try to motivate &lt;strong&gt;product owners, designers, user interaction
experts, thinkers or activists&lt;/strong&gt; to participate in
various parts of the process as a part of the team attacking particular
problem. This way we think we can make teams last longer than a weekend
and drive the solution to the state when it is being used in production.&lt;/p&gt;

&lt;h2&gt;RHoK #4 Zürich, 3rd and 4th of December 2011&lt;/h2&gt;

&lt;p&gt;What we provide is a venue, infrastructure, food and refreshements. At
the beginning of the event we&amp;#8217;ll get an overview of the problems that we
might attack during the weekend. All the problems are placed on the
official &lt;a href="http://www.rhok.org/problems"&gt;RHoK website&lt;/a&gt; in the problems section.
For some of the problems we&amp;#8217;ll have on-site representatives, for some of
them you might want to pair up with a team from another &lt;a href="http://www.rhok.org/events"&gt;RHoK event from
the list&lt;/a&gt; or you might bring your own
problem and attack it alone or with other participants that decide to
join you.&lt;/p&gt;

&lt;h2&gt;Stay up to date with new information about the event&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Official &lt;a href="http://www.rhok.org"&gt;Random Hacks of Kindness website&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;RHoK Switzerland Twitter account &lt;a href="http://twitter.com/#!/rhokch"&gt;@rhokch&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;RHoK Zürich event page -
&lt;a href="http://www.rhok.org/event/zurich-switzerland"&gt;http://www.rhok.org/event/zurich-switzerland&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Contact us directly &lt;a href="https://twitter.com/#!/ivanjovanovic"&gt;@ivanjovanovic&lt;/a&gt; or &lt;a href="https://twitter.com/#!/thesuperlogical"&gt;@thesuperlogical&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
  </entry>
  
  <entry>
    <title>There’s an RFC for That</title>
    <link href="http://ivanjovanovic.com/2011/10/02/theres-an-rfc-for-that" />
    <updated>2011-10-02T23:39:00+02:00</updated>
    <id>http://ivanjovanovic.com/2011/10/02/theres-an-rfc-for-that</id>
    <content type="html">&lt;p&gt;Too often I see colleagues developers employing Google and lurking around
random results to find answers on some typical web development questions
as &lt;strong&gt;&amp;quot;What does must-revalidate in Cache-Control does?&amp;quot;&lt;/strong&gt;, or &lt;strong&gt;&amp;quot;Is ETag
header forcing revalidation?&amp;quot;&lt;/strong&gt; and similar. Usually it ends up in
deciphering random answer on Stack Overflow or some other community web
site.&lt;/p&gt;

&lt;p&gt;First, of course that there is huge amount of knowledge out there and
very smart people answering with deep insight on every of these
questions. But still, they do present most often only their
interpretation of certain clearly defined and described standard. Answers also often know to be either
incomplete or plainly wrong. Second, most often these kind of responses
are representing how things are implemented in certain technology, Rails for example of any other.
That way usually you don&amp;#8217;t come to the answer of &lt;code&gt;why&lt;/code&gt; but &lt;code&gt;how&lt;/code&gt;
something is done. And to grow knowledge I always tend to go deeper and
understand why something is done in certain way.&lt;/p&gt;

&lt;p&gt;Take HTTP protocol as example, it is defined in &lt;a href="http://www.ietf.org/rfc/rfc2616.txt"&gt;RFC2616&lt;/a&gt;
where everything you need to know about it is written. It has a bit
unfriendly writing style, but once you get used to it you can see that
it is in fact very clear and unambiguous. Other benefit of getting used to
read RFC documents is that they are written in similar style and once
you get used to you can benefit from vast amount of them. At the end RFC
are the rules which define most of the web implementation in wide use on
the net. Let the HTML5 mess aside ;)&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>CoffeeScript implementation of Conway’s Game of Life</title>
    <link href="http://ivanjovanovic.com/2011/08/02/coffeescript-implementation-of-conways-game-of-life" />
    <updated>2011-08-02T00:00:00+02:00</updated>
    <id>http://ivanjovanovic.com/2011/08/02/coffeescript-implementation-of-conways-game-of-life</id>
    <content type="html">&lt;p&gt;Over the weekend I wanted to get a bit deeper into the &lt;a title="CoffeeScript website" href="http://jashkenas.github.com/coffee-script/"&gt;CoffeeScript&lt;/a&gt; and get around how it feels working with it. I gave myself task to do something simple  but inspiring. Therefore I implemented simple version of Conway&amp;#8217;s Game of Life to be played in browser. &lt;a title="CoffeeScript Conway’s Game of LIfe" href="http://blog.ivanjovanovic.com/labs/cgol/"&gt;Go here to see how it looks like&lt;/a&gt;.
&lt;h3&gt;CoffeeScript&lt;/h3&gt;
&lt;blockquote&gt;&lt;strong&gt;CoffeeScript is a little language that compiles into JavaScript.&lt;/strong&gt; Underneath all of those embarrassing braces and semicolons, JavaScript has always had a gorgeous object model at its heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way.&lt;/blockquote&gt;
In other words, CoffeeScript is an attempt to replace JavaScript syntax with a better one based on experiences from Ruby and Python worlds. Beside that it introduces couple of new abstractions which natively do not exist in the vanilla JavaScript like classes, list comprehensions, return of multiple values from function etc.&lt;/p&gt;

&lt;p&gt;CoffeeScript brings a lot of relaxation on the original JavaScript syntax and makes writing it at first weird experience but only until you get used to it. Afterwards it gets obvious that it takes much less to write the same thing in CoffeeScript than in plain JavaScript.
&lt;h3&gt;My observations on developing with CoffeeScript&lt;/h3&gt;
First and obvious observation is that with CoffeeScript you need additional tool in your toolset which will continuously compile your work to JavaScript. I used Jasmine for writing tests and I based my setup on &lt;a href="https://gist.github.com/956438"&gt;this gist&lt;/a&gt; which proposes using &lt;a title="guard Ruby gem on GitHub" href="https://github.com/guard/guard"&gt;guard Ruby gem&lt;/a&gt; for tracking changes and compiling CoffeeScript files into JavaScript ones.&lt;/p&gt;

&lt;p&gt;It looked a bit weird at start, but after couple of hours playing it started getting better. One thing I had always to do is to look in the actual compiled JavaScript to see how to do some things i.e. how to pass index to function that maps an array. But it was intuitive enough that I almost didn&amp;#8217;t need official documentation. Here I have to tell that it might not be as intuitive to people without experience with writing Ruby and Python code or lack of understanding for rather mathematical&lt;/p&gt;

&lt;figure role=code&gt; &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’js’&gt;&lt;div class=’line’&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;

&lt;p&gt;function notation.&lt;/p&gt;

&lt;p&gt;At the end I really liked it. Problem that I was solving didn&amp;#8217;t need using some advanced CoffeeScript constructs like classes but one that I used like multiple return values from the function really show how much you can get out of language if you have some basic tools implemented within.&lt;/p&gt;

&lt;p&gt;Last several months I was developing mostly in the Rails framework and since &lt;a title="Ruby on Rails 3.1 enabling CoffeeScript by default" href="http://weblog.rubyonrails.org/2011/5/22/rails-3-1-release-candidate"&gt;Rails 3.1&lt;/a&gt; is going to have CoffeeScript enabled by default I suppose I&amp;#8217;ll give CoffeeScript a chance again in next months and write more about experiences developing more complex things again in future.
&lt;h3&gt;Code is on GitHub&lt;/h3&gt;
You can find the source code for the implementation of the game on &lt;a title="Source code for CoffeeScript implementation of Conway’s Game of Life" href="https://github.com/ivanjovanovic/coffee-cgol"&gt;GitHub&lt;/a&gt;
&lt;h3&gt;Related links&lt;/h3&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;a title="CoffeeScript implementation of Conway’s Game of Life" href="http://blog.ivanjovanovic.com/labs/cgol/"&gt;My CoffeeScript implementation of Conway&amp;#8217;s Game of Life&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a title="CoffeeScript official page" href="http://jashkenas.github.com/coffee-script/"&gt;CoffeeScript&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a title="Conway’s game of life on Wikipedia" href="http://en.wikipedia.org/wiki/Conway’s_Game_of_Life"&gt;Conway&amp;#8217;s Game of LIfe on Wikipedia&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Introduction to JavaScript BDD testing with Jasmine library</title>
    <link href="http://ivanjovanovic.com/2011/07/22/introduction-to-javascript-bdd-testing-with-jasmine-library" />
    <updated>2011-07-22T00:00:00+02:00</updated>
    <id>http://ivanjovanovic.com/2011/07/22/introduction-to-javascript-bdd-testing-with-jasmine-library</id>
    <content type="html">&lt;p&gt;If we look at the developments in the software testing area, step beyond in evolution after &lt;a title="Razvoj vođen testovima" href="http://en.wikipedia.org/wiki/Test-driven_development"&gt;TDD&lt;/a&gt; is, so called, &lt;a title="Razvoj softvera vođen ponašanjem" href="http://en.wikipedia.org/wiki/Behavior_Driven_Development"&gt;BDD&lt;/a&gt; (Behavior Deriven Development). It is hard to describe BDD in couple of sentences. Excerpt taken from Wikipedia says:
&lt;blockquote&gt;BDD focuses on obtaining a clear understanding of desired software behaviour through discussion with stakeholders. It extends &lt;a title="Test-driven development" href="http://en.wikipedia.org/wiki/Test-driven_development"&gt;TDD&lt;/a&gt; by writing test cases in a natural language that non-programmers can read. Behavior-driven developers use their native language to describe the purpose and benefit of their code. This allows the developers to focus on why the code should be created, rather than the technical details, and minimizes translation between the technical language in which the code is written and the domain language spoken by the business, users, stakeholders, project management, etc.&lt;/blockquote&gt;
If this looks a bit complicated, in one sentence it would mean: &lt;strong&gt;BDD helps programmers and non-technical stakeholders understand each other better and develop software which will be the most representative model of the problem solved by writing the software  itself. &lt;/strong&gt;
&lt;h2&gt;Jasmine: BDD for your JavaScript&lt;/h2&gt;
&lt;a title="Jasmine: BDD za vaš JavaScript" href="http://pivotal.github.com/jasmine/"&gt;Jasmine&lt;/a&gt; is a library for BDD testing of your JavaScript. It offers range of possibilities to describe software functionalities by simple and descriptive tests, which is one of the basic principles of BDD based development. This way tests usually serve as the most accurate software documentation. More about Jasmine library on the &lt;a title="Jasmine na GitHub" href="https://github.com/pivotal/jasmine"&gt;GitHub repository&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;After you download standalone Jasmine distribution from &lt;a title="Nezavisna distribucija Jasmine biblioteke" href="http://pivotal.github.com/jasmine/download.html"&gt;here&lt;/a&gt; you&amp;#8217;ll find in the archive all you need to write your first tests together with the example of your code organization. The most important fie is &lt;strong&gt;SpecRunner.html&lt;/strong&gt; which, when run in browser, will execute tests and give you report about the state of the tests. SpecRunner.html is very simple and self explanatory. &lt;strong&gt;lib&lt;/strong&gt; folder contains Jasmine library, &lt;strong&gt;src&lt;/strong&gt; folder contains code to be tested and  &lt;strong&gt;spec&lt;/strong&gt; folder contains actual software specifications as tests.&lt;/p&gt;

&lt;p&gt;Further, I will implement simple object that can register multiple callback functions and call them with given data. Something like simple observer. I will always first write tests and then implement functionality to make tests pass.
&lt;h2&gt;Example of simple JavaScript observer with Jasmine tests&lt;/h2&gt;
We start from the downloaded archive for standalone Jasmine library. We need to delete example code provided with the library to implement our own example.&lt;/p&gt;

&lt;figure role=code&gt; &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;span class=’line’&gt;2&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’bash’&gt;&lt;div class=’line’&gt;rm src/*
&lt;/div&gt;&lt;div class=’line’&gt;rm spec/*
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;

&lt;p&gt;Also, from &lt;code&gt;SpecRunner.html&lt;/code&gt; file we delete references to just removed scripts. Therefore, part which includes them stays empty like this:&lt;/p&gt;

&lt;figure role=code&gt; &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;span class=’line’&gt;2&lt;/span&gt;
&lt;span class=’line’&gt;3&lt;/span&gt;
&lt;span class=’line’&gt;4&lt;/span&gt;
&lt;span class=’line’&gt;5&lt;/span&gt;
&lt;span class=’line’&gt;6&lt;/span&gt;
&lt;span class=’line’&gt;7&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’js’&gt;&lt;div class=’line’&gt;&lt;span class="p"&gt;…&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;
&lt;/div&gt;&lt;div class=’line’&gt;  &lt;span class="c"&gt;&amp;lt;!–&lt;/span&gt; &lt;span class="nx"&gt;include&lt;/span&gt; &lt;span class="nx"&gt;source&lt;/span&gt; &lt;span class="nx"&gt;files&lt;/span&gt; &lt;span class="nx"&gt;here&lt;/span&gt;&lt;span class="p"&gt;…&lt;/span&gt; &lt;span class="o"&gt;–&amp;gt;&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;
&lt;/div&gt;&lt;div class=’line’&gt;  &lt;span class="c"&gt;&amp;lt;!–&lt;/span&gt; &lt;span class="nx"&gt;include&lt;/span&gt; &lt;span class="nx"&gt;spec&lt;/span&gt; &lt;span class="nx"&gt;files&lt;/span&gt; &lt;span class="nx"&gt;here&lt;/span&gt;&lt;span class="p"&gt;…&lt;/span&gt; &lt;span class="o"&gt;–&amp;gt;&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="p"&gt;…&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;
&lt;h3&gt;First test&lt;/h3&gt;
In TDD and BDD philosophy one rule is essential for success.
&lt;blockquote&gt;First you write the test which will at the beginning fail, then you implement code which should satisfy specification described by test. Then, you execute test and continue with implementation until test passes. When that happens you know that implementation is OK.&lt;/blockquote&gt;
According to this we create file to place our tests in &lt;code&gt;spec/ObserverSpec.js&lt;/code&gt; and we define first test to simply check existence of the observer object.

&lt;figure role=code&gt;&lt;figcaption&gt;&lt;span&gt;lang.js &lt;/span&gt;&lt;/figcaption&gt;
 &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;span class=’line’&gt;2&lt;/span&gt;
&lt;span class=’line’&gt;3&lt;/span&gt;
&lt;span class=’line’&gt;4&lt;/span&gt;
&lt;span class=’line’&gt;5&lt;/span&gt;
&lt;span class=’line’&gt;6&lt;/span&gt;
&lt;span class=’line’&gt;7&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’js’&gt;&lt;div class=’line’&gt;&lt;span class="nx"&gt;describe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;rs.ji.observer&amp;quot;&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="nx"&gt;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;should be present in the global namespace&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;toBeDefined&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;

&lt;p&gt;And we add this specification to &lt;code&gt;SpecRunner.html&lt;/code&gt; to execute it:&lt;/p&gt;

&lt;figure role=code&gt; &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;span class=’line’&gt;2&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’html’&gt;&lt;div class=’line’&gt;&lt;span class="c"&gt;&amp;lt;!– include spec files here… –&amp;gt;&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;spec/ObserverSpec.js&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;

&lt;p&gt;If we now open &lt;code&gt;SpecRunner.html&lt;/code&gt; in some browser (i.e. Google Chrome) we will see one failing test.&lt;/p&gt;

&lt;p&gt;It is important to take a look in how our test looks like. If you read the test you&amp;#8217;ll see how descriptive it is and how with simple words expresses how our code should behave, although example is very simple. Here it takes some creativity of the developer to make tests really valuable but more than that is important that developer have deep understanding of the dictionary and terminology of the domain for which software is developed because understanding of the domain should be heavily embedded in the test definitions.&lt;/p&gt;

&lt;p&gt;Next step is to implement the code which will satisfy test. We will create file &lt;code&gt;src/observer.js&lt;/code&gt;&lt;/p&gt;

&lt;figure role=code&gt;&lt;figcaption&gt;&lt;span&gt;lang.js &lt;/span&gt;&lt;/figcaption&gt;
 &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;span class=’line’&gt;2&lt;/span&gt;
&lt;span class=’line’&gt;3&lt;/span&gt;
&lt;span class=’line’&gt;4&lt;/span&gt;
&lt;span class=’line’&gt;5&lt;/span&gt;
&lt;span class=’line’&gt;6&lt;/span&gt;
&lt;span class=’line’&gt;7&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’js’&gt;&lt;div class=’line’&gt;&lt;span class="c1"&gt;// defining so called namespace objects so I can namespace observer into&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="c1"&gt;// rs.ji.observer&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;rs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ji&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="c1"&gt;// observer implementation&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;

&lt;p&gt;And we will add it to &lt;code&gt;SpecRunner.html&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;[html]
&amp;lt;!&amp;#8211; include source files here&amp;#8230; &amp;#8211;&amp;gt;
&lt;script type="text/javascript" src="src/observer.js"&gt;&lt;/script&gt;
[/html]&lt;/p&gt;

&lt;p&gt;If we run &lt;code&gt;SpecRunner.html&lt;/code&gt; again, we can see that our test passes, it is green :)
&lt;h3&gt;Rest of implementation&lt;/h3&gt;
Now, when we know for the principle  &lt;strong&gt;&amp;quot;First failing test, then implementation&amp;quot;&lt;/strong&gt; we can add new functionalities to our simple example. We add next test:&lt;/p&gt;

&lt;figure role=code&gt; &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;span class=’line’&gt;2&lt;/span&gt;
&lt;span class=’line’&gt;3&lt;/span&gt;
&lt;span class=’line’&gt;4&lt;/span&gt;
&lt;span class=’line’&gt;5&lt;/span&gt;
&lt;span class=’line’&gt;6&lt;/span&gt;
&lt;span class=’line’&gt;7&lt;/span&gt;
&lt;span class=’line’&gt;8&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’js’&gt;&lt;div class=’line’&gt;    &lt;span class="nx"&gt;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;should be able to register callback function&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="c1"&gt;// define function to be placed into the observer register&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;callbacks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getCallbacks&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callbacks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callbacks&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]).&lt;/span&gt;&lt;span class="nx"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;

&lt;p&gt;And implementation that makes this test pass:&lt;/p&gt;

&lt;figure role=code&gt; &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;span class=’line’&gt;2&lt;/span&gt;
&lt;span class=’line’&gt;3&lt;/span&gt;
&lt;span class=’line’&gt;4&lt;/span&gt;
&lt;span class=’line’&gt;5&lt;/span&gt;
&lt;span class=’line’&gt;6&lt;/span&gt;
&lt;span class=’line’&gt;7&lt;/span&gt;
&lt;span class=’line’&gt;8&lt;/span&gt;
&lt;span class=’line’&gt;9&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’js’&gt;&lt;div class=’line’&gt;&lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="nx"&gt;callbacks&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;callbacks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="p"&gt;},&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="nx"&gt;getCallbacks&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;callbacks&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;

&lt;p&gt;We want to check if we can register multiple callbacks. This functionality should be supported already, but we write test to confirm this:&lt;/p&gt;

&lt;figure role=code&gt; &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;span class=’line’&gt;2&lt;/span&gt;
&lt;span class=’line’&gt;3&lt;/span&gt;
&lt;span class=’line’&gt;4&lt;/span&gt;
&lt;span class=’line’&gt;5&lt;/span&gt;
&lt;span class=’line’&gt;6&lt;/span&gt;
&lt;span class=’line’&gt;7&lt;/span&gt;
&lt;span class=’line’&gt;8&lt;/span&gt;
&lt;span class=’line’&gt;9&lt;/span&gt;
&lt;span class=’line’&gt;10&lt;/span&gt;
&lt;span class=’line’&gt;11&lt;/span&gt;
&lt;span class=’line’&gt;12&lt;/span&gt;
&lt;span class=’line’&gt;13&lt;/span&gt;
&lt;span class=’line’&gt;14&lt;/span&gt;
&lt;span class=’line’&gt;15&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’js’&gt;&lt;div class=’line’&gt;    &lt;span class="c1"&gt;// before every test we reset array of callbacks&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="nx"&gt;beforeEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;callbacks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="nx"&gt;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;should be able to register multiple callbacks&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;callback1&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;callback2&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callback1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callback2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;callbacks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getCallbacks&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callbacks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callbacks&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]).&lt;/span&gt;&lt;span class="nx"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callback1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callbacks&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]).&lt;/span&gt;&lt;span class="nx"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callback2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;

&lt;p&gt;Programmers often use &lt;code&gt;print, echo&lt;/code&gt; and friends to test code for certain functionalities. That takes time as for writing a test, but from other side tests are possible to be executed all the time after this initial check is done even when we move to implement something else.&lt;/p&gt;

&lt;p&gt;If we run &lt;code&gt;SpecRunner.html&lt;/code&gt; in browser, all tests should pass.&lt;/p&gt;

&lt;p&gt;Last thing our observer should do to satisfy its basic purpose is to update callback functions with some new information. That means it should be able to call them with some data. To define this functionality we write new test:&lt;/p&gt;

&lt;figure role=code&gt; &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;span class=’line’&gt;2&lt;/span&gt;
&lt;span class=’line’&gt;3&lt;/span&gt;
&lt;span class=’line’&gt;4&lt;/span&gt;
&lt;span class=’line’&gt;5&lt;/span&gt;
&lt;span class=’line’&gt;6&lt;/span&gt;
&lt;span class=’line’&gt;7&lt;/span&gt;
&lt;span class=’line’&gt;8&lt;/span&gt;
&lt;span class=’line’&gt;9&lt;/span&gt;
&lt;span class=’line’&gt;10&lt;/span&gt;
&lt;span class=’line’&gt;11&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’js’&gt;&lt;div class=’line’&gt;    &lt;span class="nx"&gt;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;should provide update method to execute all callbacks&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;callback1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;callback2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;spyOn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;callback1&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;spyOn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;callback2&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;callback1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;callback2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;data string&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;callback1&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;toHaveBeenCalledWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;data string&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;callback2&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;toHaveBeenCalledWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;data string&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;

&lt;p&gt;Here we use some advanced techniques of &lt;a title="Jasmine špijuniranje metoda" href="https://github.com/pivotal/jasmine/wiki/Spies"&gt;spying on methods&lt;/a&gt; (SpyOn) in order to see if some method is called while other is executed.&lt;/p&gt;

&lt;p&gt;As a helper, we will add &lt;a title="jQuery biblioteka" href="http://code.jquery.com/jquery-1.6.2.min.js"&gt;jQuery library&lt;/a&gt; to &lt;code&gt;src/jquery.js&lt;/code&gt; location and add it to &lt;code&gt;SpecRunner.html&lt;/code&gt; file:&lt;/p&gt;

&lt;figure role=code&gt; &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;span class=’line’&gt;2&lt;/span&gt;
&lt;span class=’line’&gt;3&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’html’&gt;&lt;div class=’line’&gt;&lt;span class="c"&gt;&amp;lt;!– include source files here… –&amp;gt;&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;src/jquery.js&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;src/observer.js&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;

&lt;p&gt;And we implement code to satisfy the test:&lt;/p&gt;

&lt;figure role=code&gt; &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;span class=’line’&gt;2&lt;/span&gt;
&lt;span class=’line’&gt;3&lt;/span&gt;
&lt;span class=’line’&gt;4&lt;/span&gt;
&lt;span class=’line’&gt;5&lt;/span&gt;
&lt;span class=’line’&gt;6&lt;/span&gt;
&lt;span class=’line’&gt;7&lt;/span&gt;
&lt;span class=’line’&gt;8&lt;/span&gt;
&lt;span class=’line’&gt;9&lt;/span&gt;
&lt;span class=’line’&gt;10&lt;/span&gt;
&lt;span class=’line’&gt;11&lt;/span&gt;
&lt;span class=’line’&gt;12&lt;/span&gt;
&lt;span class=’line’&gt;13&lt;/span&gt;
&lt;span class=’line’&gt;14&lt;/span&gt;
&lt;span class=’line’&gt;15&lt;/span&gt;
&lt;span class=’line’&gt;16&lt;/span&gt;
&lt;span class=’line’&gt;17&lt;/span&gt;
&lt;span class=’line’&gt;18&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’js’&gt;&lt;div class=’line’&gt;&lt;span class="c1"&gt;// observer implementation&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="nx"&gt;callbacks&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;callbacks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="p"&gt;},&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="nx"&gt;getCallbacks&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;callbacks&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="p"&gt;},&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="c1"&gt;// added update method to inform registered callbacks&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="c1"&gt;// uses jQuery to iterate over the array&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="nx"&gt;update&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;each&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;callbacks&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;            &lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// call every callback with provided data&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;
&lt;h2&gt;Complete picture&lt;/h2&gt;
That is it, now we have full implementation of simple observer with tests that can pretty clearly describe functionalities of the software we developed and they can as well prove in every time that needed functionalities are working OK by executing them in the browser (or different browsers to see if they will work in all of them).

Complete files:

&lt;figure role=code&gt; &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;span class=’line’&gt;2&lt;/span&gt;
&lt;span class=’line’&gt;3&lt;/span&gt;
&lt;span class=’line’&gt;4&lt;/span&gt;
&lt;span class=’line’&gt;5&lt;/span&gt;
&lt;span class=’line’&gt;6&lt;/span&gt;
&lt;span class=’line’&gt;7&lt;/span&gt;
&lt;span class=’line’&gt;8&lt;/span&gt;
&lt;span class=’line’&gt;9&lt;/span&gt;
&lt;span class=’line’&gt;10&lt;/span&gt;
&lt;span class=’line’&gt;11&lt;/span&gt;
&lt;span class=’line’&gt;12&lt;/span&gt;
&lt;span class=’line’&gt;13&lt;/span&gt;
&lt;span class=’line’&gt;14&lt;/span&gt;
&lt;span class=’line’&gt;15&lt;/span&gt;
&lt;span class=’line’&gt;16&lt;/span&gt;
&lt;span class=’line’&gt;17&lt;/span&gt;
&lt;span class=’line’&gt;18&lt;/span&gt;
&lt;span class=’line’&gt;19&lt;/span&gt;
&lt;span class=’line’&gt;20&lt;/span&gt;
&lt;span class=’line’&gt;21&lt;/span&gt;
&lt;span class=’line’&gt;22&lt;/span&gt;
&lt;span class=’line’&gt;23&lt;/span&gt;
&lt;span class=’line’&gt;24&lt;/span&gt;
&lt;span class=’line’&gt;25&lt;/span&gt;
&lt;span class=’line’&gt;26&lt;/span&gt;
&lt;span class=’line’&gt;27&lt;/span&gt;
&lt;span class=’line’&gt;28&lt;/span&gt;
&lt;span class=’line’&gt;29&lt;/span&gt;
&lt;span class=’line’&gt;30&lt;/span&gt;
&lt;span class=’line’&gt;31&lt;/span&gt;
&lt;span class=’line’&gt;32&lt;/span&gt;
&lt;span class=’line’&gt;33&lt;/span&gt;
&lt;span class=’line’&gt;34&lt;/span&gt;
&lt;span class=’line’&gt;35&lt;/span&gt;
&lt;span class=’line’&gt;36&lt;/span&gt;
&lt;span class=’line’&gt;37&lt;/span&gt;
&lt;span class=’line’&gt;38&lt;/span&gt;
&lt;span class=’line’&gt;39&lt;/span&gt;
&lt;span class=’line’&gt;40&lt;/span&gt;
&lt;span class=’line’&gt;41&lt;/span&gt;
&lt;span class=’line’&gt;42&lt;/span&gt;
&lt;span class=’line’&gt;43&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’js’&gt;&lt;div class=’line’&gt;&lt;span class="nx"&gt;describe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;rs.ji.observer&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="nx"&gt;beforeEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;callbacks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="nx"&gt;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;should be present in the global namespace&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;toBeDefined&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="nx"&gt;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;should be able to register callback function&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="c1"&gt;// define anonymous function to be placed into the observer register&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;callbacks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getCallbacks&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callbacks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="c1"&gt;// so we need to have first funtion in registered callbacks&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callbacks&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]).&lt;/span&gt;&lt;span class="nx"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="nx"&gt;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;should be able to register multiple callbacks&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;callback1&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;callback2&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callback1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callback2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;callbacks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getCallbacks&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callbacks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callbacks&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]).&lt;/span&gt;&lt;span class="nx"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callback1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callbacks&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]).&lt;/span&gt;&lt;span class="nx"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callback2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="nx"&gt;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;should provide update method to execute all callbacks&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;callback1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;callback2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;spyOn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;callback1&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;spyOn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;callback2&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;callback1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;callback2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;data string&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;callback1&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;toHaveBeenCalledWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;data string&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;callback2&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;toHaveBeenCalledWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;data string&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;
And the observer implementation
&lt;figure role=code&gt; &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;span class=’line’&gt;2&lt;/span&gt;
&lt;span class=’line’&gt;3&lt;/span&gt;
&lt;span class=’line’&gt;4&lt;/span&gt;
&lt;span class=’line’&gt;5&lt;/span&gt;
&lt;span class=’line’&gt;6&lt;/span&gt;
&lt;span class=’line’&gt;7&lt;/span&gt;
&lt;span class=’line’&gt;8&lt;/span&gt;
&lt;span class=’line’&gt;9&lt;/span&gt;
&lt;span class=’line’&gt;10&lt;/span&gt;
&lt;span class=’line’&gt;11&lt;/span&gt;
&lt;span class=’line’&gt;12&lt;/span&gt;
&lt;span class=’line’&gt;13&lt;/span&gt;
&lt;span class=’line’&gt;14&lt;/span&gt;
&lt;span class=’line’&gt;15&lt;/span&gt;
&lt;span class=’line’&gt;16&lt;/span&gt;
&lt;span class=’line’&gt;17&lt;/span&gt;
&lt;span class=’line’&gt;18&lt;/span&gt;
&lt;span class=’line’&gt;19&lt;/span&gt;
&lt;span class=’line’&gt;20&lt;/span&gt;
&lt;span class=’line’&gt;21&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’js’&gt;&lt;div class=’line’&gt;&lt;span class="c1"&gt;// defining so called namespace objects so I can namespace observer into&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="c1"&gt;// rs.ji.observer&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;rs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ji&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="c1"&gt;// observer implementation&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="nx"&gt;rs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ji&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="nx"&gt;callbacks&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;callbacks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="p"&gt;},&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="nx"&gt;getCallbacks&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;callbacks&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="p"&gt;},&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="nx"&gt;update&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;each&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;callbacks&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;            &lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt; 
</content>
  </entry>
  
  <entry>
    <title>Why (I think) Khan Academy really matters.</title>
    <link href="http://ivanjovanovic.com/2011/06/09/why-khan-academy-really-matters" />
    <updated>2011-06-09T00:00:00+02:00</updated>
    <id>http://ivanjovanovic.com/2011/06/09/why-khan-academy-really-matters</id>
    <content type="html">&lt;p&gt;Today I made &lt;a title="Serbian translation of Khan Academy video" href="http://www.universalsubtitles.org/en/videos/2QEdZnl4jZvK/sr/115753/"&gt;first translation to Serbian on Khan Academy&lt;/a&gt; and this post is about why I loved doing it and why I think it really matters.&lt;/p&gt;

&lt;p&gt;If you havent heard of &lt;a title="Khan Academy" href="http://www.khanacademy.org/"&gt;Khan Academy&lt;/a&gt; yet you should immediately get out that rock you are hiding under. No joke, Khan Academy is a big thing. Watch &lt;a title="Salman Khan TED talk" href="http://www.ted.com/talks/salman_khan_let_s_use_video_to_reinvent_education.html"&gt;this TED talk&lt;/a&gt; to see how amazing is what Salman Khan is doing. I was really happy when I saw that &lt;a href="http://ejohn.org/"&gt;John Resig of jQuery fame&lt;/a&gt; has &lt;a href="http://ejohn.org/blog/next-steps-in-2011/"&gt;joined their crew&lt;/a&gt; to help bringing this extraordinary mission to the next level. It is really extraordinary, especially for the times of today when everything is in profits and money. But it doesn&amp;#8217;t matter only because of that.&lt;/p&gt;

&lt;p&gt;I come from Serbia, country which is in kind of development. Last 20 years where not that good for us. Degradation of every part of society to the critical level happened during that time. People mostly without jobs, hope and will to go forward despite the fact that time passes by them fast. Yes, time passes by and developed world is changing even faster every day. And if you stand still for 20 years, you can imagine how far world goes in front of you. It goes so far that you, from your own point of view don&amp;#8217;t understand any more all that modern development and trends.&lt;/p&gt;

&lt;p&gt;So the big question for countries like Serbia is how do they catch up with the modern world. How do you learn things you have to know when you don&amp;#8217;t have access to good and innovative education, have no great people to lead the country because they are all spread around the world. Well, there are options. And improving education of people is in the core of all of them. In this context Khan Academy really matters. Not as final solution but more as announcement of future where education is going to be much less institutionalized and much easier spread across the globe, especially in the countries which need this the most.&lt;/p&gt;

&lt;p&gt;Internet has evolved to a point where it is becoming a platform for spreading something more than Facebook and Farmville. Recently I watched &lt;a title="Chris Anderson on TED.com" href="http://www.ted.com/talks/lang/eng/chris_anderson_how_web_video_powers_global_innovation.html"&gt;TED talk of Chris Anderson&lt;/a&gt; on how web video powers global innovation and I could not agree more. And Khan Academy proves this in practice on a high scale and is able to motivate thousands to join the train of global education improvement and to bring it to the higher level. This might lead to looking at the education in whole lot different ways than before and using peoples potential most efficiently to solve problems of underdeveloped communities. It brings some hope at least.
&lt;p style="text-align: center;"&gt;&lt;object width="526" height="374"&gt;&lt;param name="movie" value="http://video.ted.com/assets/player/swf/EmbedPlayer.swf"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true" /&gt;&lt;param name="allowScriptAccess" value="always"/&gt;&lt;param name="wmode" value="transparent"&gt;&lt;/param&gt;&lt;param name="bgColor" value="#ffffff"&gt;&lt;/param&gt;&lt;param name="flashvars" value="vu=http://video.ted.com/talk/stream/2011/Blank/SalmanKhan_2011-320k.mp4&amp;su=http://images.ted.com/images/ted/tedindex/embed-posters/SalmanKhan-2011.embed_thumbnail.jpg&amp;vw=512&amp;vh=288&amp;ap=0&amp;ti=1090&amp;lang=eng&amp;introDuration=15330&amp;adDuration=4000&amp;postAdDuration=830&amp;adKeys=talk=salman_khan_let_s_use_video_to_reinvent_education;year=2011;theme=a_taste_of_ted2011;event=TED2011;&amp;preAdTag=tconf.ted/embed;tile=1;sz=512x288;" /&gt;&lt;embed src="http://video.ted.com/assets/player/swf/EmbedPlayer.swf" pluginspace="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" bgColor="#ffffff" width="526" height="374" allowFullScreen="true" allowScriptAccess="always" flashvars="vu=http://video.ted.com/talk/stream/2011/Blank/SalmanKhan_2011-320k.mp4&amp;su=http://images.ted.com/images/ted/tedindex/embed-posters/SalmanKhan-2011.embed_thumbnail.jpg&amp;vw=512&amp;vh=288&amp;ap=0&amp;ti=1090&amp;lang=eng&amp;introDuration=15330&amp;adDuration=4000&amp;postAdDuration=830&amp;adKeys=talk=salman_khan_let_s_use_video_to_reinvent_education;year=2011;theme=a_taste_of_ted2011;event=TED2011;&amp;preAdTag=tconf.ted/embed;tile=1;sz=512x288;"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;
Currently I live in Switzerland, country blessed by the best standard in the world and really great performance in every aspect, from administration to education. One thing I see here is that people are not aware enough how others in the world live and when aware it is on the level of general empathy and not on the level of doing something with it. Paradoxically, countries like this can give the most to the world, not only by sharing money but experiences and knowledge about their success as well. Internet in this case might be a great leverage for small and great ones to influence world wide.&lt;/p&gt;

&lt;p&gt;Considering all of this, I though I could be one among this army of good people to help on this idea. I&amp;#8217;ll try to contribute on this topic as much as I can in my spare time and motivate others to do the same. Translating as much videos to Serbian would be one of primary goals and promoting the idea as well.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Random Hacks of Kindness - building a better world commit by commit</title>
    <link href="http://ivanjovanovic.com/2011/06/06/random-hacks-of-kindness-building-better-world-commit-by-commit" />
    <updated>2011-06-06T00:00:00+02:00</updated>
    <id>http://ivanjovanovic.com/2011/06/06/random-hacks-of-kindness-building-better-world-commit-by-commit</id>
    <content type="html">&lt;p&gt;It was long time ago since I realized that every discussions about this or that technology falls into water without putting it in the context of the real-world problem. And, unfortunately, real world today doesn&amp;#8217;t lack problems. What it lacks are people of good will to solve them, or at least good people lack organization and coordination in order to efficiently solve these problems.
&lt;a href="http://www.rhok.org/about"&gt;Random Hacks of Kindness&lt;/a&gt; project was started with idea to address this problem.
&lt;blockquote&gt;RHoK works by bringing together experts in development and volunteers with a broad set of skills in software development and design to solve problems defined by NGOs and other institutions which work in the area of disaster management.&lt;/blockquote&gt;
Last weekend RHoK happend for the first time in Switzerland. &lt;a href="http://wernerkrippendorf.blogspot.com/"&gt;Frank&lt;/a&gt;, driven by his experience from RHoK #2 in Berlin, organized great event in Basel and gathered around 20 of us to attack some of the &lt;a href="http://www.rhok.org/problems"&gt;RHoK problem definitions&lt;/a&gt; we found interesting. On the following video you can see presentations of all the teams, their problem definitions and explanations of solutions.&lt;/p&gt;

&lt;iframe width="420" height="315" src="http://www.youtube.com/embed/3y-afSoX_YA" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;

&lt;p&gt;I worked with &lt;a href="http://www.rhok.org/users/mullinger"&gt;Max&lt;/a&gt;, &lt;a href="http://www.rhok.org/users/philipp"&gt;Phillip&lt;/a&gt;, &lt;a href="http://www.rhok.org/users/delixfe"&gt;Felix&lt;/a&gt;, &lt;a href="http://www.rhok.org/users/tomtomaso"&gt;Thomas&lt;/a&gt; and Chad from &lt;a href="http://www.secondmuse.com"&gt;SecondMuse&lt;/a&gt; on the &lt;a href="http://www.rhok.org/problems/hazards-map-field-use"&gt;problem defined by Caritas Switzerland&lt;/a&gt;. Overall idea was to gather different sources of scientific GIS data for different global community risk related information like percentage of child hunger per country or intensity of cyclones in coastal areas and to present this information in usable way on one map with some tools to examine data more deep. Technically, the most difficult part of the problem is the fact that, as far I could understand, GIS area lacks standardization of data exchange file formats, and getting head around this domain in 2 days is really hard. We did not finish much on the practical side, but we examined the problem from technical side and came to deeper understanding of the problem domain and some ideas how it can be solved properly in future. One visible thing we made is &lt;a href="http://blog.ivanjovanovic.com/labs/chm/"&gt;half-working prototype&lt;/a&gt; of Google Map with two custom tile layers, more like proof of concept for our idea.&lt;/p&gt;

&lt;div class="image" style="width:580px;"&gt;&lt;img class=" " title="Me, explaining our solution" src="http://farm3.static.flickr.com/2559/5801680178_e18be382ff_z.jpg" alt="" width="576" height="383" /&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="http://oleg.utou.ch/"&gt;Oleg&lt;/a&gt;, who worked on the Person finder problem, gave &lt;a title="Olegs overview of RHoK Basel" href="http://ol.posterous.com/random-hacks-of-kindness-basel"&gt;great overview of the whole RHoK Basel event on his blog&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Beside great time, meeting great people and working on challenging problem I found that participating to this event additionally boosted my motivation to get deeper into non-technical side of problems of communities around the world. Also I became more aware how important is to motivate people to put some effort into solving this kind of problems and how easy is to help if proper environment is set and some basic organization is provided.&lt;/p&gt;

&lt;p&gt;On the line of organization, I liked that we could give the input about how we could improve the event organization for future. I found couple of possible optimizations of the process which might help me achieve better results next time:
&lt;ul&gt;
    &lt;li&gt;As software developer I&amp;#8217;m sensitive to quality of requirements. Problem definitions, as given today, are definitely not the best to work with. If we could &lt;strong&gt;involve engineers in the problem definition process&lt;/strong&gt; before problem definition comes for implementation it might help to get more done during the short and intense 2 days of hacking. And even more important maybe is to &lt;strong&gt;have the problem owner present in place for all time during the event&lt;/strong&gt;. This not only helps team but even more helps them to understand the problem better for future.&lt;/li&gt;
    &lt;li&gt;The way teams are formed is not the most efficient. Although, getting together with group of completely unfamiliar people is personally great and can lead to lot of innovation, it makes continuity a bit harder. Working with people you know and trust is from other side more efficient but can lead to not that innovative approaches. If these could be combined in a way I&amp;#8217;m sure we could achieve better results and insure better continuity which is essential for finishing the project to some usable state. Therefore I&amp;#8217;ll try to make effort to&lt;strong&gt; form a team for next RHoK and try to stick to a problem until it is finished at least in the basic version&lt;/strong&gt;.&lt;/li&gt;
    &lt;li&gt;&lt;strong&gt;Event should be promoted to the broader audience&lt;/strong&gt; and involve more different professions like &lt;strong&gt;designers, usability experts, product owners, scrum masters&lt;/strong&gt; and other involved in agile software development which is I believe the most appropriate for this way of attacking problems.&lt;/li&gt;
    &lt;li&gt;In future whole RHoK idea should be expanded to &lt;strong&gt;involve problem areas other than disaster management&lt;/strong&gt;. I would personally be the most interested in problems related to online education of countries in development, and others certainly have their own preferences as well. This way we might gather much bigger community around it.&lt;/li&gt;
&lt;/ul&gt;
&lt;img class="  " title="RHoK #3 Basel participants" src="http://farm4.static.flickr.com/3475/5801145819_ee4b6a5841_z.jpg" alt="" width="576" height="383" /&gt;&lt;/p&gt;

&lt;p&gt;And of course, next time consider to join&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Am I stupid, or is that = this stupid?</title>
    <link href="http://ivanjovanovic.com/2011/04/27/am-i-stupid-or-is-that-this-stupid" />
    <updated>2011-04-27T00:00:00+02:00</updated>
    <id>http://ivanjovanovic.com/2011/04/27/am-i-stupid-or-is-that-this-stupid</id>
    <content type="html">&lt;p&gt;JavaScript development has got really much momentum and its popularity is peaking. In the moment of design it was probably never foreseen as such success. Maybe that is why we have to satisfy to using only its &lt;a title="No affiliates ;)" href="http://www.amazon.com/exec/obidos/ASIN/0596517742/"&gt;&amp;quot;Good Parts&amp;quot;&lt;/a&gt;. There are lot of compromises with it, in order to make programming it a success overall. One thing that I always found weird is usage of &lt;strong&gt;that = this&lt;/strong&gt; concept. JavaScript guru &lt;a title="The guy that is bravely hiding Chuck Norris on the picture" href="http://www.crockford.com/"&gt;Douglas Crockford&lt;/a&gt; &lt;a href="http://javascript.crockford.com/private.html"&gt;explains on his website&lt;/a&gt; this concept of preserving connection of method with parent object regardless of the context of invocation. In practical usage I saw this pattern used for essentially the same reason but on other places. Consider this example (code purpose and quality in general do not matter that much)&lt;/p&gt;

&lt;figure role=code&gt; &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;span class=’line’&gt;2&lt;/span&gt;
&lt;span class=’line’&gt;3&lt;/span&gt;
&lt;span class=’line’&gt;4&lt;/span&gt;
&lt;span class=’line’&gt;5&lt;/span&gt;
&lt;span class=’line’&gt;6&lt;/span&gt;
&lt;span class=’line’&gt;7&lt;/span&gt;
&lt;span class=’line’&gt;8&lt;/span&gt;
&lt;span class=’line’&gt;9&lt;/span&gt;
&lt;span class=’line’&gt;10&lt;/span&gt;
&lt;span class=’line’&gt;11&lt;/span&gt;
&lt;span class=’line’&gt;12&lt;/span&gt;
&lt;span class=’line’&gt;13&lt;/span&gt;
&lt;span class=’line’&gt;14&lt;/span&gt;
&lt;span class=’line’&gt;15&lt;/span&gt;
&lt;span class=’line’&gt;16&lt;/span&gt;
&lt;span class=’line’&gt;17&lt;/span&gt;
&lt;span class=’line’&gt;18&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’js’&gt;&lt;div class=’line’&gt;&lt;span class="c1"&gt;// Returns array of positions of current players on the field&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="nx"&gt;tofu&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getPlayerPositions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;positions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;that&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;each&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rods&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;rod&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;that&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getRodDistance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="c1"&gt;// produce positions for all players&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nx"&gt;amp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;lt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;rod&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;men_number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;            &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;position&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;                &lt;span class="nx"&gt;left&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;left&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;                &lt;span class="nx"&gt;top&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;rod&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;men_distance&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;rod&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;position&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;            &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;            &lt;span class="nx"&gt;positions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;position&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;positions&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;

&lt;p&gt;The main point here is that we try to preserve reference to parent object with &lt;strong&gt;var that = this&lt;/strong&gt; because $.each(this.rods, &amp;#8230; ) will overwrite reference to local variable &lt;strong&gt;this&lt;/strong&gt;. In that case we access closure reference &lt;strong&gt;that&lt;/strong&gt; to refer to our original object.&lt;/p&gt;

&lt;p&gt;And there is a problem, I keep seeing this pattern all around. As I understand programming, proper naming of &amp;quot;things&amp;quot; is very important. And one that calls everything around in the terms of &lt;strong&gt;this&lt;/strong&gt; and &lt;strong&gt;that&lt;/strong&gt; might not be considered much smart ;) Can&amp;#8217;t we have a name for &lt;strong&gt;that&lt;/strong&gt; reference. Considering same example with small change in code I think it looks more natural than before and more readable and self explainable
&lt;figure role=code&gt; &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;span class=’line’&gt;2&lt;/span&gt;
&lt;span class=’line’&gt;3&lt;/span&gt;
&lt;span class=’line’&gt;4&lt;/span&gt;
&lt;span class=’line’&gt;5&lt;/span&gt;
&lt;span class=’line’&gt;6&lt;/span&gt;
&lt;span class=’line’&gt;7&lt;/span&gt;
&lt;span class=’line’&gt;8&lt;/span&gt;
&lt;span class=’line’&gt;9&lt;/span&gt;
&lt;span class=’line’&gt;10&lt;/span&gt;
&lt;span class=’line’&gt;11&lt;/span&gt;
&lt;span class=’line’&gt;12&lt;/span&gt;
&lt;span class=’line’&gt;13&lt;/span&gt;
&lt;span class=’line’&gt;14&lt;/span&gt;
&lt;span class=’line’&gt;15&lt;/span&gt;
&lt;span class=’line’&gt;16&lt;/span&gt;
&lt;span class=’line’&gt;17&lt;/span&gt;
&lt;span class=’line’&gt;18&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’js’&gt;&lt;div class=’line’&gt;&lt;span class="c1"&gt;// Returns array of positions of current players on the field&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="nx"&gt;tofu&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getPlayerPositions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;positions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;table&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;each&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rods&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;rod&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getRodDistance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="c1"&gt;// produce positions for all players&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nx"&gt;amp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;lt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;rod&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;men&lt;em&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;            &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;position&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;                &lt;span class="nx"&gt;left&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;left&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;                &lt;span class="nx"&gt;top&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;rod&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;men&lt;/em&gt;distance&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;rod&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;position&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;            &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;            &lt;span class="nx"&gt;positions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;position&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;        &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;positions&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Getting around first steps with Git</title>
    <link href="http://ivanjovanovic.com/2011/03/25/getting-around-first-steps-with-git" />
    <updated>2011-03-25T00:00:00+01:00</updated>
    <id>http://ivanjovanovic.com/2011/03/25/getting-around-first-steps-with-git</id>
    <content type="html">So, your pain threshold limits are exhausted by everyday use of your current version control software (SVN, CVS anyone?). You are looking for another solution to version control problems and you start exploring &lt;a href="http://git-scm.com/"&gt;Git&lt;/a&gt;. You heard that it is really cool, but now you&amp;#8217;re getting hands on to figure out how cool it really is.

For start, you should know that &lt;a title="Git basics" href="http://progit.org/book/ch1-3.html"&gt;Git is different&lt;/a&gt;. Your current mindset will drive you into using it the same way you used SVN, but very soon you&amp;#8217;ll find out that if you don&amp;#8217;t start working on your mindset, using Git can become more a problem than a solution. Fortunately, &lt;a href="http://progit.org/book/"&gt;Pro Git book&lt;/a&gt; is available online for free and I highly recommend going through it with understanding.&lt;!–more–&gt;

If there is a list of things to understand and clarify at start that I would recommend:
&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://progit.org/book/ch2-0.html"&gt;Git basics&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;track -&gt; edit -&gt; stage -&gt; commit -&gt; push file lifecycle&lt;/li&gt;
	&lt;li&gt;&lt;a href="http://stackoverflow.com/questions/292357/whats-the-difference-between-git-pull-and-git-fetch"&gt;fetching vs pulling&lt;/a&gt; changes from remote origin&lt;/li&gt;
	&lt;li&gt;every Git repository of a project &lt;a href="http://progit.org/book/ch3-5.html"&gt;represents part of one common history&lt;/a&gt;, your local branches are just one part of it, remote origin as well and repositories of your colleagues too.&lt;/li&gt;
	&lt;li&gt;&lt;a href="http://progit.org/book/ch3-0.html"&gt;working with branches&lt;/a&gt; properly and efficiently&lt;/li&gt;
	&lt;li&gt;&lt;a href="http://progit.org/book/ch7-1.html"&gt;managing configuration&lt;/a&gt; of your local repository and global Git configuration&lt;/li&gt;
&lt;/ul&gt;
I&amp;#8217;m new to Git and I had some basic questions to answer for myself, and afterwards I saw others asking again the same things. If I would take a couple of them to answer that would be these.
&lt;h3&gt;Git autocompletion&lt;/h3&gt;
Great tool to explore and learn Git commands during your everyday work. It is easy to set up and invaluable to have it.

First download the git-completion.bash file

&lt;figure role=code&gt; &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;span class=’line’&gt;2&lt;/span&gt;
&lt;span class=’line’&gt;3&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’bash’&gt;&lt;div class=’line’&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="c"&gt;# to go to your home folder&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;curl &lt;span class="se"&gt;\ &lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;  https://raw.github.com/git/git/master/contrib/completion/git-completion.bash -O
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;

and then add this line to your ~/.bash_profile or however you name your profile file

&lt;figure role=code&gt; &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’bash’&gt;&lt;div class=’line’&gt;&lt;span class="nb"&gt;source&lt;/span&gt; ~/git-completion.bash
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;
&lt;h3&gt;Checking out remote branch&lt;/h3&gt;
Someone pushed new branch to remote repository and you are having tough time to start working on it. Use

&lt;figure role=code&gt; &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’bash’&gt;&lt;div class=’line’&gt;git fetch
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;

this will fetch all remote branches and put them in local repository

&lt;figure role=code&gt; &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’bash’&gt;&lt;div class=’line’&gt;git checkout -b &lt;span class="nb"&gt;local&lt;/span&gt;-branch-name origin/remote-branch-name
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;

will check out branch and set tracking between local and remote branch properly for you.
&lt;h3&gt;Pushing and pulling only to and from current branch&lt;/h3&gt;
After you have finished your work on a branch, you want to push your changes. But git push command by default pushes changes from all branches if no other parameters are given. It can be configured in general to push only current branch with

&lt;figure role=code&gt; &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’bash’&gt;&lt;div class=’line’&gt;git config push.default current
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;

Regarding puling is a bit more complicated, since this is the option to be set for each branch. Probably it can be generalized. For example, you can have  a remote branch called funky-branch which is on the origin remote repository and local branch with same name funky-branch. Then we can pull only its changes if we set following config options for this local branch

&lt;figure role=code&gt; &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;span class=’line’&gt;2&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’bash’&gt;&lt;div class=’line’&gt;git config branch.funky-branch.remote origin
&lt;/div&gt;&lt;div class=’line’&gt;git config branch.funky-branch.merge refs/heads/funky-branch
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;

now git pull works without pulling other branches along the way.

There are of course numerous more questions to answer regarding Git, but when you touch the ground with your own feet, you&amp;#8217;ll get to answer them really quickly since it has a &lt;a href="http://git-scm.com/documentation"&gt;great documentation&lt;/a&gt; and an active community.

Git is extremely powerful and incredibly fast tool which enables us to make some really complicated development scenarios easy to manage. On the other hand it can often look like a kind of magic since there is a bit more to understand of it comparing to centralized version control solutions. One thing that is obvious after some weeks of everyday usage of Git is that it fits really good to the way my mind works during development. If you still have doubts, give it a try, it might even help :)
&lt;h3&gt;Making current git branch visible in your command prompt&lt;/h3&gt;
Git is known for powerful branching possibilities. Although, it is hard to shuffle between branches and to always know in which you are currently. There is simple solution to this. You can add name of current branch to your command prompt by adding this to your shell profile script.

&lt;figure role=code&gt; &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;span class=’line’&gt;2&lt;/span&gt;
&lt;span class=’line’&gt;3&lt;/span&gt;
&lt;span class=’line’&gt;4&lt;/span&gt;
&lt;span class=’line’&gt;5&lt;/span&gt;
&lt;span class=’line’&gt;6&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’bash’&gt;&lt;div class=’line’&gt;&lt;span class="c"&gt;# Set up git branch information in command prompt&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;parse_git_branch&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;  git branch 2&amp;gt; /dev/null | sed -e &lt;span class="s1"&gt;&amp;#39;/^[^*]/d&amp;#39;&lt;/span&gt; -e &lt;span class="s1"&gt;&amp;#39;s/* \(.*\)/[\1]/&amp;#39;&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="c"&gt;# Example of use of the function in command prompt $(parse_git_branch)&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="nv"&gt;PS1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;\w\$(parse_git_branch) $ &amp;quot;&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;

After resourcing your shell profile you&amp;#8217;ll see current checkout branch name in command prompt whenever you enter git workspace folder.
&lt;h3&gt;Selecting only part of a change for commit&lt;/h3&gt;
Usually changes we make are not perfectly clean, or currently changed files contain at least two unrelated changes. Git provides the way to select only a part of all the changes and stage them for commit. It is done by using:

&lt;figure role=code&gt; &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’bash’&gt;&lt;div class=’line’&gt;git app -p
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;

Then you would have a change to decide on every group of lines weather to include it or not, you can even split it to parts so you can select more granular way &amp;#8230;
&lt;h3&gt;Cleaning up repository with garbage collection&lt;/h3&gt;
Git doesn&amp;#8217;t do garbage collection on the repositories by default which has couple of advantages. Commands don&amp;#8217;t lose time to prune objects all the time and you have kind of history to refer to locally. But, over time it gets slower, which can be fixed with activating garbage collection.

&lt;figure role=code&gt; &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;span class=’line’&gt;2&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’javascript’&gt;&lt;div class=’line’&gt;&lt;span class="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;gc&lt;/span&gt; &lt;span class="o"&gt;–&lt;/span&gt;&lt;span class="nx"&gt;prune&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="c1"&gt;// or check `man git-gc` for more information about git garbage collection&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;
&amp;nbsp;
&lt;h3&gt;Getting up to more speed&lt;/h3&gt;
&lt;a title="Six Revisions Git resources" href="http://sixrevisions.com/resources/git-tutorials-beginners/"&gt;Here&lt;/a&gt; you can find extensive list of resources for learning Git with selection of top 10 sites that provide the best resources online.

After you have finished the basics you can proceed with more advanced topics. This &lt;a href="http://nuclearsquid.com/writings/git-tricks-tips-workflows.html"&gt;great post from Markus Prinz &lt;/a&gt; can help you with optimizing Git for more advanced and more personalized workflows.
</content>
  </entry>
  
  <entry>
    <title>TextMate for PHP development</title>
    <link href="http://ivanjovanovic.com/2010/12/29/textmate-for-php-development" />
    <updated>2010-12-29T00:00:00+01:00</updated>
    <id>http://ivanjovanovic.com/2010/12/29/textmate-for-php-development</id>
    <content type="html">If you want to improve your productivity and programming skills in general, getting to know better the tools you use every day is one of  the important things to invest your time in. Keyboard shortcuts of your favorite editor are especially important and using them in your daily routine will save you lot of hand movements towards mouse, lot of context switching and will help you focus on what is important.

I use TextMate for everyday PHP development and I find it excellent. There are some features that more complex IDEs provide out of the box, but after you get used to work with TextMate and learn how to be productive you can hardly find better option. Keyboard shortcuts are one of its good parts and key to boosting your productivity.

&lt;!–more–&gt;

There are some general purpose shortcuts that will work on any type of document, therefore on PHP files as well.

Regarding the notation: &lt;strong&gt;A + B&lt;/strong&gt; means press in same time, &lt;strong&gt;A -&amp;gt; B&lt;/strong&gt; means type A and then after it press B
&lt;ul&gt;
	&lt;li&gt;&lt;strong&gt;mate filename1 filename2&lt;/strong&gt; - you can always start TextMate from command line and give list of files/folders to open&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;open projectname.tmproj&lt;/strong&gt; - if you saved your TextMate project to a file, which is good way to preserve custom project configuration, you can open it from shell with standard OSX &lt;em&gt;open&lt;/em&gt; command&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Cmd + T&lt;/strong&gt; - search for file in the project&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Cmd + Shift + F&lt;/strong&gt; - search for a given string through all files in the project&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Cmd + F&lt;/strong&gt; - regular search for a given string in current file&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Ctrl + S&lt;/strong&gt; - faster way to search for strings in current file. Notice the input text box at the bottom of you TextMate window. Hit Esc to get out of fast search mode.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Cmd + Shift + T&lt;/strong&gt; - search for a function/class name in current file&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Cmd + Ctrl + R&lt;/strong&gt; - see where the current file is in the project folder tree.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Ctrl + W&lt;/strong&gt; - select whole word under cursor&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Ctrl + Shift + A&lt;/strong&gt; - gives you the list of SVN commands to execute on current file or folder if it is selected in project file tree.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Ctrl + Shift + G&lt;/strong&gt; - gives you the list of Git commands to execute on current file or folder if it is selected in project file tree.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Alt + Mouse Selection&lt;/strong&gt; - selecting in vertical blocks has never been easier, and editing afterwards as well :)&lt;/li&gt;
	&lt;li&gt;Set of shortcuts for doing fast search and replace
&lt;ul&gt;
	&lt;li&gt;&lt;strong&gt;Cmd + E&lt;/strong&gt; - set keyword to be replaced&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Shift + Cmd + E&lt;/strong&gt; - set replacement word&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Ctrl + Cmd + F&lt;/strong&gt; - replace in current file&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Ctrl + Shift + Cmd + F&lt;/strong&gt; - replace in selection only&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
Great thing about TextMate is its possibility to be customized for specific needs by adding so called &lt;a title="Textmate bundles" href="http://manual.macromates.com/en/bundles#bundles"&gt;bundles&lt;/a&gt;. TextMate comes with &lt;a title="Default PHP Bundle" href="https://github.com/textmate/php.tmbundle"&gt;default PHP bundle&lt;/a&gt; embedded. You can see all the functionalities it provides in &lt;em&gt;TextMate -&amp;gt; Bundles -&amp;gt; Bundle Editor -&amp;gt; Show Bundle Editor&lt;/em&gt; or &lt;strong&gt;Ctrl + Alt + Cmd + B&lt;/strong&gt; as shortcut. Here are some interesting ones from this bundle or useful for development in general
&lt;ul&gt;
	&lt;li&gt;&lt;strong&gt;Esc&lt;/strong&gt; - hitting escape after you typed couple of letters  will do code completion from the symbols defined in current editing file. Will work as well for native PHP functions. Just start typing &lt;em&gt;mk&lt;/em&gt; and hit &lt;em&gt;escape&lt;/em&gt; then and it will complete it as &lt;em&gt;mktime&lt;/em&gt; :)&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Alt + Esc&lt;/strong&gt; - this will give you list of possible completions. After selecting one of them, you&amp;#8217;ll get full function signature injected in the document.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Ctrl + H&lt;/strong&gt; - will give you PHP documentation related to the selected word in your current editing document.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Ctrl + Shift + V&lt;/strong&gt; - will check your file for syntax validity.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Shift + Cmd + D&lt;/strong&gt; - will jump to file that is included in the current PHP file.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;doc -&amp;gt; Tab&lt;/strong&gt; - if you type word &lt;em&gt;doc&lt;/em&gt; above class/method/function and hit Tab after it, you will get documentation block for the related entity.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Cmd + Shift + R&lt;/strong&gt; - will run your file with current system PHP executable. This is very nice when you just test something and want to see the output, but don&amp;#8217;t want to get out to shell and command line.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Alt + F1&lt;/strong&gt; - documentation about function signature in the form of tooltip. If you forgot weather $haystack or $needle goes first as the param in the array function this is easy way not to search through extensive documentation.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Shift + Ctrl + T&lt;/strong&gt; - if you like to place lot of &lt;em&gt;TODO&lt;/em&gt;, &lt;em&gt;FIXME&lt;/em&gt; or &lt;em&gt;CHANGED&lt;/em&gt; meta information in your comments for later addressing, this will help you find them quickly and navigate through them easily.&lt;/li&gt;
&lt;/ul&gt;
Beside these shortcuts there are a lot of snippets triggered by hitting Tab after typing its abbreviation. For example &lt;strong&gt;doc_f -&amp;gt; Tab&lt;/strong&gt; will create new function together with doc block. You can see list of all of them in the mentioned bundle editor in the section for PHP bundle. It is pretty easy as well to create your own specific snippets.

Many more general or specific shortcuts can be found online e.g. as printable &lt;a href="http://www.g-design.net/textmate.pdf"&gt;cheat&lt;/a&gt; &lt;a href="http://www.grayskies.net/TMcheatsheet.pdf"&gt;sheets&lt;/a&gt;. Or in TextMate &lt;a href="http://manual.macromates.com/en/"&gt;manual&lt;/a&gt;. The best way to adopt them is to take them one by one and pay attention to use it regularly, as soon as it is at the back of the brain start with new one until you become TextMate productivity wizard.
</content>
  </entry>
  
  <entry>
    <title>Then I saw the tests, now I’m a believer.</title>
    <link href="http://ivanjovanovic.com/2010/11/24/then-i-saw-the-tests-now-im-a-believer" />
    <updated>2010-11-24T00:00:00+01:00</updated>
    <id>http://ivanjovanovic.com/2010/11/24/then-i-saw-the-tests-now-im-a-believer</id>
    <content type="html">&lt;p&gt;These days I was working on a small feature that had to be added to an application here at &lt;a title="Local.ch AG, Official Swiss Phonebook" href="http://local.ch/"&gt;local.ch&lt;/a&gt;. The application was originally written by some other developers and it was first time that I looked at that code. Everything would be OK, and I would not write this post at all if at one moment I didn&amp;#8217;t feel strong need to rewrite the application completely. To be clear, it is not kind of need that draws motivation in &amp;quot;Not my code, I&amp;#8217;m smarter than others.&amp;quot; source of frustration. Point is that this code really needs refactoring in order to grow in future and remain maintainable while adding new features to it. But that is by itself not a problem, what code doesn&amp;#8217;t need refactoring, especially your own!  And if you have no constant need to refactor things that could mean you didn&amp;#8217;t learn anything since last time you saw that code.&lt;/p&gt;

&lt;p&gt;The problem becomes obvious and bit more acute when you figure out that, despite the fact that we try to keep our micro applications pretty simple with least possible code and logic, you don&amp;#8217;t have all clues about how that piece of software works. Then you become aware  that amount of time needed to get into all the bits of included functionalities is way bigger than just  refactoring the code. Therefore, you lose peak of your motivation since you instantly visualize all the non-engineering time you need to invest in gathering information instead of just doing it. But of course, when just doing it, at the end it should have the same function as before, I guess. So without some proof that you didn&amp;#8217;t degrade functionality, just do it approach would be even worse than not doing it.&lt;/p&gt;

&lt;p&gt;And where would you expect to find up to date documentation in such case? Browsing the Wiki &amp;#8230; not ;)&lt;/p&gt;

&lt;p&gt;While letting you think a bit, I&amp;#8217;d tell you that at &lt;a href="http://local.ch"&gt;local.ch&lt;/a&gt; we are passionate about agile practices and testing in particular. We always try to cover our code with reasonable amount of coverage and quality of tests. Since I joined, I accepted this as a fact and acted in that sense, but was not believer in testing in the religious way. Not until I imagined ideal world where I would go to test cases and could understand all functionalities implemented in the code that these tests cover. And in more ideal world, I would be able to drop the code, leave the tests and write new code which would be proved as correct in the moment all tests get green again. But not when tests are written in the way to reflect bad implementation choices in the code and not thoroughly though through. Then you have to throw the tests as well and you are back at the start point.&lt;/p&gt;

&lt;p&gt;I could imagine that in mentioned idealized model of the world you could continuously improve quality of the code, reduce price of its maintenance, add new features and experiment with different ways of implementing the same thing while exploring new approaches to solving old problems. And all that while being sure that you didn&amp;#8217;t break function of software that might in a case pay your salary at the end of the month.&lt;/p&gt;

&lt;p&gt;Yes, and &amp;quot;The Beatles&amp;quot; are now in iTunes. Lucky us, the whole world has changed.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Webtuesday at local.ch offices</title>
    <link href="http://ivanjovanovic.com/2010/04/14/webtuesday-at-local-ch-offices" />
    <updated>2010-04-14T00:00:00+02:00</updated>
    <id>http://ivanjovanovic.com/2010/04/14/webtuesday-at-local-ch-offices</id>
    <content type="html">Every first Tuesday of a month, Zürich oriented web community gather for an evening of tech talks and some beer for, so called, &lt;a title="Webtuesday web site" href="http://webtuesday.ch/"&gt;webtuesday&lt;/a&gt;. Yesterday, we had pleasure to host event at  &lt;a title="Local.ch web site" href="http://local.ch/"&gt;local.ch&lt;/a&gt; for the first time as unofficial opening for the community after movement to &lt;a title="Local.ch address" href="http://yellow.local.ch/en/d/Zuerich/8001/Internet/local.ch-ag-jXdlhL7d_gnuD1d-TjoTTw?what=local.ch"&gt;new offices&lt;/a&gt;. As Harry &lt;a title="Harry’s twitter status" href="http://twitter.com/hfuecks/status/12115799946"&gt;tweeted&lt;/a&gt; already during the event, it was pretty packed. I was personally happy to see lot of people coming since this was only my second webtuesday since I started working for local.ch 6 months ago.

&lt;div class="image" style="width:350px;"&gt;
  &lt;a href="http://twitter.com/hfuecks/status/12115799946"&gt;&lt;img title="Packed webtuestad @localch offices" src="http://a.yfrog.com/img707/5599/4lmg.jpg" alt="Packed Webtuesday @localch offices" width="336" height="252" /&gt;&lt;/a&gt;
Packed webtuesday @localch offices (by Harry Fuecks)&lt;/div&gt;

This time &lt;a title="Patrice’s blog" href="http://weblog.patrice.ch/"&gt;Patrice&lt;/a&gt; and Chris from &lt;a title="Memonic" href="http://memonic.com"&gt;memonic.com&lt;/a&gt; gave great talk on the current state of the architecture and tools that are behind their startup. Since both of them worked for local.ch before (Patrice as Lead of Frontend Development, Chris as backend Java developer)  it was interesting to see how much they kept and where they improved along the way.

Interesting point was the choice of the language for their startup. At local.ch, we are kind of separated on frontend and backend development, before all, by the languages we use. Shortly, PHP on the frontend and Java in backend with HTTP communication in between, XML result got from backend parsed by XSL to produce HTML. At Memonic they decided to bring that together and make gap between backend and frontend development smaller by choosing Python as common language. Having experience with the Scrum and challenges which this kind of separation between frontend and backend carries, I see this as reasonable decision. I was surprised to hear that none of them had professional experience with Python before founding Memonic.

Their architecture is highly web service oriented. The way Patrice conceptually sees the architecture can be paraphrased like this:
&lt;blockquote&gt;&amp;#8220;I see web services in our architecture as classes are used traditionally, or maybe better, as components of the traditional framework&amp;#8221;&lt;/blockquote&gt;
end of lousy paraphrase :). So, if we take Zend Framework for example: imagine that instead of having Zend_Auth, Zend_Session, Zend_Log, Zend_Mail &amp;#8230; and sending messages to their objects, you have web services that expose interfaces over HTTP. On the &lt;a title="Memonic blog post" href="http://blog.memonic.com/archive/2010/04/14/webtuesday-memonic-architecture.html"&gt;slides Patrice provided&lt;/a&gt; can be seen in smaller detail way their architecture is broken into smallest possible web services that communicate among each other. Web services are based on &lt;a title="wsgiservice on GitHub" href="http://github.com/pneff/wsgiservice"&gt;wsgiservice&lt;/a&gt; (Python WSGI framework to create REST web service) library that is open sourced by Patrice. One thing I was interested is what is the performance loss in HTTP communication overhead between components. In current state of the load they do not see it as problem and they see using HTTP features as e.g. caching more valuable than performance loss introduced.

Here are some links, if you are more interested to find out about &lt;a title="Local.ch - official website" href="http://www.local.ch/en/s/aboutus/facts_and_figures"&gt;local.ch&lt;/a&gt;, &lt;a title="Webtuesday website" href="http://webtuesday.ch"&gt;webtuesday&lt;/a&gt; or &lt;a title="Keep the essential, memonic.com website" href="http://memonic.com/"&gt;memonic.com&lt;/a&gt;.
</content>
  </entry>
  
  <entry>
    <title>A year behind my back</title>
    <link href="http://ivanjovanovic.com/2009/09/16/a-year-behind-my-back" />
    <updated>2009-09-16T00:00:00+02:00</updated>
    <id>http://ivanjovanovic.com/2009/09/16/a-year-behind-my-back</id>
    <content type="html">&lt;p&gt;The year is behind me since I wrote last post. A lot, mostly good, has
happened.&lt;/p&gt;

&lt;p&gt;First and most important I have finished my studies. Now I can proudly say that I&amp;#8217;m an Electrical Engineer in the field of Automation and Control Engineering. But wait, how does Senior Web Developer position relates to that? Let that be a topic for further evaluation :) Let just say that in one moment I had to decide what interests me more.&lt;/p&gt;

&lt;p&gt;Somewhere at the beginning of February, after almost year and a half,
our cooperation with Tilllate ended. Thanks to the Maarten, Leo, Silvan,
Cyprian, Jia-yong Ou, Michael, Thilo and others for being friendly,
positive and smart to create great surrounding to work in. I have raised
my skill to much higher level and learned a lot about programming in
high-traffic, heavy-loaded environment and gained much wider view on
software development than I had before. I&amp;#8217;d like to specially thank to
Tilllate Chief Software Engineer Maarten Manders for having confidence
that I will do proper job with some crucial parts of Tilllate, I hope I
succeeded.&lt;/p&gt;

&lt;p&gt;During the March I have started looking for a new job, preferably in Switzerland. After evaluation of open positions in the market I have applied for a position of frontend engineer in &lt;a title="Local.ch" href="http://www.local.ch"&gt;local.ch&lt;/a&gt;. In May I went to Zurich on the interview and until the beginning of the June I was offered a job. I accepted the offer and there was just one little thing standing between me and Zurich, the procedure of getting working permission for the non-EU citizen. Hard times for me :) To cut the story (since writing this post took some time and things happened meanwhile) I got my working permission after several months. Now I&amp;#8217;m waiting for Swiss entrance visa and until the end of October I should start on my new job in Zurich. Currently I&amp;#8217;m looking for a temporary flat in Zurich where I could reside for couple months before I find real place to live and bring my wife to Zurich too.&lt;/p&gt;

&lt;p&gt;As it is in real life, some stories are at the beginning, and some are at the end. While writing this post, I&amp;#8217;m spending last days in &lt;a title="youngculture" href="http://www.youngculture.com"&gt;youngculture&lt;/a&gt;. It was great experience and pleasure, before all, for me to work with some of the most advanced developers in Belgrade in very high-quality working environment. I met friends for the whole life here and my two years in Belgrade will stay clearly positive experience. However, &lt;a href="http://www.youngculture.com"&gt;youngculture&lt;/a&gt; headquarters is based in Zurich, and people that I worked with regularly travel to Switzerland, so I presume I won&amp;#8217;t miss them too much :) I&amp;#8217;m ready for beer or two whenever you call!!!!&lt;/p&gt;

&lt;p&gt;The year has passed so fast that I almost did not notice it. Just heard &amp;quot;whuush&amp;quot; sound somewhere around birthday. I had no time to devote to the things I like as blogging and out-of-work internet existence, but I hope that next year will change that. I planned to reorganize this domain and blog so I could efficiently present what I&amp;#8217;m working on and things I like. I hope as well that starting new job will give me the chance to reconsider some priorities in life and bring some fresh air as well.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>PHP debugging with FirePHP</title>
    <link href="http://ivanjovanovic.com/2008/08/31/php-debugging-firephp" />
    <updated>2008-08-31T00:00:00+02:00</updated>
    <id>http://ivanjovanovic.com/2008/08/31/php-debugging-firephp</id>
    <content type="html">&lt;p&gt;I really like when I stumble upon a creative and useful piece of software that could improve my everyday development process. I remember when I started using FireBug it was great help in the HTML/CSS/JavaScript development and debugging.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ve just found out &lt;strong&gt;FirePHP&lt;/strong&gt;, FireBug plugin that enables the developer to send log messages from PHP code to FireBug console. Quite helpfull I can say :) It consists of Firefox extension (mentioned FireBug plugin) and small PHP logger that you actually use in your code to communicate with the FireBug console. Logger comes in procedural and object-oriented fashion so if you are striving towards exceptional performance of your PHP app, or just still old-school PHP4 (R.I.P.), then man you have your choice :) Otherwise use OO PHP5 logger class. I&amp;#8217;ve manage to set the demo, that goes within the PHP library, in a couple of minutes and I&amp;#8217;m looking forward for using it in the future.&lt;/p&gt;

&lt;p&gt;Thanks guys for great work.
&lt;a title="Official FirePHP website" href="http://www.firephp.org/"&gt;Official FirePHP website&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another cool thing that comes with the FirePHP is its integration posibilities with CakePHP, CodeIgniter, Drupal, ExpressionEngine, Kohana, PRADO, Symfony, TYPO3, &lt;strong&gt;Zend Framework.&lt;/strong&gt; So there is some for anyone.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Moving to Ubuntu or Windows sucks!</title>
    <link href="http://ivanjovanovic.com/2008/08/12/moving-to-ubuntu-or-windows-sucks" />
    <updated>2008-08-12T00:00:00+02:00</updated>
    <id>http://ivanjovanovic.com/2008/08/12/moving-to-ubuntu-or-windows-sucks</id>
    <content type="html">&lt;p&gt;&lt;img class="alignleft" style="margin: 10px;" src="http://www.ubuntu.com/themes/ubuntu07/images/ubuntulogo.png" alt="Ubuntu logo" hspace="5" vspace="5" width="202" height="55" align="left" /&gt;While writing this post, post-intallation update on my fresh Ubuntu installation is under its way. It was long time ago I started to feel constraints of Windows as web development environment. So, very logical step was to move to something more developer friendly than user (read dummy) friendly. After testing Ubuntu with VMware player I decided to go step further and use &lt;a title="WUBI (Ubuntu Installer for Windows)" href="http://wubi-installer.org/"&gt;WUBI (Windows Ubuntu installer)&lt;/a&gt; to intall Ubuntu as Windows application in a folder that will act as separate filesystem for my linux installation.&lt;/p&gt;

&lt;p&gt;Yes, I know it is not perfect solution, but since I&amp;#8217;m running it on Toshiba laptop I was worried about drivers and related staff  and didn&amp;#8217;t want to stay even without the Vista crap (TM).
After all installation was smooth and harmless and it seems that everything works as expected for now. Setting the development environment is the next challenge I&amp;#8217;ll take. Apache, MySQL, SVN &amp;#8230; here I come :)&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Preserving ordering with WHERE IN() clause in MySQL</title>
    <link href="http://ivanjovanovic.com/2008/04/01/preserving-ordering-with-where-in-clause-in-mysql" />
    <updated>2008-04-01T00:00:00+02:00</updated>
    <id>http://ivanjovanovic.com/2008/04/01/preserving-ordering-with-where-in-clause-in-mysql</id>
    <content type="html">Today I ran into the code that pulls from database list of elements with
&lt;figure role=code&gt; &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’sql’&gt;&lt;div class=’line’&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="k"&gt;table&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;22&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;56&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;48&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt; 
where order of ids is important to be preserved after results found. When using SELECT this way you will get the results for
every id but ordered by id in ascending order. I was looking around and found neat solution to make MySQL work
for you to preserve the order of returned results. With ORDER BY FIELD clause like here
&lt;figure role=code&gt; &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;span class=’line’&gt;2&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’sql’&gt;&lt;div class=’line’&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="k"&gt;table&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;FIELD&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt; 
you can keep the initial ordering. What is the catch. This way &lt;strong&gt;id&lt;/strong&gt; field can not be used as indexed. Therefore, 
&lt;figure role=code&gt; &lt;div class="highlight"&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class=’line’&gt;1&lt;/span&gt;
&lt;span class=’line’&gt;2&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class=’code’ width=’100%’&gt;&lt;pre&gt;&lt;code class=’sql’&gt;&lt;div class=’line’&gt;&lt;span class="k"&gt;EXPLAIN&lt;/span&gt; &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="k"&gt;table&lt;/span&gt;
&lt;/div&gt;&lt;div class=’line’&gt;&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;FIELD&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;
would give you the information that it is using &lt;strong&gt;filesort&lt;/strong&gt; for results ordering which is not so nice. In general, when you have &lt;strong&gt;id&lt;/strong&gt;s
as the array with the ordering you need, it probably needs less resources to reorganize them in memory instead of letting MySQL doing it with &lt;strong&gt;filesort.&lt;/strong&gt;
</content>
  </entry>
  
</feed>

