LuckyStarr
Programmer
Hi,
I have a system written in Java that shares the same code for three different versions. The version logic is made using IFs, like the example:
This code snippet is spread all over the system code. However, when a new version is released, I have a big problem: modify each single if to update the version constants. There are a lot of them, near 100 ifs. It's very error prone.
My question is: Is there a design pattern that I could use to improve the code, to ease the new version's pain?
Thanks.
---
There is no Knowledge that is not power
---
I have a system written in Java that shares the same code for three different versions. The version logic is made using IFs, like the example:
Code:
if(currentRelease == ManagedProducts.SW_540){
...
}
else if(currentRelease == ManagedProducts.SW_530){
...
}
else if(currentRelease == ManagedProducts.SW_520){
...
}
This code snippet is spread all over the system code. However, when a new version is released, I have a big problem: modify each single if to update the version constants. There are a lot of them, near 100 ifs. It's very error prone.
My question is: Is there a design pattern that I could use to improve the code, to ease the new version's pain?
Thanks.
---
There is no Knowledge that is not power
---