Strahan
Member
- Joined
- Mar 28, 2015
- Messages
- 11
- Programming Experience
- 3-5
Hi! I'm rebuilding my old media browser. I made a PHP website to browse my media files and handle playing them and tracking where I am with shows. Thing is, I made it sixteen years ago. Over the years I've just modded it as necessary to meet my needs, and what I have now is absolutely ghastly lol. It's 8,305 lines of code in... two files lol. No classes either, no OO at all. Needless to say, it's high time to ditch that spaghetti mess. I decided to forgo the web approach all together and make a C# application. The web interface is not easy to work with my remote control whereas I'll have control over everything UI related in C#.
Anyway I digress. In my C# application, I have two main objects MediaEntry and MediaFile. When the app opens, it will display all MediaEntry at the root level. So the initial screen's list would be like:
The MediaEntry object has a string Path. A sample of the data would be like "anime//g//genjitsu shugi yuusha no oukoku saikenki//season 2". I figured I could find children by searching for entries where path = current path + "//". But then I was thinking perhaps it'd be better to just have a "parent" field. My objects have an "Id" int which relates to the database autoinc ID index field for the entry. Parent then would have that Id value of the parent entry. The reason I'm not 100% sure that's the way to go is then if I move an entry, I have to both update a parent and a path. Seems like I shouldn't need both then. Plus then to display the current path if I only have parent I guess I'd have to write something that iterates its way backwards up the tree? Sounds inefficient.
I figured instead of agonizing over it I'd just ask the community; when you design a hierarchical structure like this, what is the best practice for associating the levels with each other?
Thanks!
Anyway I digress. In my C# application, I have two main objects MediaEntry and MediaFile. When the app opens, it will display all MediaEntry at the root level. So the initial screen's list would be like:
C#:
Anime
Movies
Music Videos
TV Shows
I figured instead of agonizing over it I'd just ask the community; when you design a hierarchical structure like this, what is the best practice for associating the levels with each other?
Thanks!