Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Renamed and simplified AttributeCommand. #10

Merged
merged 5 commits into from
Aug 22, 2016
Merged

Renamed and simplified AttributeCommand. #10

merged 5 commits into from
Aug 22, 2016

Conversation

oskarwrobel
Copy link
Contributor

@oskarwrobel oskarwrobel commented Aug 17, 2016

@@ -0,0 +1,50 @@
/**
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it is the right place for those helpers src/command/helpers?

@oskarwrobel
Copy link
Contributor Author

oskarwrobel commented Aug 17, 2016

My second concern is that extracting helpers to separate files makes them difficult to stubbing. Because of it I duplicated some code in tests instead of making a simple spy:

Helper test:
https://github.com/ckeditor/ckeditor5-core/blob/t/9/tests/command/helpers/isattributeallowedinselection.js#L16-L86

Duplicated code in method which uses helper:
https://github.com/ckeditor/ckeditor5-core/blob/t/9/tests/command/toggleattributecommand.js#L206-L264

[Edit]
After talking with @pjasiun I've decided to keep helpers fully tested, but methods where helpers are used are tested basically, so only few test cases are duplicated.

@@ -5,7 +5,7 @@

import Editor from '/ckeditor5/core/editor/editor.js';
import Document from '/ckeditor5/engine/model/document.js';
import AttributeCommand from '/ckeditor5/core/command/attributecommand.js';
import ToggleAttributeCommand from '/ckeditor5/core/command/toggleattributecommand.js';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed AttributeCommand to ToggleAttributeCommand, but now I'm thinking about AttributeTogglerCommand?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I'm still thinking about BooleanAttributeCommand :D. But from the two you proposed, I'm more for ToggleAttributeCommand. It's more in line with the names that we always used (in terms of grammar).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @pjasiun is also for BooleanAttributeCommand. It's OK for me too, so I can change it.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer: ToggleAttributeCommand or even ToggleCommand. The command is an action (AddSomething, RemoveSomething...), it should not be a noun.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, @pjasiun is right. It should be a verb. Though, we used nouns sometimes for features. But perhaps that was wrong – command is an action + state, so its name should indeed represent that and, also, there should be no command like image which insert and edit image at the same time. OTOH, such commands are useful, because they you can use one in your button. Tricky :).

Anyway, ToggleAttributeCommand is fine for me. ToggleCommand isn't, because it doesn't says what it toggles.

@scofalik
Copy link
Contributor

I don't like such long function names and file names but I that's just subjective opinion. Other than that it's ok so I am merging it.

@scofalik scofalik closed this Aug 22, 2016
@scofalik scofalik reopened this Aug 22, 2016
@scofalik scofalik merged commit f865b09 into master Aug 22, 2016
@scofalik scofalik deleted the t/9 branch August 22, 2016 10:35
@Reinmar
Copy link
Member

Reinmar commented Aug 22, 2016

I agree that the naming and location isn't the best. Those functions are not commands' helpers. They can be used by any piece of code. So first of all, we need to understand where they belong (I'm thinking e.g. about the schema itself – perhaps static methods). Then, how they actually can be proposed (we need to understand whether they are part of some closed functionality or their number may grow indefinitely).

@Reinmar
Copy link
Member

Reinmar commented Aug 22, 2016

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

Successfully merging this pull request may close these issues.

Simplify AttributeCommand
5 participants