An Illustration Of Decoupling - Part II of II

Part I of this blog post described a simplified, real-world, design problem and two proposed solutions.  This part critiques the two proposals but begins by explaining the additional shortcomings of the existing solution.

Additional Problems:

  • Output file name collisions can occur as inputs may differ only in their path, improbable though it may be given the business context
  • Client code may want to disregard the current base name and use a different name.  It would be nice to avoid copying (because rename is not available)

Proposal 1

Benefits:

 (none)

Problems:

  • Assumes the path and file name have contextual value that should be retained
  • What happens if the prefix doesn't match?

Proposal 2

Benefits:

  • Solves problem of collisions (assuming outputPrefix's are unique)
  • Offers ability to rename or rearrange folder structure
  • Avoid having to do string processing of input


Problems:

  • No need to offer renaming at this point in time
  • Output file name collisions are highly improbably

Conclusion

The correct answer in my opinion is the second proposal.  Essentially, the inputs can be completely decoupled from the outputs for little to no overhead.

As you might have guessed, I offered the second proposal.  However, the first proposal was accepted by the team.

Comments

Popular Posts