File system supports
Creation
reading
writing
deleting files and directories
Should handle permissions, different types of files, and provide a hierarchial directory structure
Concurrent connections are expected for reads, writes,
a user may delete which another is reading.
Based on the requirements and use cases, identify the main objects of the system and analyze how they interact and relate to each other...
public abstract class FileSystemNode
{
public Guid Id { get; init; }
public string Name { get; set; }
public Directory Parent { get; set; }
public User CreatedBy { get; init; }
public User LastModifiedBy { get; set; }
public DateTime CreatedOn { get; init; }
public DateTime LastModifiedOn { get; set; }
}
public class Directory : FileSystemNode
{
public List<Directory> ChildDirectories { get; } = [];
public List<File> Files { get; } = [];
}
public class File : FileSystemNode
{
public string Extension { get; set; }
public long Size { get; set; }
}
public interface IDirecotryService
{
bool CreateDirectory(Directory Parent, string Name);
bool DeleteDirectory(string path);
Directory ReadDirectory(Directory path);
}
public class DefaultDirectoryService : IDirectoryService {
SearchByPath
}
public interface FileService
{
File Create(string path, string fileName, string fileType);
Content Read(string path);
bool Write(string path, string content);
bool Delete(string path);
}
public class FileService : IFileService { }
public interface ISearchService
{
SearchByPath(string path);
}
public class SearchService : ISearchService { }
public class User
{
int id
string Name
List
}
public enum Permissions
{
Create,
Read,
Write,
Delete,
All
}
public interface IUserPermissionsReader
{
public bool IsUserAlllowed(string path, enum permission, int userId);
}
public class UserPermissionReader : IUserPermissionReader
{
}
For each class, define the attributes (data) it will hold and the methods (functions) that operate on the attributes. Ensure they align with the object's responsibilities and adhere to the principle of encapsulation. Write your code in the code editor below.
Explain design tradeoffs you considered. Check and explain whether your design adheres to SOLID principles. Explain how your design can handle changes in scale and whether it would be easy to extend with new functionalities. Identify areas for future improvement...