Backends and OO principles



Hija,

I'm a Summer of Code student, accepted by the Gentoo mentors to work on
NetworkManager integration into the Gentoo distribution this summer.
I've been working on the Gentoo backend a little before too.

I got a question on the backend stuff. This might be completely useless
etc, just asking for you guy's ideas:
While working on the backend, I saw lots of code duplication for several
functions between the different backends. So I started to wonder how we
could get rid of it.
The solution I came up with is very simple. Instead of using normal
functions in the backend source files, and link in one of the backend
source files during compilation, why not take this to a somewhat higher
level?
Imagine we could define a "NetworkManagerBackend" interface, which
should be implemented by the backend we want to use. Then we could have
a "NetworkManagerGenericBackend" which is an abstract "class"
implementing most of the functions defined in the interface, ie all
fairly common functions (the code currently copied between all backends
right now).
Then the final backends are classes extending
NetworkManagerGenericBackend when desired, implementing
NetworkManagerBackend, overriding NetworkManagerGenericBackend functions
where necessary, and providing all functions not in the abstract class.
Next to that, even backends could inherit from other backends: eg the
Ubuntu backend might extend the Debian backend and override some of its
functions, if Ubuntu has at some places a somewhat other network
handling than Debian has.

Obviously, all this would be based on the gobject framework, both the
interfaces and classes. I know using gobjects adds some overhead to
applications, but I think this possible overhead is small, compared to
the extra functionalities we might get by using this system.

If the NM devs 'd think this is a good idea, I'd be willing to work on
implementing this, as long as my SoC mentor agrees :-)

I'd be glad to get any comments on this, both positive and negative (if
there's a good reason ;))

Regards,

Ikke
http://www.eikke.com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]