itomek/ConsoleWeather — pull request #1 by millsb (2012-10-28 17:23:33+00:00)
Title: notes

Hey There!

I made some notes and a few refactors. Overall, it looks pretty solid, but there's just some Ruby specific stuff I wanted to cover. Ruby's kind of weird in that it offers you lots fo ways to do things, but the community itself kind of has an agreed upon set of stylistic standards that are often referred to as the 'ruby way.' This becomes a lot more obvious once you start working with it more, or start looking at other people's code.

One thing I didn't cover in my comments was the standard naming and casing conventions (cause when in Rome...).

- Class names use CamelCase, like in C#: `YahooWeather` is correct, but the file itself should be named `yahoo_weather.rb`
- Variable and method names are lower case, with underscores, so: `get_weather` and `parse_xml(xml)`

Parens are optional in many cases, and are often left off. If the parens are going to be empty, leave them out entirely. Parens are also often left off when calling methods with arguments. I think the idea is to construct method names and arguments in a way that has kind of a natural language feel, and only use parens when it enhances code readability. So:

# feels natural to write without parens
attr_accessor :foo, :bar, :baz
add_column :user, :name, :null => false
if 1 == 2

# Not so natural
authenticate(User.find(id))

Let me know if you have any questions!