4 ms·
I love LibreOffice. That said, in my spare time, I've been looking through the code base, and my impressions are that it's too large. For instance, looking at
by chris_wot 14y ago
I love LibreOffice.
That said, in my spare time, I've been looking through the code base, and my impressions are that it's too large. For instance, looking at the vcl module, which handles widgets, windows, etc. when I look at the number of classes my mind begins to boggle.
I possibly (read: probably) speak from ignorance, but I use the function SVMain() [1] as an example. Instead of defining a purely abstract class with architecture specific classes derived from this, they have defined an extern hook function, then they run it, test to see if it returns false, and if so run the standard ImplSVMain function. This seems inelegant for two reasons: the code is somewhat unclear, and there seems to be two functions with lightly different names, one is an SVMain function that does something, the other is an implementation of a function... Yet both implement a functional part of the code base. There is even a comment that reads "the real SVMain.".
Then there are the names... There is a "desktop" object that runs the main loop, the desktop being the application. [2] But there is an Application class [3], yet at the same time there's a DesktopEnvironmentContext class [4]. This seems to be some sort of misguided attempt at reimplementing a "desktop" metaphor, which is a legacy of early versions StarOffice. It was one of the first things ripped out when work started on OpenOffice.org, yet the class name still remains, making its purpose most unclear.
Furthermore, for some reason they force the Application class to be subclassed. Which they do only once, via Application_Impl. But I have noticed that the base class has lots of empty non-pure functions, and only forces Main() to be a pure virtual function. What is the point of this?
Another thing that I find makes the code harder to read is it uses a lot of Hungarian notation.
This is a legacy code base, and I wasn't being sarcastic when I said I love LibreOffice. I think people like Michael Meeks and Kohei are amazing. But I see the code base as having been slapped together somewhat pver many years. And there are code smells and, frankly, code rot, throughout the source.
It needs to be rearchitected (not rewritten). There is code in the code base that nobody dares touch (the legacy filters). The code is organised strangely, for example there are multiple places to find filters. At the same time, they have a system abstraction layer (sal), which has specific architectural and generic classes, but then I see that http://docs.libreoffice.org http://docs.libreoffice.org has modules like "android" and "iOS".
There are literally thousands of classes in there. Go-oo sometime ago refactored away dozens of classes, I would think they could refactor away a lot more.
I'm truly sorry if this seems harsh or ignorant by the way. It's not intended to be that way. It's just this code base is massive, so massive that its hard to understand how it all works. This in turn, IMO, may cause issues getting more volunteers. Not to mention too much refactoring might break things.
1. http://docs.libreoffice.org/vcl/html/svmain_8cxx_source.html#l00211 http://docs.libreoffice.org/vcl/html/svmain_8cxx_source.html...
2. http://wiki.openoffice.org/wiki/Architecture/Process_Flow http://wiki.openoffice.org/wiki/Architecture/Process_Flow
3. http://docs.libreoffice.org/vcl/html/classApplication.html http://docs.libreoffice.org/vcl/html/classApplication.html
4. http://docs.libreoffice.org/vcl/html/classDesktopEnvironmentContext.html http://docs.libreoffice.org/vcl/html/classDesktopEnvironment...
- bjustin 14y agoIt would be great if it people made the kind of changes you mention, but would it be worth the time and effort? It may be better for people to work on other kinds of programs than to spend a lot of time improving the LibreOffice code base. Writer is good enough for education up through undergrad for many majors, and good enough for some nonprofits. It is certainly good enough for my needs. I don't use the other applications so I can't say about them.
- chris_wot 14y agoI think it would. I speak from the peanut gallery, but the first thing I'd do would be to encapsulate all of the standalone functions into a relevant class. I think most of the Impl* classes are not needed. Ideally, I'd turn vcl into a framework. Currently this module is tightly coupled with the execution of the main application. Consider that if this was its own framework, then wouldn't it be easier to port it to more architectures? And consider how much easier it would be for app developers to extend the core of LibreOffice. I'd be abstracting all the OS specific constructs into the osl modules (which is its intended purpose), and keep a strict coding guideline that anything OS specific must be implemented there. Id also abstract all the graphics primitives to its own module. I'm specifically thinking of the Gtk+ idea here, you can see the fruits of this design decision because gtk+ apps now literally will run on almost anything. I've not looked at UNO much, but is it possible that there is duplication between this module and other modules? As an example, but surely cppu is duplicating work that the sal module should be taking care of? Then there is the filter, hwpfilter, lotuswordpro, oox, writer filter and writerperfect filters. Surely one filter interface would be better and make document expor animport fidelity better? Perhaps I talk from ignorance, bu I'd have thought that shortens development time and reduces bugs. This could be abstracted out and othe projects could use it also, cross pollinating with other OSS efforts. It would also make correcting or implementing filters for more obscure formats easier.
- grandinj 14y agoYou could start by stepping in to help convert UI code to glade files. This is a huge code base. It needs lots and lots of little steps to get it into shape :)