D23582: [platforms/x11] Make X11WindowedOutput::init() private
Vlad Zagorodniy <[email protected]>
| Newsgroups | gmane.comp.kde.devel.kwin |
|---|---|
| Message-ID | <[email protected]> |
zzag added a comment. In D23582#522457 <https://phabricator.kde.org/D23582#522457>, @davidedmundson wrote: > So instead of N classes able to access one method they don't need, we have one class which can access all X11WindowedOuptut's private's which it doesn't need. > It gets downcast to everyone outside of X11WindowedBackend, so init() isn't a visible method to any other class outside of the x11/windowed folder. Such reasoning won't get us anywhere because I can ask "why would N classes have to be able to call init() method which will lead to undefined behavior when kwin compiled w/o Q_ASSERT?" It's all about maintaining good public interface. Sometimes it's worth to keep "create" or "init" method public, but in most cases it's discouraged. Even though this code is in "platforms/whatever", it doesn't mean that we should stop writing good code. Keeping init() public is bad because it pollutes the public interface with implementation details of the class as well it's not safe to call init() many times. In either case encapsulation is "meh," but at least it's less severe with friend class. REPOSITORY R108 KWin REVISION DETAIL https://phabricator.kde.org/D23582 To: zzag, #kwin Cc: davidedmundson, kwin, LeGast00n, The-Feren-OS-Dev, sbergeron, jraleigh, fbampaloukas, GB_2, mkulinski, ragreen, jackyalcine, Pitel, iodelay, crozbo, bwowk, ZrenBot, ngraham, alexeymin, himcesjf, lesliezhai, ali-mohamed, hardening, romangg, jensreuterberg, abetts, sebas, apol, mart