Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interview Q - Design File System - Review [closed]

Tags:

filesystems

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.

like image 840
name_masked Avatar asked Apr 01 '11 05:04

name_masked


People also ask

Does Amazon ASK system design?

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.

What happens in system design interview?

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.


1 Answers

There are three essential operations, that are missing:

  • reading the contents of a file
  • writing the contents of a file
  • testing whether a 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:

  • the file extension does not have any significance in all operating systems. Then why should a method exists for setting and retrieving it?
  • the associated programs only have a meaning in a single computer/os combination. In a general purpose file system, the programms might exists only temporarily (because a different os is booted or the device is moved). It should IMHO not be stored as part of the meta information of a file, because of separation of concerns.
  • 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.

like image 129
Oswald Avatar answered Oct 14 '22 12:10

Oswald