Skip to content

Latest commit

 

History

History
47 lines (34 loc) · 2.67 KB

File metadata and controls

47 lines (34 loc) · 2.67 KB

FileManager - Ryan's Notes

Why are the manipulation commands, the things that affect files and folders, in a different class than the file manager itself?

FileManager has a lot of userinput, in order to make the program test-able it needs methods that operate on the files to be independent of scanners.

Why is all the input and output factored out into a separate class?

So that it can be called easily and factored out of methods that change things

Why is Copy/Move in the same method? What about the two operations are so much the same?

It's a very similar action where move has an extra step after copying.

How would you separate them? Would it make it more understandable or less to separate them?

You could make a cut method that calls the move method and then deletes the file that was moved from its original location. As written (checking for input to be move to do one other task) would be the same amount of work. It may make future changes to move and copy be easier to change if they were less integrated.

What would you have to do to:

  • add the idea of a current folder? -- we would need a cd type command that moved us into a certain folder
  • how would you add a change folder command? -- we can take a file path and then need a field to store the current path we're on and be able to move forward and backward on it
  • how would you add a command to display the contents of a file? you'd need the ability to read the file's text and store that before printing to console
  • how would you change list to show the difference between files and folders? string formatting
  • how could you clean up some of the code by using an enum instead of strings for the commands? an enum would clean up some of the console variables and make a cleaner switch statement possible??
  • how would you use the FileOperator class to test the FileOperator class? Creating an instance of console and passing it to a new instance of file operator would let you call methods of the class. You could make instances of file's etc for testing

How would you test this code?

you could test the FileOperator class with the above method

How are the testing methods different for each class?

Tests that include user I/O would need to be tested through use rather than with test methods

Which class cannot be easily tested wit unit tests?

FileManager which has a lot of console scanner waiting for input

Does the code, as is, have any obvious bugs?

I didn't notice any..

How would find out?

Write tests that cover all of the FileOperator methods

Why is the Console passed as a parameter to the two constructors?

By having a single Console, it can clean up repeated code