I'm going to save some string payload in the database.But I've I have two global configurations encryption and compress.We:
- encryption
- compression
These can enablebe enabled or disabled using the configuration in a way that either only one of configthem is enabled, both are enabled or both of themare disabled.
My current implementation likeis this.:
if (encryptionEnable && !compressEnable) { encrypt(data); } else if (!encryptionEnable && compressEnable) { compress(data); } else if (encryptionEnable && compressEnable) { encrypt(compress(data)); } else { data; } I'm thinking about the Decorator pattern.Please help me out find good design pattern to handle this. Is it the right choice, or is there perhaps a better alternative?