Question: a . The CaesarCipher and XORCipher classes couple two concerns, the business logic of encrypting data and the mechanics of how to get the input
a The CaesarCipher and XORCipher classes couple two concerns, the business logic of encrypting data and the mechanics of how to get the input from a file on the filesystem and writing the output to a file. This makes it harder to test just the business logic. Using the Hexagonal Architecture pattern we can refactor the encrypt and decrypt methods to use an existing Java type, byte as an abstract port for the input argument and return a byte for the result.
b Using the Dependency Inversion pattern we can do even better by creating an abstract interface called EncryptionMethod that will become the interface between high level client code and the lower level encryptiondecryption methods. In addition to encrypt and decrypt methods we could also put the setPassword method into the interface and add a getPassword method that would return a string representation of the internal password data to make testing setPassword easier.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
