Following "Learning Ruby the Hard Way" chapter 36, I am writing my own game. The player enters a kitchen. Whether he gets breakfast, lunch, or dinner depends on the time.
I wrote a function clock that gives:
time_of_day = t.strftime "%H:%M"
then checks to see if it's a Sunday. I wrote a kitchen function with an array of choices:
food_choice = ["breakfast", "lunch", "dinner"]
Where is it best to put the logic that determines which meal the character gets? I'm guessing in the kitchen function, so the clock stays clean. But I could put something in the clock function that returns
meal_choice = ['a', 'b', 'c']
as it were.
                        
You can talk with your classes/functions to see if they have a single responsibility ( one of the OOP stuff ). This means that entity ( class or function ) has a purpose and everything it does is strictly bound to this purpose. E.G.
Hey, mr. time, what time of the day is it?Sonds ok, right? Now you may ask the question:
Hey, mr. kitchen - what are the meals for now?P.S. If your question sounds strange like
Mr. Man, what is you bicycle tire?don't be afraid to create new entity:mr. bicycle, what is you tire?sound more good.