Click here to Skip to main content
15,896,459 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Ruby on Rails Pin
Luiz Monad13-Jan-14 3:01
professionalLuiz Monad13-Jan-14 3:01 
GeneralRe: Ruby on Rails Pin
Garth J Lancaster11-Jan-14 17:29
professionalGarth J Lancaster11-Jan-14 17:29 
GeneralRe: Ruby on Rails Pin
walterhevedeich12-Jan-14 15:46
professionalwalterhevedeich12-Jan-14 15:46 
GeneralRe: Ruby on Rails Pin
Sampath Lokuge11-Jan-14 19:58
Sampath Lokuge11-Jan-14 19:58 
GeneralRe: Ruby on Rails Pin
Marc Clifton12-Jan-14 2:33
mvaMarc Clifton12-Jan-14 2:33 
GeneralRe: Ruby on Rails Pin
Sampath Lokuge12-Jan-14 2:45
Sampath Lokuge12-Jan-14 2:45 
GeneralRe: Ruby on Rails Pin
Dan Neely13-Jan-14 2:34
Dan Neely13-Jan-14 2:34 
GeneralRe: Ruby on Rails Pin
Marc Clifton13-Jan-14 3:39
mvaMarc Clifton13-Jan-14 3:39 
Dan Neely wrote:
and am finding about 2/3rds of my debug time is being spent on issues that a compiled/strongly typed language would've called me out on immediately;


Absolutely. Duck-typing is a productivity-killer in my opinion. Type inference is another killer in an interpreted context. At least in F#, the IDE detects issues even before you compile the code, though it is possible to fool it.

To help with that, what I do is the following:

* I use very descriptive function names, variable names, and parameter names
* I write very small functions that do just one thing
* I comment every single function, describing the input and output types so I know how to use the function later on
* I heavily comment the code
* I refactor constantly -- as soon as I see some duplicate code, I refactor it into a single function
* I step through every line of code (I tend to do that in C# as well, so it's not really a development hit)
* I explicitly specify the return value, even if it's redundant.
* Liberal use of white space.

Notice I didn't say that I write tests or work in a TDD paradigm. The main reason is that it takes a while to fire up the unit tests, which is yet another hit on development time, not to mention writing the tests.

Lastly, there's a lot of "idiomatic" Ruby which is really cool and sexy and geeky but is totally incomprehensible at first glance. I always refactor those into functions that explicitly state what's going on. The idea is that the high level code should tell me what it's doing, and the low level code tells me how it's doing it.

Here's an example:

How:

# Given comma separated values in a string, returns an array of strings, stripping leading
# and trailing whitespace.
def csv_to_array(csv)
  array = csv.split(',').collect{|s| s.strip}

  array
end


What:

# Adds children (given in csv format) to an entity.
def add_children(entity, csv_children)
  child_list = csv_to_array(csv_children)
  entity.add_children(child_list, self.project_id)
end


Hope that helps! (And gee, I think I'm going to copy this reply and post it on my blog!)

Marc
GeneralRe: Ruby on Rails Pin
Dan Neely13-Jan-14 4:03
Dan Neely13-Jan-14 4:03 
GeneralRe: Ruby on Rails Pin
Marc Clifton13-Jan-14 4:12
mvaMarc Clifton13-Jan-14 4:12 
GeneralRe: Ruby on Rails Pin
Dan Neely13-Jan-14 4:46
Dan Neely13-Jan-14 4:46 
GeneralRe: Ruby on Rails Pin
Marc Clifton13-Jan-14 4:50
mvaMarc Clifton13-Jan-14 4:50 
GeneralRe: Ruby on Rails Pin
Dan Neely13-Jan-14 4:55
Dan Neely13-Jan-14 4:55 
GeneralRe: Ruby on Rails Pin
JamesHurst14-Jan-14 9:03
JamesHurst14-Jan-14 9:03 
GeneralRe: Ruby on Rails Pin
Marc Clifton12-Jan-14 2:24
mvaMarc Clifton12-Jan-14 2:24 
GeneralRe: Ruby on Rails Pin
Brisingr Aerowing12-Jan-14 2:59
professionalBrisingr Aerowing12-Jan-14 2:59 
GeneralRe: Ruby on Rails Pin
thomas.michaud13-Jan-14 3:50
thomas.michaud13-Jan-14 3:50 
GeneralRe: Ruby on Rails Pin
Brisingr Aerowing12-Jan-14 4:47
professionalBrisingr Aerowing12-Jan-14 4:47 
GeneralRe: Ruby on Rails Pin
Marc Clifton12-Jan-14 7:33
mvaMarc Clifton12-Jan-14 7:33 
GeneralRe: Ruby on Rails Pin
Brisingr Aerowing12-Jan-14 7:47
professionalBrisingr Aerowing12-Jan-14 7:47 
GeneralRe: Ruby on Rails Pin
Marc Clifton12-Jan-14 7:49
mvaMarc Clifton12-Jan-14 7:49 
GeneralRe: Ruby on Rails Pin
Adilson Carvalho13-Jan-14 0:06
Adilson Carvalho13-Jan-14 0:06 
GeneralRe: Ruby on Rails Pin
ssa-ed13-Jan-14 6:53
ssa-ed13-Jan-14 6:53 
GeneralMight be worth a look see Pin
Mike Hankey11-Jan-14 12:05
mveMike Hankey11-Jan-14 12:05 
GeneralRe: Might be worth a look see Pin
Ron Beyer11-Jan-14 12:15
professionalRon Beyer11-Jan-14 12:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.