Tell me more ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

I'm working a simple Blackjack game for the CLI. While it works, I am having trouble refactoring it and was wondering if anyone could give me some advice as to what parts of the program look bulky and could be slimmed down. Any help would be appreciated. You can find it here.

share|improve this question
3  
Hello! Please include some code in the question, not just a link to it. – Quentin Pradet Mar 6 '12 at 7:53

closed as off topic by palacsint, Michael K Jul 31 '12 at 13:52

Questions on Code Review Stack Exchange are expected to relate to code review request within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

1 Answer

It will be better, if you post some of code examples here.

https://github.com/latinforadapt/blackjack/blob/master/deck.rb

1) Where is line breaks? Please, separate your methods by line breaks, it will increase your code readability.

2)

@card_values = %w[Ace 2 3 4 5 6 7 8 9 10 Jack Queen King]

Use CONSTANTS for values which will not change.

3)

def suits
@heart_suit = @card_values.map {|x| x + " of Hearts"}

What sux, all of this staff should be placed in initialize method. Or it should me memoizable.

http://stackoverflow.com/questions/7236772/what-are-the-drawbacks-of-using-syntax-to-perform-memoization

4)

$shuffled_deck = ((@heart_suit + @diamond_suit + @club_suit + @spade_suit) * @number_of_decks).shuffle

Why you use global variable? :) This should be in class level method.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.