Uh oh!
There was an error while loading. Please reload this page.
Salesperson assignment submission - #13
Conversation
codeblahblah
commented
Feb 25, 2014
@jwo Created a separate file for the Benchmarking named salesperson_bm.rb |
codeblahblah
commented
Feb 26, 2014
@jwo The route distance calculation is working however I am "losing" the original city schedule after the CalculateRoute#route invocation. |
codeblahblah
commented
Feb 27, 2014
@jwo It seems the |
jwo
commented
Feb 27, 2014
I haven't looked into this fully, but yes, Witness another example: word="Sheep"word.gsub!("ee","o")=>"Shop"putsword"Shop"word="Sheep"word.gsub("ee","o")=>"Shop"putsword"Sheep"You'll see this all over ruby. |
codeblahblah
commented
Feb 28, 2014
@jwo Gotcha! |
codeblahblah
commented
Feb 28, 2014
@jwo Some questions... Can the starting point method be refactored or simplified? Anytime I see an IF stament in a 'each' loop, I perceive it to be a good smell? When would you use variables versus a Hash for object initialization e.g. Benchmarking code: RSpec: How would you convert 28.83 hours to a more readable human format? Are there any Gems for such? When does one decide to go use a Gem versus hack their own solution? |
jwo
commented
Mar 5, 2014
This does seem very complicated. I recommend you rewrite into english, and have the methods do those things. cities.each_indexdo |index|
cities.insert(0,cities.delete_at(index))ifcities[index].starting_point == trueendIf you are looking to have the cities without the starting point, this could be useful: cites.reject{|c| c.starting_point} |
jwo
commented
Mar 5, 2014
You probably mean "code smell", which is bad. I agree. |
jwo
commented
Mar 5, 2014
Good Guidline to follow: You can send 0, 1, or 2 variables to any method, including initialization. Any more than that, use a hash. |
jwo
commented
Mar 5, 2014
For converting 28.83 hours -- check out these: |
jwo
commented
Mar 5, 2014
BTW, code overall is really good |
jwo
commented
Mar 5, 2014
This will make your tests pass: You could tell this because the failure message told you: |
codeblahblah
commented
Mar 5, 2014
@jwo Thanks for the feedback and encouragement. Side note: I'm working on the Gem assignment and get a load path error when On Wednesday, March 5, 2014, Jesse Wolgamott notifications@github.com
"When you are tired of being yourself then you can be ordinary." - dudu |
jwo
commented
Mar 5, 2014
"about-drammopo" -- means You want the second. As far as "jeweler" -- not used much anymore. |
codeblahblah
commented
Mar 10, 2014
@ jwo I'm stuck here: Using your This is the code: But I get a NilClass error below: |
jwo
commented
Mar 10, 2014
It's probably best to isolate the problem; it can illuminate issues that seem hard to find. The error you entered looks like it has a nil in the array - can you prove/disprove this? On Mon, Mar 10, 2014 at 2:35 PM, drammopo notifications@github.com
|
codeblahblah
commented
Mar 11, 2014
@jwo Isolating the problem worked! I wrote it down in simplified English and it became clearer. Pity you cannot multiple assign arrays thus my: |
jwo
commented
Mar 12, 2014
AWESOME! unrouted_cities << cityunlessunrouted_cities.include?(city)cities << cityunlesscities.include?(city)Well, let's see what we can do. If we want to send an item into two arrays, maybe we could: [unrouted_cities,cities].each{|a| a << city}unlesscities.include?(city)That might read better... what do you think? |
codeblahblah
commented
Mar 12, 2014
@jwo GREAT! |
@jwo Completed the Panda Level.
Had to comment out the tests below as they used stubs:
Pending:
SalesPerson should have many cities
# Temporarily disabled with xit
# ./spec/sales_person_spec.rb:7
SalesPerson should keep the cities only scheduled once
# Temporarily disabled with xit
# ./spec/sales_person_spec.rb:13
Is this approach correct?
New code: