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

changing description and example to add more clarification #322

Merged
merged 9 commits into from Mar 17, 2020

Conversation

@h4ppysmile
Copy link
Contributor

@h4ppysmile h4ppysmile commented Mar 12, 2020

add more clarification

add more clarification
@gyermolenko
Copy link
Contributor

@gyermolenko gyermolenko commented Mar 12, 2020

"add more clarification" PR description is misleading. You change example itself.
As for the code itself:

  1. If class has only one method (as in on_press or execute) and no state - it is a candidate for a function. It doesn't mean the example is bad or good. Just not "pythonic"?
  2. Current implementation shows popular use case for Commands - possibility to store them and perform "undo".
  3. Once again, I don't like abstract classes for such examples.

Please take these comments just as an opinion and a ground for discussion.

class MakeBoldCommand(Command):
"""
A simple command to bold a text.
"""

def execute(self):

This comment has been minimized.

@faif

faif Mar 12, 2020
Owner

To show the effect of the command it is good to have some definition of bold. Maybe in this case wrap the text with the HTML <b> or <strong> element. The same goes for italic.

@h4ppysmile h4ppysmile changed the title Update commad pattern changing description and example to add more clarification Mar 14, 2020
@h4ppysmile
Copy link
Contributor Author

@h4ppysmile h4ppysmile commented Mar 14, 2020

Hi guys!
Would you please check the code?

@gyermolenko @faif

patterns/behavioral/command.py Outdated Show resolved Hide resolved
def rename(self, src, dest):
print("renaming {} to {}".format(src, dest))
os.rename(src, dest)
def on_do_press(self, filename):

This comment has been minimized.

@gyermolenko

gyermolenko Mar 15, 2020
Contributor

I think names like on_do_press and on_undo_press are harder to read then rename, delete or whatever else

This comment has been minimized.

@h4ppysmile

h4ppysmile Mar 15, 2020
Author Contributor

You are right, but the invoker (here is the menu item) does not know what is going to do.

Am I right?

@gyermolenko
Copy link
Contributor

@gyermolenko gyermolenko commented Mar 15, 2020

Can we think of example without actual os files manipulations? Deleting files is a bit dangerous and not really necessary here.

patterns/behavioral/command.py Outdated Show resolved Hide resolved
@faif faif merged commit 697deba into faif:master Mar 17, 2020
@h4ppysmile h4ppysmile deleted the h4ppysmile:patch-1 branch Mar 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.