Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3f81cba

Browse files
committed
java file manager notes
1 parent d339834 commit 3f81cba

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

.idea/compiler.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FileManager.md

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,47 @@
1-
# FileManager
1+
# FileManager - Ryan's Notes
22

3-
An amazingly useless tool!
3+
#### Why are the manipulation commands, the things that affect files and folders, in a different class than the _file manager_ itself?
4+
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.
5+
6+
#### Why is all the input and output factored out into a separate class?
7+
So that it can be called easily and factored out of methods that change things
8+
9+
#### Why is Copy/Move in the same method? What about the two operations are so much the same?
10+
It's a very similar action where move has an extra step after copying.
11+
12+
#### How would you separate them? Would it make it more understandable or less to separate them?
13+
You could make a cut method that calls the move method and then deletes the file that was moved from its original location.
14+
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
15+
to move and copy be easier to change if they were less integrated.
16+
17+
#### What would you have to do to:
18+
19+
- add the idea of a _current folder_? -- we would need a cd type command that moved us into a certain folder
20+
- 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
21+
be able to move forward and backward on it
22+
- 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
23+
- how would you change _list_ to show the difference between files and folders? string formatting
24+
- how could you clean up some of the code by using an _enum_ instead of strings for the commands?
25+
an enum would clean up some of the console variables and make a cleaner switch statement possible??
26+
- how would you use the _FileOperator_ class to test the _FileOperator_ class?
27+
Creating an instance of console and passing it to a new instance of file operator would let you call methods of the
28+
class. You could make instances of file's etc for testing
29+
30+
#### How would you test this code?
31+
you could test the FileOperator class with the above method
32+
33+
#### How are the testing methods different for each class?
34+
Tests that include user I/O would need to be tested through use rather than with test methods
35+
36+
#### Which class cannot be easily tested wit unit tests?
37+
FileManager which has a lot of console scanner waiting for input
38+
39+
#### Does the code, as is, have any obvious bugs?
40+
I didn't notice any..
41+
42+
#### How would find out?
43+
Write tests that cover all of the FileOperator methods
44+
45+
#### Why is the Console passed as a parameter to the two constructors?
46+
By having a single Console, it can clean up repeated code
447

0 commit comments

Comments
 (0)