Case study: LibreOffice
I promised to document my attempt to understand a brand new codebase, so I chose the LibreOffice source.
OpenHub.net says 7M lines of C++/Java/XML across 71,000 files.
Let's figure out how the charting feature works!
Josh Matthews, @lastontheboat
That's it. That's the job.
Not the same as reading syntax.
Not taught in classes.
Difficulty is based on experience and confidence.
Not the same as reading syntax.
Not taught in classes.
Difficulty is based on experience and confidence.
same project <= same framework <=
different framework <= different language
I promised to document my attempt to understand a brand new codebase, so I chose the LibreOffice source.
OpenHub.net says 7M lines of C++/Java/XML across 71,000 files.
Let's figure out how the charting feature works!
Get ready to search all the things.
We can do better than this.
UI strings ("Insert Chart") are more likely to be unique than arbitrary keywords.
Even if they're not directly related, the results provide us context.
Using ack "Insert Chart"
on LibreOffice brings up 10 results!
I found a strings.src that looks plausible. It references a STR_INSERT_CHART name, so let's repeat the process for that.
This found a file called viewoverlaymanager.cxx in a ui/ directory, which sounds like something that could implement the button I'm looking for.
Breadth-first vs. depth-first searching.
We have found gButtonToolTips and gButtonSlots, which are used in onMouseEnter and MouseButtonDown methods. These seem to use an abstract command pattern by calling an Execute method. We can try to trace that by following SID_INSERT_DIAGRAM.
This takes us to a DoExecute method in ui/func/fuinsert.cxx. There's a lot that doesn't make sense here, but there's a chart2 module used which I recognize from an earlier search.
The chart2 turns out to contain a model/view/controller design, which makes a lot of sense. I learn things like:
Either we've accomplished our task, or it's time to start over.
In both cases, we now are more familiar with patterns in the code!