Should I make use of nested courses in this instance?
I am working with a collection of courses made use of for video playback and also recording. I have one major class which imitates the general public user interface, with approaches like
record() and so on. After that I have workhorse courses which do the video decoding and also video encoding.
I simply learnt more about the presence of nested courses in C++, and also I'm interested to recognize what designers think of utilizing them. I am a little skeptical and also not actually certain what the benefits/drawbacks are, yet they appear (according to guide I'm reviewing) to be made use of in instances such as mine.
Guide recommends that in a circumstance like mine, an excellent remedy would certainly be to nest the workhorse courses inside the user interface class, so there are no different apply for courses the customer is not suggested to make use of, and also to stay clear of any kind of feasible identifying problems? I do not find out about these validations. Nested courses are a new principle to me. Simply intend to see what designers think of the concern.
One means of determining whether to make use of nested courses is to assume whether this class plays a sustaining duty or it's very own component.
If it exists only for the objective helpful an additional class after that I usually make it a nested class. There are an entire load of cautions to that, several of which appear inconsistent yet all of it boils down to experience and also intestine - sensation.
I would certainly be a little bit unwilling to make use of nested courses below. What happens if you developed an abstract base class for a "multimedia vehicle driver" to take care of the back-end things (workhorse ), and also a different class for the front-end job? The front-end class can take a pointer/reference to an applied vehicle driver class (for the ideal media type and also scenario ) and also execute the abstract procedures on the workhorse framework.
My ideology would certainly be to proceed and also make both frameworks obtainable to the customer in a sleek means, simply under the presumption they would certainly be made use of in tandem.
I would certainly reference something like a QTextDocument in Qt. You give a straight user interface to the bare steel information handling, yet pass the authority along to an object like a QTextEdit to do the adjustment.