All,
I was recently asked in one of the technical interviews to write a high level design for a File Sysem. My answer to the question was as follows. I would request everyone to please review and let me know if there are suggestions/improvement:
interface BaseFileSystem
{
/*Basic file/folder attributes are:
1. File/Folder Size
2. File/Folder Date created
3. File/Folder Date Modified
4. File/Folder permissions - Read, write and execute
5. File/Folder Owner - Owner of the file who defines permissions for other users
6. File/Folder Visibility - Hidden or Visible
7. File/Folder Name
Hence each one of the above attributes would have public <return type> get() and public void set<AttributeName>(<variable datatype>) */
}
public class File implements BaseFileSystem
{
/*The `File` class should implement all of the methods from interface `BaseFilesystem`.
In addition, it must also implement following specific methods that can only be associated with physical files*/
public String getFileExtension(){….}
public void setFileExtension(String value) {….}
public String[] getAssociatedPrograms(){ …..}
public void executable(){ …. };
}
public class Folder implements BaseFileSystem
{
/*The `Folder` class should implement all of the methods from interface `BaseFileSystem`. In addition, it must also implement following specific methods that can only be associated with the physical 'folders'*/
public BaseFileSystem[] getSubFoldersAndFiles(){ …. }
public void addSubFolderAndFiles(BaseFileSystem fileObj) { …. }
public void executable(){throw new UnsupportedOperationException();}
}
Additionally, any general pointers to such design questions would be greatly appreciated.
System Design is a key aspect at Amazon Amazonian build reliable, scalable, and cost-optimal performance systems. System design is mandatory to prepare for interviews for all experienced candidates, with 2+ years of experience.
In a System Design Interview, interviewers ask the candidate to design a web-scale application. For example, they might ask you to design Instagram, design YouTube, or design Uber backend. Unlike a coding interview question, System Design Interviews are free-form discussions, and there's no right or wrong answer.
There are three essential operations, that are missing:
BaseFileSystem
is a File
or a Folder
On the other hand, there are some operations that I do not consider essential for a file system:
public void executable()
seems out of place. But this is only a guess, because I do not know what this method is supposed to do. If this executes an executable file: that should be done by the operating system manually. Also, it has no business being defined in class Folder.Furthermore, the attributes that you defined in BaseFileSystem
make some assumptions about the requirements of the file system. Maybe your simple permissions system is not sufficient or the purpose of the file system and ACLs are needed. Maybe visibility is determined by the name of the file (like in UNIX). You should clarify that beforehand.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With