Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about command pattern in Ruby #16

Open
RomanADavis opened this issue Jun 16, 2017 · 0 comments
Open

Question about command pattern in Ruby #16

RomanADavis opened this issue Jun 16, 2017 · 0 comments

Comments

@RomanADavis
Copy link

I've actually wanted to use a pattern like this in Ruby, where I've wanted an object to do some nonstandard behavior and then do some standard behavior. For example, an OpCode class that executes a certain operation argument then changes the value of the address in memory for a simple emulator, or a Spell class that checks if the Character casting it has enough magic_points to cast the spell, fails if it doesn't, subtracts mp_cost argument from the character casting it and executes the spell_formula argument.

The thing is, in Ruby I didn't create a special operation or spell_formula class to pass around a method / command as an argument. I used a lambda.

It would be nice if the description of this pattern was expanded to include the pros and cons of this method, since from my perspective it just seems like the natural and dare-I-say-it, ruby way to do things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant