aerospike / aerospike-client-java

Aerospike Java Client Library
Other
236 stars 212 forks source link

Set 2 - Refactoring Changes #255

Closed prxtik closed 1 year ago

prxtik commented 1 year ago
  1. login() in AdminCommand.java The login method now delegates to three private methods: loginInternal, loginPKI, and loginExternal. In this case, the login method contains different sections of code that are executed based on the authentication mode (INTERNAL, PKI, or EXTERNAL). The refactoring aims to split the code into separate methods based on the authentication mode. As a result, the original login method will now call one of three new methods based on the authentication mode: loginInternal, loginPKI, or loginExternal. Each of these new methods will contain the code for a specific authentication mode. The reason for creating these new methods is to improve the readability and maintainability of the code. By separating the code into smaller, more focused methods, it becomes easier to understand and modify. Additionally, it helps to reduce duplication of code since the logic for each authentication mode is contained in its own method.

  2. bins[] in ExpectedValue.java In the refactored code, the bins array has been moved to private methods read and write to allow for persistence between calls. The validate method now takes the bins array as a parameter, which can be passed to it from the benchmarking code. The max variable is calculated inside the validate method based on the length of the bins array parameter.

  3. genValue() in Arguments.java In the given code snippet, the method genValue contains a switch statement that chooses the behavior based on the spec.type parameter. The refactoring involves creating a separate class for each type of behavior and making them implement a common interface (e.g., ValueGenerator). The genValue method is now replaced with a factory method that creates the appropriate object based on the spec.type parameter and delegates the behavior to the created object.

BrianNichols commented 1 year ago

We generally don't accept refactoring pull requests.