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

0011 - Use constants for configuration variables #16

Conversation

JevgenijVisockij
Copy link

No description provided.

@matks
Copy link
Contributor

matks commented Jan 5, 2021


## Context

Configuration names in PrestaShop are used as hardcoded strings. It makes it harder to figure out
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you provide a few examples of such configuration names and how they are used in the code ? (just to make it easier for reader to understand the topic, this ADR also serves as documentation for people in the future)

Copy link
Author

Choose a reason for hiding this comment

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

Updated the PR to include examples.


## Consequences

What becomes easier :
Copy link
Contributor

Choose a reason for hiding this comment

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

To be honest, we must also list the drawbacks 😄 . This means for example we need to require or use the Configuration class everywhere.

Copy link
Author

Choose a reason for hiding this comment

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

Added 2 drawbacks, couldn't think of more at the moment.

Copy link
Contributor

@matks matks left a comment

Choose a reason for hiding this comment

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

PR looks good to me. Complete. Ready to discuss and vote.

@matks
Copy link
Contributor

matks commented Jan 12, 2021

@PrestaShop/prestashop-core-developers Can you check this and ask questions if you have? Else we can start the voting phase.

@Progi1984
Copy link
Member

@matks You should ping @PrestaShop/prestashop-maintainers. May we should create a meeting for all ADRs?

Copy link

@matthieu-rolland matthieu-rolland left a comment

Choose a reason for hiding this comment

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

Being working on the configuration forms at the moment, I wholeheartedly agree with this ADR.

About the drawbacks, they are minor in my opinion, this could be implemented progressively.

PS_SHOP_ENABLE

It makes it harder to figure out which configurations are available, also leaves possibility for mistyping configuration name without noticing.

Copy link

@matthieu-rolland matthieu-rolland Jan 14, 2021

Choose a reason for hiding this comment

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

Also, configuration names don't always match the names of configuration form fields, for example, form field enable_shop is linked to the configuration name PS_SHOP_ENABLE. (and not PS_ENABLE_SHOP as we would intuitively guess).

Using constants would make it less error-prone.

@kpodemski
Copy link
Contributor

I like the idea, I'm not sure if main Configuration class is good for those statics,

Configuration::get(Configuration:PS_SHOP_NAME);
`Configuration::get(ConfigKey::PS_SHOP_NAME);

use ConfigurationKeys as Key;
`Configuration::get(Key::PS_SHOP_NAME);

I don't think it's that important, I'm thinking aloud :)

@PierreRambaud
Copy link
Contributor

I like the idea, I'm not sure if main Configuration class is good for those statics,

Configuration::get(Configuration:PS_SHOP_NAME);
`Configuration::get(ConfigKey::PS_SHOP_NAME);

use ConfigurationKeys as Key;
`Configuration::get(Key::PS_SHOP_NAME);

I don't think it's that important, I'm thinking aloud :)

As I said in the PR, I'm like @kpodemski, using ConfigurationCore class isn't the best one (imho). I'm not even sure about the ConfigurationKeys class too 😅 but maybe in the adapter?

@PierreRambaud
Copy link
Contributor

Hi @PrestaShop/prestashop-maintainers , I'm not sure it's a good idea to keep ADR for months. If it's not relevant, maybe it's time to close it? 🤔

@matks
Copy link
Contributor

matks commented Oct 13, 2021

Yes :( unfortunately ADR are a costly process as it requires time from each maintainer to explore and discuss the topic, so it's hard to be able to get everybody's attention and investment on a single topic. This topic did not make it.

@matks matks closed this Oct 13, 2021
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.

6 participants