Not sure if anyone is reading any of this, but figured I would update it
to show what things I'm doing to try and resolve my own code and clean
it up.
First, I took a step back and realized I was doing too much in my rake
file, and not enough in the model. So, all I have in my rake file for
this particular ratings bit is:
update_tsrs = TsrsRating.new
offensive_opponent_ratings = []
offensive_opponent_ratings = update_tsrs.calculate_ratings(Schedule,
TsosOffense)
offensive_opponent_ratings.each_with_index do |row,i|
puts " Team ID of #{i+1} has opponent ratings of #{row}"
end
that's it...
The model then does all of the real work and returns the end result back
to the rake file to be held in queue until all the tallies are
completed.
I also realized that I wasn't keeping things DRY. I should have created
a class for the entire routine - so I did. I created a class that holds
the entire routine and made it so that I can call it with the remainder
of my ratings subtasks..
This should help.
I also realized that it doesn't matter what my array and variable names
are so long as they are easy to read. Before they weren't. I was even
getting lost myself.
So, I made them simpler to read using names like:
opponent_strength
opponent_array
opponent_ids
find_opponent_by_id
etc.
So, now I can at least read my own code which is hopefully a good thing.
I still have the same times loops and array loops in my code as I listed
in pastie. I will have to work at cleaning that up as well.
Thanks.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---