Files.fileExists or file.exists?
- 981 words
- 5 minutes to read
- comments
How would you design a class that abstracts, say, a file on a disk with certain properties? Let’s say you need to be able to check whether the file exists on the disk or has already been deleted. Would you create an object first and then call the exists()
method on it, or would you call Disk.fileExists()
first and only then, if TRUE
is returned, make an instance of the File
class and continue working with it? This may sound like a matter of taste, but it’s not that simple.