Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DX] Do not hardcode order state in order processors#14935

Merged
GSadee merged 2 commits into
Sylius:1.12from
Zales0123:undhardcode-using-order-state
Apr 14, 2023
Merged

[DX] Do not hardcode order state in order processors#14935
GSadee merged 2 commits into
Sylius:1.12from
Zales0123:undhardcode-using-order-state

Conversation

@Zales0123
Copy link
Copy Markdown
Contributor

Q A
Branch? 1.12
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Related tickets
License MIT

Hello everyone 👋

While browsing our order processors, I figure out that they lack some extendability regarding whether they should be run or not. Most of them have hardcoded check if the $state is cart - which is a good default behavior, but does not have to be right for everyone (imagine we have a draft order, that we still want to process, but is not placed yet). If we want to change that, we would have to override the whole processor just to adjust/remove a simple if at the beginning.

I think such information (whether the order is processable or not) can be a part of the Order entity itself. It's easy to override and we avoid some additional services. We could even go further and have other methods like this for specific cases, but let's start simple.

I believe the general rule of thumb regarding the DX and extendability should be "never use any primitive value directly in the condition in any service" (constant is also a value, as it's not easily replaceable 💃).

Cheers 🚀 🖖

@Zales0123 Zales0123 added Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.). DX Issues and PRs aimed at improving Developer eXperience. labels Apr 14, 2023
@Zales0123 Zales0123 requested a review from a team as a code owner April 14, 2023 06:21
@GSadee GSadee merged commit 1712bfa into Sylius:1.12 Apr 14, 2023
@GSadee
Copy link
Copy Markdown
Member

GSadee commented Apr 14, 2023

Thank you, Mateusz! 🥇

@Zales0123 Zales0123 deleted the undhardcode-using-order-state branch April 14, 2023 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DX Issues and PRs aimed at improving Developer eXperience. Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants