Skip to content

0011 - Use constants for configuration variables#16

Closed
JevgenijVisockij wants to merge 5 commits intoPrestaShop:masterfrom
JevgenijVisockij:0011-use-constantas-for-configuration-variables
Closed

0011 - Use constants for configuration variables#16
JevgenijVisockij wants to merge 5 commits intoPrestaShop:masterfrom
JevgenijVisockij:0011-use-constantas-for-configuration-variables

Conversation

@JevgenijVisockij
Copy link
Copy Markdown

No description provided.

@matks
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

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

Copy link
Copy Markdown

@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
Copy Markdown

@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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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