alex_read
Jun 27th, 2008, 02:30 AM
Background:
I'm just writing a small home project at the mo, which contains the following classes:
Windows form for input and to call processing methods.
SubtitleFile abstract base class
SRTSubtitleFile class which inherits the above, but is specific to a *.srt subtitle file.The project shows the form/UI allowing a subtitle file to be chosen. This form in turn instanciates the SRTSubtitleFile class and runs some of it's methods.
Question:
Though I don't really need to extend this any further, I wanted to do things properly. :p So I was wondering, could I have everyones thoughts on the best way to expose the formats/types of subtitle files I'm supporting here please?
Currently I have an open file dialog control and I'm setting it's filter property to a hardcoded string to limit the files to those with a *.srt extension, but I really wanted to move away from this hardcoded implementation.
Thoughts so far:
Below I've listed a few thoughts I've had, but perhaps there's a common practice for this idea? Thanks everyone! :bigyello:
1) To add an Enum to the form (downside: if moving the subtitle bits to their own project in the future, the file types aren't exposed by any of these classes)
Exposing an enum of file types from the SubtitleFile abstract class (neater, but downside means remembering to maintain this file rather than just adding in a new class/classes representing the new subtitle format)
Exposing a property from the SubtitleFile abstract class which (maybe through reflection) evaluates and presents a list of all inheriting class names or property values (it just doesn't seem good practice to expose this from the SubtitleFile abstract class to me).
Creating a separate SupportedSubtitleFormats class, and performing the evaluation and exposal of the formats from the classes inheriting SubtitleFile (utilise the inheriting SubtitleFile classes, or use the next point)
Creating a separate SupportedSubtitleFormats class, then creating separate SRTSubtitleFormat SUBSubtitleFormat etc. classes which expose the format name and filetypes (utilise the inheriting SubtitleFile classes, or use extra classes and split off the file type information)
At the moment I'm thinking the last one, and I guess trying to take a look at reflection to get the inheriting classes & their details which might be overkill. Then whether to expose these child SubtitleFileFormat classes via the related child subtitleFile classes. Any and all comments/ideas/thoughts/opinions/random suggestions are warmly welcomed! Thanks again. :)
I'm just writing a small home project at the mo, which contains the following classes:
Windows form for input and to call processing methods.
SubtitleFile abstract base class
SRTSubtitleFile class which inherits the above, but is specific to a *.srt subtitle file.The project shows the form/UI allowing a subtitle file to be chosen. This form in turn instanciates the SRTSubtitleFile class and runs some of it's methods.
Question:
Though I don't really need to extend this any further, I wanted to do things properly. :p So I was wondering, could I have everyones thoughts on the best way to expose the formats/types of subtitle files I'm supporting here please?
Currently I have an open file dialog control and I'm setting it's filter property to a hardcoded string to limit the files to those with a *.srt extension, but I really wanted to move away from this hardcoded implementation.
Thoughts so far:
Below I've listed a few thoughts I've had, but perhaps there's a common practice for this idea? Thanks everyone! :bigyello:
1) To add an Enum to the form (downside: if moving the subtitle bits to their own project in the future, the file types aren't exposed by any of these classes)
Exposing an enum of file types from the SubtitleFile abstract class (neater, but downside means remembering to maintain this file rather than just adding in a new class/classes representing the new subtitle format)
Exposing a property from the SubtitleFile abstract class which (maybe through reflection) evaluates and presents a list of all inheriting class names or property values (it just doesn't seem good practice to expose this from the SubtitleFile abstract class to me).
Creating a separate SupportedSubtitleFormats class, and performing the evaluation and exposal of the formats from the classes inheriting SubtitleFile (utilise the inheriting SubtitleFile classes, or use the next point)
Creating a separate SupportedSubtitleFormats class, then creating separate SRTSubtitleFormat SUBSubtitleFormat etc. classes which expose the format name and filetypes (utilise the inheriting SubtitleFile classes, or use extra classes and split off the file type information)
At the moment I'm thinking the last one, and I guess trying to take a look at reflection to get the inheriting classes & their details which might be overkill. Then whether to expose these child SubtitleFileFormat classes via the related child subtitleFile classes. Any and all comments/ideas/thoughts/opinions/random suggestions are warmly welcomed! Thanks again. :)