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 :

  1. class VotingSystem 
  2.   #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!
  3.   @@nbrOfVotes = Array.new
  4.  
  5.   #The users who sent their vote arrive in this very top secret method!! (I retire in 2 days!)
  6.   def receiveAVote(theVote)
  7.     if theVote == "YES, IT SUCKS"
  8.      @@nbrOfVotes[0] = 0 if @@nbrOfVotes[0].nil?
  9.      @@nbrOfVotes[0] = @@nbrOfVotes[0] + 1
  10.     else
  11.       if theVote == "NO, IT DOESN’T SUCK"
  12.         @@nbrOfVotes[1] = 0 if @@nbrOfVotes[1].nil?
  13.         @@nbrOfVotes[1] = @@nbrOfVotes[1] + 1
  14.       else
  15.           puts "THIS IS NOT A VALID ANSWER YOU MORON… btw i retire in 2 days!"
  16.       end
  17.     end
  18.   end
  19.  
  20.   #This is the function that compile ALL the votes… I retire in 2 days!
  21.   def compileAllTheVotes
  22.     for i in (0..1)
  23.       if i == 0
  24.         @@nbrOfVotes[0] = 0 if @@nbrOfVotes[0].nil?
  25.         puts "HERE IS THE NUMBER OF VOTES FOR ‘YES IT SUCKS’ : " + @@nbrOfVotes[0].to_s
  26.       else
  27.         if i == 1
  28.           @@nbrOfVotes[1] = 0 if @@nbrOfVotes[1].nil?
  29.           puts "HERE IS THE NUMBER OF VOTES FOR ‘NO IT DOESN’T SUCKS’ : " + @@nbrOfVotes[1].to_s
  30.         end
  31.      end
  32.     end
  33.   end
  34. end
  35.  

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
Rate this post :
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...
Posted under : Easy reading
9 Comments
MyAvatars 0.2

Rubyize this : 6th edition…

— April 16, 2008 @ 8:37 pm

MyAvatars 0.2

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

MyAvatars 0.2

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

MyAvatars 0.2

Rubyize this : 6th edition…

not much different than what has already been submitted….

— April 17, 2008 @ 9:53 am

MyAvatars 0.2

Rubyize this : 6th edition…

— April 17, 2008 @ 2:40 pm

MyAvatars 0.2

Rubyize this : 6th edition…

Maybe not quite a refactoring……

— April 18, 2008 @ 6:00 pm

MyAvatars 0.2

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

MyAvatars 0.2

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

MyAvatars 0.2

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