Move from using Result to CommandResult throughout the system.
Whenever updating a command, extract command implementation into a separate class. Look for grouping in the parameter list and consider making them into one class (see Credential object).
Commands should never reference gfsh. Whenever necessary, use CommandContext instead of referencing Gfsh directly.
Get rid of Gfsh’s own flavor of logging completely. Use LogService.
Consider breaking CommandContext into CommandOutputContext and CommandInputContext.
Rule: each command class should only have one command
Rule: command should throw exception rather than return system error result. It should only return the InfoResult or UserErrorResult (any error that doesn’t have a stack trace. Like user specify a dir that doesn’t exist, a member name that doesn’t exist…).
CommandProcessor and GfshExecutionStrategy should use CommandExecutor execute the commands.
CommandExecutor should be the one place that would catch general exceptions thrown by each command.
GfshExecutionStrategy catches the AuthorizationException and other exceptions happening in the transport, anything that escaped CommandExecutor.
Use a single HttpOperationInvoker and a single Controller class to handle all command over http requests.
Rule: whenever we touch a class, add a true unit test for it. Attempt to instantiate an instance by itself.
Investigate why the CommandResult before and after the transport are different.
For http command response, any commands that would result into a file download, return an FileInputStream, otherwise return a StringInputStream. On the client side, it looks into the response content-type header to decide whether to write the stream into a file or turn it into a Result object.
A command can only be either online or offline, can’t be both. (currently we use annotation to denote it, consider using different base class). Only offline commands should have access to the CommandContext (gfsh).
Move toward always using Jackson json instead of home-brewed json or org.json.
Reduce nesting by returning early. Replace conditional guard clause.
Don’t use java Asserts in your code. Use Design by Contract, documenting the pre-condition would be enough.
Try to minimize the usage of Null.
Move the tests using TestableGfsh to use HeadlessGfsh
remove try catch block in each commands
consolidate CommandResult and CommandResponse
Annotation for test constructor
gfsh uses LogWrapper while server uses LogService, refactor gfsh to use logService.
ConnectCommand: re-write the do-while loop and lump properties using an SslConfig object for later use.
In connect command, use ping instead of index request to check authentication.
In GfshExecutionStrategy, fix the way interceptors are called.
Implement a no-op interceptor
Make the declaration a class instead of a string
Execute on remote should just be :
Create an interceptor
Pre-execute, execute, post-execute.
Have more tests to document the structure of the json of CommandResult.
Clean up CommandResult:
Reduce duplication inside the object construct.
Consider separating result content from result display.
Lines contains newline?
Consider returning iterators for the lines.
Further reduce the argument list for ConnectCommand by grouping all ssl configuration together.
completely single-flavor test. A test should only test a limited set of behavior.
Use compiler to help you refactor, compiling errors means points of dependency.
TDD makes design better because it help you understand how your code will be used.
test problems indicates design problems.
Narrow down your scope when refactor and pay attention to what it is v.s what we want.
Define behaviors using tests. Tests before coding.
Do not put too much into one object. Consider separation of responsibility instead of convenience. (See CommandResult)
Change one thing at a time and run tests frequently, and commit separately.
Simplifying code can involve talking to user community to get feedback. Look for opportunities to simplify behavior and implementation.
Mobbing when hashing out design details, not just whiteboarding, but writing code and tests together, and setting design directions together.
Having turns driving when mobbing.
Break often when mobbing, 10 min hourly.