New answers tagged

2

Consistency Sometimes you use accessor methods, sometimes you access instance variables directly. Sometimes you use parentheses around message send arguments, sometimes you don't. You should choose one style and stick with it. If you are editing some existing code, you should adapt your style to be the same as the existing code. If you are part of a team, ...


2

I'm not a Ruby programmer, but there are a couple of general improvements I can think of for this code: Better initialization: There is no need to pass the random number and num_of_guess to the class. Generating a random number is part of the core definition of this game, and I will put it in the class. For num_of_guess, just set it to zero. There's no ...


0

So, the first problem I'd try to address is that you're running SQL queries in your views. This is generally considered a bad practice (and there are helpful gems/frameworks that will throw errors if you try to do this). The second major issue is the # of sql queries being run, as we're executing multiple queries for each measurement (1+N problem). This is ...


1

Your "method missing" implementation responds to every method with the same result, ignoring the method name. Essentially you're letting someone call BalanceService.new(data).this_method_does_not_exist == BalanceService.new(data).neither_does_this_one and get true. I cannot imagine a reason to do this. Do you mean to call @ field_data .get_#{method}...


1

You balance class does not have a field_data method. def fetch_fields value = BalanceService.new(field_data) value.field_data # this method does not exist end So you could implement a attr_reader :field_data but that would be undefined with undef_method (which I don't really get what this is for). This should work class BalanceService ...


-2

there is many way to refactor this first change operator into integer/enum instead string, or change operator to become an object/table instead with a name and order column so that we can sort the browsings/ftpdl/ftp ul using operator column more easier then to simplify the loop and query we can transform it into and array first then render the table row/...


Top 50 recent answers are included