Partial class or "chained inheritance"
Posted
by Charlie boy
on Stack Overflow
See other posts from Stack Overflow
or by Charlie boy
Published on 2010-04-30T08:29:49Z
Indexed on
2010/04/30
8:57 UTC
Read the original article
Hit count: 243
Hi
From my understanding partial classes are a bit frowned upon by professional developers, but I've come over a bit of an issue;
I have made an implementation of the RichTextBox control that uses user32.dll calls for faster editing of large texts. That results in quite a bit of code. Then I added spellchecking capabilities to the control, this was made in another class inheriting RichTextBox control as well. That also makes up a bit of code.
These two functionalities are quite separate but I would like them to be merged so that I can drop one control on my form that has both fast editing capabilities and spellchecking built in. I feel that simply adding the code form one class to the other would result in a too large code file, especially since there are two very distinct areas of functionality, so I seem to need another approach.
Now to my question; To merge these two classes should I make the spellchecking RichTextBox inherit from the fast edit one, that in turn inherits RichTextBox? Or should I make the two classes partials of a single class and thus making them more “equal” so to speak?
This is more of a question of OO principles and exercise on my part than me trying to reinvent the wheel, I know there are plenty of good text editing controls out there. But this is just a hobby for me and I just want to know how this kind of solution would be managed by a professional.
Thanks!
© Stack Overflow or respective owner