Slashdot Mirror


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.

4 of 317 comments (clear)

  1. I'd bet there is. by JGuru42 · · Score: 5, Informative

    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.

  2. Re:oooh yes by zidium · · Score: 5, Informative

    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!!
  3. Re:It doesn't matter by smi.james.th · · Score: 5, Informative

    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...
  4. Re:It doesn't matter by bonch · · Score: 5, Informative

    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.