<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>westoque</title>
    <description>I make apps for mobile and web. Specializing in Rails, Javascript, and Node.JS. Whatever gets the job done.
</description>
    <link>http://westoque.com/</link>
    <atom:link href="http://westoque.com/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Sun, 19 Apr 2015 13:54:00 +0800</pubDate>
    <lastBuildDate>Sun, 19 Apr 2015 13:54:00 +0800</lastBuildDate>
    <generator>Jekyll v2.5.3</generator>
    
      <item>
        <title>You already use TypeScript</title>
        <description>&lt;p&gt;You probably heard of this new language on top of Javascript called
&lt;a href=&quot;http://www.typescriptlang.org&quot;&gt;TypeScript&lt;/a&gt;. TypeScript promises to make your code better and 
maintainable by adding more features on top of Javascript such as
types and classes.&lt;/p&gt;

&lt;p&gt;Javascript purists on the other hand, don’t want types and infer that it
is one of Javascripts strengths. That is correct, although if you used a
popular open source Javascript library in the past few years, you might’ve
come across some documentation that looks like this.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/facebook_code_example.png&quot; alt=&quot;facebook code example&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Now, if you looked at the documentation, look at that! You see types! Isn’t
that ironic. So you have been using types all along, you just didn’t
notice it yet. This pattern is actually used by a lot of big Javascript
libraries like Facebook’s JS SDK, Yahoo’s YUI, and many more.&lt;/p&gt;

&lt;p&gt;I have been using TypeScript myself lately. And I’m all for it. It makes
your code much more readable, and eliminates some boiler plate code
checking, like checking for default values and types.&lt;/p&gt;

&lt;p&gt;The best thing I like about it is that if you are working on a
huge codebase, it would be easier to work with the code by knowing which
code breaks because of the compiler, not that we’re all dependent on it,
but I wouldn’t mind having some type of checking.&lt;/p&gt;

&lt;p&gt;So there you have it, I think TypeScript has a lot of potential.
Especially for people who write libraries. If you use Javascript,
you might as well use TypeScript.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://news.ycombinator.com/item?id=9402170&quot;&gt;Discuss on hacker news.&lt;/a&gt;&lt;/p&gt;

</description>
        <pubDate>Sun, 19 Apr 2015 21:00:00 +0800</pubDate>
        <link>http://westoque.com/2015/04/19/you-already-use-typescript.html</link>
        <guid isPermaLink="true">http://westoque.com/2015/04/19/you-already-use-typescript.html</guid>
        
        
      </item>
    
      <item>
        <title>A Huge Ruby Problem</title>
        <description>&lt;p&gt;Oh my beloved ruby! How I thought you were perfect… This was the
case until I realized it had a huge problem resolving classes.&lt;/p&gt;

&lt;p&gt;Given this class:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ruby
class MyModule::File 
end
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;When I try to use &lt;code&gt;MyModule::File&lt;/code&gt; it would always resolve to the
standard &lt;code&gt;File&lt;/code&gt; class, which is not what I want and gives me a warning:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sh
&amp;gt; MyModule::File
(irb):4: warning: toplevel constant File referenced by ContentItem::File
=&amp;gt; File
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I was wondering what I was doing wrong, it took me awhile to figure out,
but then &lt;a href=&quot;http://stackoverflow.com/questions/17695557/rails-organizing-models-in-subfolders-having-warning-toplevel-constant-a-refer&quot;&gt;this&lt;/a&gt; stack overflow answer beautifully explained it.&lt;/p&gt;

&lt;p&gt;It seems that naming classes under modules that have the same name in
the global space is a bad idea because of how ruby resolves classes.
So as a workaround, just to be safe, I always try to name my classes
diffrently from any of the gem/lib classes that I use. So for this use case,
I can use &lt;code&gt;MyModule::FileItem&lt;/code&gt;.&lt;/p&gt;

</description>
        <pubDate>Wed, 13 Nov 2013 11:00:00 +0800</pubDate>
        <link>http://westoque.com/2013/11/13/a-huge-ruby-problem.html</link>
        <guid isPermaLink="true">http://westoque.com/2013/11/13/a-huge-ruby-problem.html</guid>
        
        
      </item>
    
      <item>
        <title>Add a &quot;context&quot; Block to Rails Tests</title>
        <description>&lt;p&gt;I’ve been ranting for awhile now on how hard it is to organize your
tests in &lt;a href=&quot;http://rubyonrails.org&quot;&gt;rails&lt;/a&gt; using its default test framework. Meaning it doesn’t
provide a &lt;code&gt;context&lt;/code&gt; or &lt;code&gt;describe&lt;/code&gt; block like &lt;a href=&quot;https://github.com/thoughtbot/shoulda&quot;&gt;shoulda&lt;/a&gt; or &lt;a href=&quot;https://github.com/rspec/rspec&quot;&gt;rspec&lt;/a&gt;
does.&lt;/p&gt;

&lt;p&gt;Although recently I think I found the solution. Randomly looking around
the &lt;a href=&quot;https://github.com/plataformatec/devise&quot;&gt;devise&lt;/a&gt; library code, I found this little snippet that adds “context”
blocks to the default test framework so its easier to organize your tests.&lt;/p&gt;

&lt;p&gt;Here’s an example:&lt;/p&gt;

&lt;p&gt;```ruby
class SampleTest &amp;lt; ActiveSupport::TestCase
  #
  # This method lets us add “context” blocks in our tests
  #
  def self.context(name, &amp;amp;block)
    instance_eval(&amp;amp;block)
  end&lt;/p&gt;

&lt;p&gt;# We can then use the context block…
  context “When saving” do
    test “should validate name” do
      # …
    end
  end
end
```&lt;/p&gt;

&lt;p&gt;So there you go. A quick way of adding &lt;code&gt;context&lt;/code&gt; blocks to Rails.&lt;/p&gt;

</description>
        <pubDate>Tue, 12 Nov 2013 06:00:00 +0800</pubDate>
        <link>http://westoque.com/2013/11/12/add-a-context-block-to-rails-tests.html</link>
        <guid isPermaLink="true">http://westoque.com/2013/11/12/add-a-context-block-to-rails-tests.html</guid>
        
        
      </item>
    
      <item>
        <title>Coding is not Computer Science</title>
        <description>&lt;p&gt;Programming in college definitely taught me a lot of things. Mostly
about data structures and things we consider to be good and fast design.
I found them to be extremely useful when working on very “complex”
problems.&lt;/p&gt;

&lt;p&gt;Although recently, I dedicated some time to teach some people how to
program. Most of them did not take Computer Science or take any
programming classes before so I thought it would be an interesting
experience. What I discovered was that it was easier for people to
understand the uses of the piece of code by explaining it to them
simply without the scientific bullshit.&lt;/p&gt;

&lt;p&gt;For example, in Ruby, I would have an Array that I’ll use as a Stack.
And going back to our data structures class, we know that we can &lt;em&gt;push&lt;/em&gt;
and &lt;em&gt;pop&lt;/em&gt; from this Stack. So instead of explaining how Stacks work,
we can just ask ourselves on what we wanted to do with our Array. Do
we want to put something in the start or end of it? Then, we figure out
what the method is by googling or looking at documentation. I’ve found
this to be the most effective method to get people to start building
things and not worry about the technicalities. Sometimes, technicalities
make things more complicated and also tends to scare people off.&lt;/p&gt;

&lt;p&gt;Of course, this is not the path to becoming the next amazing developer
but through time, they will get exposed to more things that will lead
them to learn deeper topics, slowly.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://news.ycombinator.com/item?id=6424228&quot;&gt;Discuss on hacker news.&lt;/a&gt;&lt;/p&gt;

</description>
        <pubDate>Sat, 21 Sep 2013 06:00:00 +0800</pubDate>
        <link>http://westoque.com/2013/09/21/coding-is-not-computer-science.html</link>
        <guid isPermaLink="true">http://westoque.com/2013/09/21/coding-is-not-computer-science.html</guid>
        
        
      </item>
    
  </channel>
</rss>
