Showing posts with label Ruby. Show all posts
Showing posts with label Ruby. Show all posts

Sunday, October 6, 2013

One month study at Tealeaf Academy

Some thoughts after one month of study at Tealeaf Academy as follows: 

1. From the ground up!

I tried to study Rails by myself before and it took me a very long time.  It's good and also bad about Ruby codes for they are easy to read and understand.  The good side is you can figure it out what happens with less efforts.  The bad side is I start to believe I can study Rails by my own without others help.  

After few months, I still can not figure out why and how some Ruby codes were written.   Now I learn and know why after I study at Tealeaf since it starts from the ground up!  The lessons of Tealeaf have taught me many important key parts to learn Ruby and Rails and save me a lot of time comparing to self-studying Rails.   The courses are good and also very fast-paced.  I have to work very hard to catch up, sometimes I work very late.  But I am happy with it since I finally know what's going on in Rails!  

2. Hard coding, hard coding and hand coding.....

 Watching the teaching video and reviewing the Rails guide is not really getting those syntax in your head.  Although I realize the ideas and concepts of study materials, but fail to write codes in the editor. After hard coding and mimic the sample codes again and again, I start to be able to memorize the syntax and conventions.  Indeed, "make your hand dirty" is the best way to learn Rails. 

3. Pluralization of Rails convention

Ok, This is a big gap for those who's mother language is not English.  I got stuck at this point for a long time while I study Rails by myself before.  Now I know the convention, it become easier to understand the Rails code.  Here are some notes:

naming:

model (class)                    => singular         ex. Post,        CrazyMonkey
model file                         => singular         ex. post.rb,    crazy_monkey.rb
database table                  => plural             ex. posts,      crazy_monkeys

    # using > 'CrazyMonkey'.tableize  to get the table name

association:

    belongs_to :user   # singular
    has_many   :posts  # plural

Saturday, September 14, 2013

The Ruby Style Guide


Ruby is fun to write.  You can write in many different forms of codes for just doing one thing. There is no rule to follow unless you find one.  The one below is a good one to follow.  I am pretty sure your life will be easier if you go for it.


Beside the guide, there is a style checker for checking codes.   It's quite easy to use, but quite naggy.

Do you use Sublime text 2?  There is a plugin for it.  Have fun.

The Ruby Style Guide


This Ruby style guide recommends best practices so that real-world Ruby programmers can write code that can be maintained by other real-world Ruby programmers. A style guide that reflects real-world usage gets used, and a style guide that holds to an ideal that has been rejected by the people it is supposed to help risks not getting used at all – no matter how good it is.RuboCop

https://github.com/bbatsov/ruby-style-guide

RuboCop


RuboCop is a Ruby code style checker based on the Ruby Style Guide.
https://github.com/bbatsov/rubocop

Sublime RuboCop

A Sublime Text plugin that runs a RuboCop check on the current file or the current project. By default it uses RVM to run RuboCop, but you can switch to rbenv or provide your own command line in the settings.
https://github.com/pderichs/sublime_rubocop