Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

23
  • 29
    I didn't downvote but the rationale might be the ridiculous amount of new classes/interfaces to do something the original code did in 8 lines (and the other answer did in 5). In my opinion the only thing it accomplishes is increasing the learning curve for the code. Commented Jan 1, 2016 at 18:46
  • 6
    @Maurycy What OP asked was to try to find a solution to his problem using common design patterns, if such solution exist. Is my solution longer than his or Ixrec's code? It is. I do admit that. Does my solution solve his problem using design patterns and thus answers his question and also effectively removing all the necessary ifs from the process? It does. Ixrec's does not. Commented Jan 1, 2016 at 19:03
  • 27
    I believe that writing code that is clear, reliable, concise, performant and maintainable is the way to go. If I had a dollar for every time someone cited SOLID or quoted a software pattern without clearly articulating their goals and their rationale, I'd be a rich man. Commented Jan 1, 2016 at 19:14
  • 12
    I think I have two issues I see here. First is that the Compression and Encryption interfaces seem totally superfluous. I'm not sure if you are suggesting that they are somehow necessary to the decoration process, or merely implying that they represent extracted concepts. The second issue is that making a class like CompressionEncryptionDecorator leads to the same kind of combinatorial explosion as the OP's conditionals. I'm also not seeing the decorator pattern clearly enough in the code suggested. Commented Jan 1, 2016 at 19:31
  • 5
    The debate on SOLID vs. simple is kinda missing the point: this code is neither, and it also does not use the decorator pattern. Code is not automatically SOLID just because it uses a bunch of interfaces. Dependency injection of a DataProcessing interface is kinda nice; everything else is superfluous. SOLID is an architecture-level concern aimed at handling change well. OP gave no information about his architecture nor how he expects his code to change, so we can't really even discuss SOLID in an answer. Commented Jan 2, 2016 at 3:05