F
flebber
HI I am hoping you can give me some guidance. I feel I really am
getting Ruby, far more than I got python I am doing more now in a
couple of weeks than I did with python.
However I just need to get my head around the flow of transactions to
ensure I am not breaking the DRY principle and defeating the purpose
of object orientation.
If this is my proposed flow how can I do it better to be more ruby? I
am happy to do more reading but not always sure what I should
belooking up. I have tried to comment it to make as much sense as
possible.
This is my proposed flow. My main concern is around the option
calculations and selections.
def foo
some function
end
# get user input
user input 1
user input 2
pass user variables through foo, each option has different set
variables
??? Should I be using a foreach case statement here or am I someway
missing the
??? the point of object oriented language?
??? Should it be option1.foo, option2.foo etc
option1
foo(set of variables, user input 1)
# set of variables will be different for each option
# Sets will have same variable types but different values
option 2
foo(set of variables, user input 1)
foo(set of variables, user input 2)
option 3
foo(set of variables, user input 1)
foo(set of variables, user input 2)
option 4
foo(set of variables, user input 1)
foo(set of variables, user input 2)
# If result of both tests in an option proves true then output
options.
To_user valid options are
option 1
this is what the results are
option 3
this is what the results are
To_user please choose an option or none to start again.
# select case if I list the 5 cases here for a user to select how can
I limit the
# selection to valid input only????
If option 1
get some details
send to file dated with date user supplied
send to database
get user more calcs or end?
getting Ruby, far more than I got python I am doing more now in a
couple of weeks than I did with python.
However I just need to get my head around the flow of transactions to
ensure I am not breaking the DRY principle and defeating the purpose
of object orientation.
If this is my proposed flow how can I do it better to be more ruby? I
am happy to do more reading but not always sure what I should
belooking up. I have tried to comment it to make as much sense as
possible.
This is my proposed flow. My main concern is around the option
calculations and selections.
def foo
some function
end
# get user input
user input 1
user input 2
pass user variables through foo, each option has different set
variables
??? Should I be using a foreach case statement here or am I someway
missing the
??? the point of object oriented language?
??? Should it be option1.foo, option2.foo etc
option1
foo(set of variables, user input 1)
# set of variables will be different for each option
# Sets will have same variable types but different values
option 2
foo(set of variables, user input 1)
foo(set of variables, user input 2)
option 3
foo(set of variables, user input 1)
foo(set of variables, user input 2)
option 4
foo(set of variables, user input 1)
foo(set of variables, user input 2)
# If result of both tests in an option proves true then output
options.
To_user valid options are
option 1
this is what the results are
option 3
this is what the results are
To_user please choose an option or none to start again.
# select case if I list the 5 cases here for a user to select how can
I limit the
# selection to valid input only????
If option 1
get some details
send to file dated with date user supplied
send to database
get user more calcs or end?