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

Remove usage of the getTag and setTag methods #1740

Open
wants to merge 10 commits into
base: georgie
Choose a base branch
from

Conversation

JohnMcGuinness
Copy link
Contributor

The WComponent::getTag and WComponent::setTag methods are deprecated and
are used by WDefinitionList to attach a term to a component. Using a
tag to store this term is replaced with using an attribute instead.
Partly addresses #1732

The WComponent::getTag and WComponent::setTag methods are deprecated and
are used by WDefinitionList to attach a term to a component. Using a
tag to store this term is replaced with using an attribute instead.
Copy link
Member

@jonathanaustin jonathanaustin left a comment

Choose a reason for hiding this comment

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

Change looks good.

Just in case projects are using getTag to refer to the value of the term, can you explain in the change log how they can get the value now. But to do this it might be easier to make the static string TERM_ATTRIBUTE public so they can access it.

By not setting the tag property on items added for a term, then the
public API of WDefinitionList is changed. This should be avoided until
the next major version. So, in order to maintain this API the tag for is
set via setTag(), but the tag is not used internally.
@JohnMcGuinness
Copy link
Contributor Author

By not setting the tag property on items added for a term, then the public API of WDefinitionList is changed. I had not considered this before making the change. This type of change should be avoided until the next major version. So, in order to maintain this existing API, and to avoid increasing the size of the API by exposing TERM_ATTRIBUTE, I have made a change to keep setting the tag via setTag(). However, the tag is not used internally.

@JohnMcGuinness JohnMcGuinness self-assigned this Jul 28, 2020
@JohnMcGuinness JohnMcGuinness requested review from jonathanaustin and removed request for jonathanaustin September 4, 2020 07:49
@JohnMcGuinness JohnMcGuinness requested review from jonathanaustin and removed request for jonathanaustin September 24, 2020 07:52
@@ -16,6 +16,8 @@
public class WDefinitionList extends AbstractNamingContextContainer implements AjaxTarget,
SubordinateTarget, Marginable {

private static final String TERM_ATTRIBUTE = "WDefinitionList.term";
Copy link
Member

Choose a reason for hiding this comment

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

Even though the change now sets the term on the tag and the attribute, I think planning ahead for getTag() being removed, it would still be good for the TERM_ATTRIBUTE to be made public and explain how they will need to access the term via the attribute in the change log.

It would also be good to include how to use the attribute in the javadoc of WDefinitionList.

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 don't understand why TERM_ATTRIBUTE should be made public. It should be considered an implementation detail. To add a term you can use addTerm(String, WComponent...) to get all of the terms you can use getTerms() or to get a specific term use getComponentsForTerm(String).

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 could envision a completely different internal implementation where WContainers were used as buckets for the components of each term, and each WComponent bucket, which is unknown to the user, has an attribute with the name of the term. In fact this might be a better implementation.

Copy link
Member

Choose a reason for hiding this comment

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

You are right. The whole implementation of WDefinitionList smells as it originally hijacked the getTag method from the template logic and using the attribute is just as smelly. It might not even be worth doing this change until we consider how it could be refactored and deleting getTag is way off in the future anyway. Let me know what you think.

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

Successfully merging this pull request may close these issues.

Remove usage of deprecated APIs from the framework and examples
2 participants