CtCI-6th-Edition
CtCI-6th-Edition copied to clipboard
Design question about designing a file system
I am referencing the file, Entry.java, as part of the Q7_11_File_System problem.
I do appreciate the CTCI book. I purchased it. It is a great help. I do not mean to troll with my question, but rather understand what the design decisions were for this solution. Please do not take offense.
I do not believe I have ever seen an abstract class have a field in it of one of the classes that inherits from it, in this case, "protected Directory parent," is a field in the abstract class "Entry." "Directory" is a class that extends from the abstract class "Entry," as shown in the code below.
` public abstract class Entry { protected Directory parent; ... more code }
public class Directory extends Entry { ... more code } `
I have never seen this approach to designing classes. As I am writing this code in my project, I have compilation errors when I create the "Entry" class because I have not created the "Directory" class. I cannot create the "Directory" class because it needs to extend the "Entry" class. To me this seems like a violation of SRP.
Can you help me understand why you designed it this way and if this is some new approach to OO design that I have not seen before?
Thank you.