Apr 16, 2008 @ 08:21 pm

Oh, my… God.

What is this? First post in a century? What’s going on here Fleebie? Our beloved readers are going to stop respecting us, and for good reasons.

For those who care, I am not dead, I am not sick… I am just working like crazy on Azanka, the company I started with Dan recently.

Ok now it’s time for a brand new edition of Rubyize this. Let’s get the ball rolling. Hold on… I’m going to google images to get a picture of a ball rolling.

364421257_8cad73e64f.jpg

Hmm… I’m afraid this isn’t going to roll at all

Anyway, consider this :

I am an old and unhappy programmer from the late eighties and you secretly watch me coding the following lines :

class VotingSystem
  #Hello, I am Rodger the old and unhappy programmer. the variable nbrOfVotes is an array of 2 dimensions. The first dimension contains the number of votes for the answer "YES, IT SUCKS"... and the other dimension contain the number of votes for the answer "NO, IT DOESN'T SUCK". In the near future there will be other possible answers... but I don't care! I retire in 2 days!
  @@nbrOfVotes = Array.new

  #The users who sent their vote arrive in this very top secret method!! (I retire in 2 days!)
  def receiveAVote(theVote)
    if theVote == "YES, IT SUCKS"
     @@nbrOfVotes[0] = 0 if @@nbrOfVotes[0].nil?
     @@nbrOfVotes[0] = @@nbrOfVotes[0] + 1
    else
      if theVote == "NO, IT DOESN'T SUCK"
        @@nbrOfVotes[1] = 0 if @@nbrOfVotes[1].nil?
        @@nbrOfVotes[1] = @@nbrOfVotes[1] + 1
      else
          puts "THIS IS NOT A VALID ANSWER YOU MORON... btw i retire in 2 days!"
      end
    end
  end

  #This is the function that compile ALL the votes... I retire in 2 days!
  def compileAllTheVotes
    for i in (0..1)
      if i == 0
        @@nbrOfVotes[0] = 0 if @@nbrOfVotes[0].nil?
        puts "HERE IS THE NUMBER OF VOTES FOR 'YES IT SUCKS' : " + @@nbrOfVotes[0].to_s
      else
        if i == 1
          @@nbrOfVotes[1] = 0 if @@nbrOfVotes[1].nil?
          puts "HERE IS THE NUMBER OF VOTES FOR 'NO IT DOESN'T SUCKS' : " + @@nbrOfVotes[1].to_s
        end
     end
    end
  end
end

Bring the light to this man who retires in 2 days

Refactor this on RMC!

Bookmark this post : These icons link to social bookmarking sites where readers can share and discover new web pages.
  • DZone
  • Reddit
  • del.icio.us
  • Digg
  • Furl
  • Technorati
  • StumbleUpon
Posted under : Easy reading
9 Comments

Rubyize this : 6th edition…

— April 16, 2008 @ 8:37 pm

Rubyize this : 6th edition…

almost the same as Vince. But he did a hell of a job, so there isn’t much left to change….

— April 17, 2008 @ 8:39 am

Rubyize this : 6th edition…

Here is my solution… nothing revolutionary but it does the job. I also added the possibility to vote on multiple questions…

— April 17, 2008 @ 9:13 am

Rubyize this : 6th edition…

not much different than what has already been submitted….

— April 17, 2008 @ 9:53 am

Rubyize this : 6th edition…

— April 17, 2008 @ 2:40 pm

Rubyize this : 6th edition…

Maybe not quite a refactoring……

— April 18, 2008 @ 6:00 pm

Rubyize this : 6th edition…

most of the suggestions are great, here is my one.
while i complied this suggestion i had the following points in mind –
1. extensibility
2. simplicity in terms of exposing api

— April 19, 2008 @ 3:29 am

Rubyize this : 6th edition…

System is a vile word in a class name. It is meaningless and encourages a pile up of concerns that should remain separated.

Since that dude retired 2 weeks ago, I think it’s safe to scrap that piece of code. Normally it’s better to refactor than re-…

— May 3, 2008 @ 8:11 pm

Rubyize this : 6th edition…

May be not the best refactoring – but my own…

— May 26, 2008 @ 5:30 pm




Leave a comment
Name (required)
Email (will not be publish) (required)
Website