Code Cleanup Culls LibreOffice Cruft
mikejuk writes with an interesting look at what coders can get around to after a few years of creating a free office suite: dealing with many thousands of lines of deprecated code: "Thanks to the efforts of its volunteer taskforce, over half the unused code in LibreOffice has been removed over the past six months. It's good to see this clean-up operation but it does raise questions about the amount of dead code lurking out there in the wild. The scale of the dead code in LibreOffice is shocking, and it probably isn't because the code base is especially bad. Can you imagine this in any other engineering discipline? Oh yes, we built the bridge but there are a few hundred unnecessary iron girders that we forgot to remove... Oh yes, we implemented the new chip but that area over there is just a few thousand transistors we no longer use... and so on." Well, that last one doesn't sound too surprising at all. Exciting to think that LibreOffice (which has worked well for me over the past several years, including under the OpenOffice.org name) has quite so much room for improvement.
There are probably dozens of extra nails that were just hammered in rather than be removed. There are extraneous pieces of lumber.
And a house that was remodeled? I've seen newspaper used as filler. I've seen layers of roofing, with things buried in between layers.
Frankly I don't know what's inside my walls, and I'm not sure I want to know.
It would not be very surprising to see a lot of dead code.
I maintain the code for MoreTerra, a Terraria map editor program and I'm pretty sure I've got dead code in there and that's a pretty small project.
With a large number of people working on the code it likely ends up slowly clogging up as no one quite knows what the others are doing.
Dare I ask what type of dead code exists in something extra huge, but closed source, like the Windows code base or for MS Office? But I'd
bet for all MS's faults that the code for Norton Antivirus is 10x worse.
Bridges often have unused structural elements: walk-ways made unsafe by modern traffic levels, maintenance accesses unused for safety reasons, supports made redundant beyond the factor of safety by bridge improvements, etc. Chips and boards too: FPGAs with 10% utilization, chip designs re-purposed with functional components disabled, subsystems replaced in boards by new designers not confident enough to remove the old design, etc.
Cruft in software is more often removed because (1) software has a potentially longer lifetime than hardware and (2) it's a lot easier to remove an uncalled function from a program than a girder from a bridge! Software cleanup should be an expected and planned part of a project's life cycle.
Human DNA (and just about every other species as well) is full of things like inactive duplicate genes (some with slight alterations), pieces of old retroviruses, and other mutations and replication errors that have been "commented out". Plus a whole lot of sequences which we don't know what they're good for yet.
I've seen chemical plants built with millions of dollars worth of unnecessary piping and valves, because the project timeframe meant that it was cheaper to install extra connections that might never be used and save engineering time than waste time re-engineering it.
If removing unnecessary items can save thirty thousand dollars (say) at the cost of three days, removing the cruft is only worth it if the delay costs less than ten thousand a day.
A nice engineering example is the stone pylons at each end of the Sydney Harbour Bridge. They were built to support the cranes that were used in constructing the steel arch of the bridge. Since the bridge's completion they've served no structural purpose whatsover.
As the parent poster suggests, it would have cost time and money to remove them. However, in bridge building they plan around that - a bit of extra effort was put in at the start and the pylons were designed and built in such a way that they looked good after the bridge was finished. They were left in place as a feature of the completed structure and, as they were built in sandstone, they do a reasonably good job of making the bridge work visually with the feel of the historic precint beneath the southern end of it.
Dead code rarely adds anything to the aesthetics of software.
Mr2Cents,
Your actions are indicative of a person who is not yet truly a craftsman of the software engineering trade.
Speaking from personal experience dealing with huge, complex, unmaintainable PHP legacy systems for the last ten years, let me tell you a far better path:
1. Search the code base for what may be directly calling the code.
2. Set debug breakpoints at the start of each piece of cruft code and rigorously test the app.
3. Create a custom exception (e.g. CrapCodeHitException) and throw it at the beginning of each code segment you want to remove. If you don't hit any of the exceptions after, say, a week of normal browsing doing other things, plus testing, then proceed to step 4.
4. Catch the CrapCodeHitExceptions at the highest level you dare, log this into a separate log file you will have permission to read. Commit the code into a releaseable branch so that it ends up on your QA and staging servers.
5. Get approval to have the logging code be pushed to staging. Add comments above each cruft piece of code stating a) the level of risk you think if it is removed, b) when one should feel free to remove it (pick increments like 3 mo, 6 mo, 1 yr, based on risk), c) your name. If shit hits the fan cuz of removal, you want to man up and accept responsibility so your peers don't waste precious cycles needlessly troubleshooting why this "perfectly fine" code was seemingly arbitrarily removed.
6. After each time of your comments has elapsed, if the code was never triggered (parse the logs!), feel free to remove it. Please leave a note behind that you removed such and such, tho, and stick your name on it. Remove these notes after a year.
I've personally cleaned up 100,000s lines of code using this mechanism on several large and complex sites, without a single failure.
Slashdot Valentines Beta Massacre: iT WORKED! The boycotts killed Beta!!
I am not a Microsoft fan, but Windows 7 is actually a very well-written OS, in my experience. If you have lots of RAM then it uses it, there's no sense in having 8GB of RAM if it's only using 250MB and paging the rest of what it needs.
As a point of reference, have a look at this article. If you only have 512MB of RAM then Win7/64 will only use about 200MB of RAM.
One thing I know, and that is that I am ignorant...
If you have newspaper or other similar material in your walls, which wasn't processed and designed as insulting filler
What material in your walls could be more insulting than newspaper?
No, it's not. Windows 7 will use as little as 200MB of RAM if you only have 512 physically available. You're misunderstanding what's actually going on as you fret over megabytes in Task Manager.