×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Code Cleanup Culls LibreOffice Cruft

timothy posted more than 2 years ago | from the let's-just-call-them-introns dept.

Open Source 317

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.

cancel ×
This is a preview of your comment

No Comment Title Entered

Anonymous Coward 1 minute ago

No Comment Entered

317 comments

Not at all. I've had a house built. (5, Interesting)

Anonymous Coward | more than 2 years ago | (#38694688)

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.

Re:Not at all. I've had a house built. (5, Insightful)

Anonymous Coward | more than 2 years ago | (#38694984)

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.

Re:Not at all. I've had a house built. (2)

theManInTheYellowHat (451261) | more than 2 years ago | (#38695130)

Except building a house is a one time endeavor. A better analogy would be to build a house on the foundation of another house and then remodel it a dozen times and then add on a few additions. Soon there after divorce your spouse and find another to guide the new additions and find another site upon which you can move that house to and hopefully not have to deal with that awful foundation.

Re:Not at all. I've had a house built. (0)

Anonymous Coward | more than 2 years ago | (#38695234)

And then rebuild it from scratch with new age materials.

Re:Not at all. I've had a house built. (4, Insightful)

Grishnakh (216268) | more than 2 years ago | (#38695522)

No, a better analogy is to build a house (full of extra materials as the parent said), and then use a giant replicator machine to mass-produce the house, almost instantly, and create thousands and thousands of new homes using that house as the basis. The wasted material in the one house is bad, but not that bad because it's one house, and it takes extra time and labor to do it more efficiently. But multiplied across thousands of identical copies, that wasted material adds up a lot. Plus, it's inefficient and you could have a better-performing house by doing a better job with the small details (better at energy efficiency for example). The slight increase in energy efficiency with that one house, realized by spending a bunch of extra time and effort removing wasted materials and doing a better job with various small details (like making sure the house wrap is applied extremely well rather being hurried and missing some staples in important places), won't amount to much with just the one house. However, multiplied across many thousands of houses, those energy savings add up to a lot.

The fact that software is easily and quickly replicated with perfect precision and little or no effort or time really makes it hard to make good analogies for it without resorting to Star Trek-style replicators; it's the only technology we have that's like that. And because it can be and is copied so easily, very different dynamics apply to it than to many other fields of endeavor.

Re:Not at all. I've had a house built. (4, Funny)

Belial6 (794905) | more than 2 years ago | (#38695188)

If it is a house that I have owned, it would be Pez dispensers. Whenever we do remodeling, we make a point to slip a pez despenser into the walls. My wife and I figure that some day a long time in the future, someone will have a mildly amusing story.

Re:Not at all. I've had a house built. (3, Informative)

theNAM666 (179776) | more than 2 years ago | (#38695410)

If you have newspaper or other similar material in your walls, which wasn't processed and designed as insulting filler, I have one word for you: mold.

You'd better know.

I'd bet there is. (5, Informative)

JGuru42 (140509) | more than 2 years ago | (#38694698)

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.

Re:I'd bet there is. (4, Interesting)

hedwards (940851) | more than 2 years ago | (#38694840)

I'm mostly surprised that they're still getting performance improvements. It seems like they've done more over the last year than Sun did during the entire time it owned the project to unbloat it.

Re:I'd bet there is. (0)

CapOblivious2010 (1731402) | more than 2 years ago | (#38694934)

But I'd bet for all MS's faults that the code for Norton Antivirus is 10x worse.

<cheap-shot>
NAV could only have that much dead code if MS actually fixed some of the security holes in Windows
</cheap-shot>

Re:I'd bet there is. (4, Informative)

Anonymous Coward | more than 2 years ago | (#38695368)

Dead code is a result of OOP development (C++/Java)

Because a lot of OOP code has extra methods used to circumvent or enforce memory protection (private/public) with variables inside classes. Sometimes the methods are created with anticipation that they will be used, but all the code is is a getVARname or setVARname dozens or hundreds of times when something like get(varname) set(varname) would be more efficient. in C you don't have this problem because memory protection basically doesn't exist unless you roll your own.

Re:I'd bet there is. (3, Interesting)

Anonymous Coward | more than 2 years ago | (#38695496)

I don't think they are talking about unused mutators. If anything Object Oriented programming makes it much easier to find and get rid of unused code BECAUSE of the data protection it implies. Having the code segmented and modular in different classes would make it worlds easier to find and remove dead code at all stages of development.

But really, C, with their fancy "structs" and "flow control" just leads to unnecessary cruft, we should just stick with ASM and Goto, b/c that's way more maintainable ;)

Then why is it still called LibreOffice? (-1)

Anonymous Coward | more than 2 years ago | (#38694700)

If I was an abbatoir that's the first cruft I'd cull. Reminds me of that Hamas lawyer named Stanley Cohen, some stuff just doesn't sound right. Even something irrational like Mephisto Office would sound better.

Re:Then why is it still called LibreOffice? (0)

Anonymous Coward | more than 2 years ago | (#38694826)

Mephisto is a German demon

Worked Well? (-1, Troll)

Oxford_Comma_Lover (1679530) | more than 2 years ago | (#38694716)

Last time I tried it--which was less than six months ago--OpenOffice was still unstable enough on a windows installation that it crashed about thirty seconds after opening a document, every time.

Its reputation has gotten a lot better over the years, so I assume there are people it works well for. But I couldn't recommend it over Word where reliability is an issue.

Re:Worked Well? (4, Informative)

theguyfromsaturn (802938) | more than 2 years ago | (#38694790)

I never get crashes with LibreOffice. Whenever I try Word on some documents (docx) I get a crash. I was completely unable to edit some documents in Word (sent to me by colleagues) until I opened them in LibreOffice, saved them in doc format, then reopened them in Word. It happens with distressing regularity. I find LibreOffice much more stable than Word personally. The worst part is when once I edited a doc in Word, saved it, and when later tried to open it again had a similar problem. I am not sure what document elements cause this but it's a sad state of affairs when LibreOffice is not only more stable (for me), but handles better MS own file format (even though there are still big deficiencies in the docx file handling in LibreOffice). So, stability issues? I guess it depends on your computer.

Re:Worked Well? (1, Interesting)

Anonymous Coward | more than 2 years ago | (#38694996)

Stop opening Word documents with non-MS software and you won't have any problem. Other software are more likely the reason of incompatibilities. I use MS-Word every day and I have not seen such problems since Office 2003.

Re:Worked Well? (-1)

Anonymous Coward | more than 2 years ago | (#38695080)

"WORKSFORME"

The most unhelpful response to a bug report ever.

Re:Worked Well? (2)

pwizard2 (920421) | more than 2 years ago | (#38695124)

LibreOffice/OpenOffice.org Writer has usually been good at handling traditional .doc files. (OO got much better when early 2.x versions came out) I'm usually able to share these documents with Word users and make changes without any major issues.

Docx is a whole different story. I recently opened a moderately complicated docx in OO Writer. This document had one of those auto-generated table of contents that corresponded to section headings, several embedded pictures, a few tables, and lots of lists. While Writer would let me see what was in the document, the editing capability was completely shot to hell. Lists were broken, the table of contents was a read-only object that Writer wouldn't (or couldn't) let me change, style/formatting was glitchy in general, and track changes was broken. Converting that document to another format just made things worse. Don't even think of using OO/LO with Docx files unless the only thing you have to do is read them.

Re:Worked Well? (4, Funny)

ColdWetDog (752185) | more than 2 years ago | (#38695236)

Of course, that behavior is quite similar to what happens when you open the moderately complex docx document in Word.

Re:Worked Well? (0)

Anonymous Coward | more than 2 years ago | (#38695366)

try resizing the main window using the upper left corner...

Don't know about LibreOffice (4, Informative)

rsilvergun (571051) | more than 2 years ago | (#38695400)

but recent (3.x) versions of OpenOffice ate my kids documents. It really sucked. From what I can gather it's a known bug in the document recovery module that hasn't been fixed to this day. The program crashes, writes a blank document out as the 'recover' document, then cheerfully overwrites all your original file and any of the automatically made backups. I suppose that somewhere along the line there was some user error. My kid probably could have said 'no' to something and stopped the whole mess. But seriously, she shouldn't have too. I've got a 500 frickin' gig drive in her machine. The biggest word doc I've ever seen in my life was 5 megs (mostly pictures). Why the hell do we still delete shit? Just make a huge undo buffer or something. I've got half a fscking terabyte. Come on OO.org, just use it already!

Re:Don't know about LibreOffice (0)

Anonymous Coward | more than 2 years ago | (#38695536)

Be careful what you wish for, you just might get it.

Captcha: blowup

Re:Worked Well? (3, Interesting)

hairyfeet (841228) | more than 2 years ago | (#38695434)

Actually I've found LO/MS Office to be pretty much mutually exclusive when it comes to any complexity of formatting. This is why i give it to home users that don't have kids or who just has young kids but not those with HS or college kids because if the teacher is using MS Office anything they give to you will be word salad in LO and anything you give to them will be word salad in MS office. And why does so many LO users find that hard to accept? they are trying to reverse engineer a binary format without jack shit for source code to look at, the fact they can open up as many as they can is a miracle and they should be applauded for it. But you take a complex doc with headers, footers, tables, etc and while i've had no problem opening that in any version of MS Office I have from 2k-2K7 that same doc will take a big old shit in LO. by the same token i make the same doc in LO with the same headers, footers, and tables and MS office will either crash or output gibberish. Does that make one better than the other? noooo, it just makes them incompatible.

That is why I give away LO to home users like I said but don't even mention it to SOHOs and SMBs because if you are having to share with MS Office users it can quickly become a mess. So I'd say it is just using the right tool for the job, LO when its home users who'll mainly be printing or not sharing with businesses, MS office for business and HS or above education.

Re:Worked Well? (2, Informative)

hedwards (940851) | more than 2 years ago | (#38694844)

LIbreOffice hasn't been OO in well over a year. But nice try with the trolling.

Re:Worked Well? (0)

Anonymous Coward | more than 2 years ago | (#38695022)

A name change doesn't make it any more stable. It's still the same old codebase.

Automate it (3, Insightful)

wisnoskij (1206448) | more than 2 years ago | (#38694720)

Sounds like they already put a lot of work into this, but someone should tell them that you can automate things like removing unused code.

Re:Automate it (0)

Anonymous Coward | more than 2 years ago | (#38695134)

Sounds like they already put a lot of work into this, but someone should tell them that you can automate things like removing unused code.

Exactly. Automatic dead code detection and aggressive automated testing helps a long way. But even w/o such automated tools, there is one humble, manual one. Continuous refactoring. Sadly, few developers ever do it. Ask a random developer what refactoring is, and you can hear chirping crickets :/

Re:Automate it (1)

gottabeme (590848) | more than 2 years ago | (#38695230)

Forgive my ignorance, but doesn't refactoring have greater potential to introduce bugs and regressions? Doing that continuously sounds like a bad idea to me, in general. You'd never get a stable, dependable codebase.

Re:Automate it (3, Interesting)

jcfandino (2196932) | more than 2 years ago | (#38695374)

Refactoring is supported by unit testing, which you should do anyway.

Do it constantly, even in the details like method names, and your code will have better quality and will be easier to understand.
Modern IDEs will resolve the tedious parts, you just have to think of the change, and the tool will do it.

The book Refactoring: Improving the Design of Existing Code is an essential resource.

It doesn't matter (1)

Anonymous Coward | more than 2 years ago | (#38694736)

No one really cares about unused functions, it doesn't degrade the resulting binary at all if the compiler you are using is any good. It may help in readability though. Refactoring the code is a whole other thing, but it don't think that is what they are doing here.

Re:It doesn't matter (4, Informative)

Mr2cents (323101) | more than 2 years ago | (#38694814)

I do think it matters. Yes, a compiler can throw out dead code, but not in all cases. E.g. if you have an enum where some values aren't used, and you then call a function if a variable has that unused value, how is the compiler going to find out? It's not only functions, there could be unused tests in code etc. All this clogs up the code and can make reading the code a living hell. It can turn an elegant part into a mess. Not mentioning the time wasted of developers trying to find out what a function does, only to discover it's not used. The article doesn't deal with the results in terms of code size or performance, but I'm very interested to find out.

Anyway: you can either have clean code or maintainable code, but not both at once in my experience.

Re:It doesn't matter (2)

GGardner (97375) | more than 2 years ago | (#38695100)

The real problem here probably has to do with shared libraries. If you have a function in a shared library with external visibility, the compiler can't remove it, unless it is doing whole program optimizations across all of the programs, and I doubt the LibreOffice builds are doing that.

Re:It doesn't matter (1)

Mr2cents (323101) | more than 2 years ago | (#38695344)

No that's just one of the problems. The rabbit hole goes much deeper than that. Also, even with such deep inspections, the public interface is, well, public, so you cannot optimise it away. At best you can use tools to hint at such cases. After that you can modify the API (and the API documentation).

Re:It doesn't matter (2, Informative)

Renegrade (698801) | more than 2 years ago | (#38694858)

And this, boys and girls, is how we end up with Windows 7/64 guzzling two gigs of memory after start-up.

Not by this one isolated idea, but the very concept of "meh it doesn't cause a problem" snowballing until it IS a problem.

I drafted up a mini-essay assuming it was C-style code, but the article is talking about methods. Clearing out half of the methods means that those virtual method tables are now half the size, which will result in much snappier execution. Less cache misses, less trash in the cache lines, shorter hash collision tables, it's all good stuff!

Nevermind all of the benefits of faster loading times, less address exhaustion, etc that apply to ANY language.

Re:It doesn't matter (0, Insightful)

Anonymous Coward | more than 2 years ago | (#38695028)

Except for the fact that the machine I'm on right now is running Win 7/64 and is using 900megs with apps running. Thanks for trolling though.
 
Remember kiddos, when you have to make up fake numbers to support your point of view you're normally wrong. And an asshat.

Re:It doesn't matter (0, Troll)

epyT-R (613989) | more than 2 years ago | (#38695164)

ok.. turn off superfetch and disable prefetch.. win7 x86_64 still eats 400-500MB. it's still bloated.

Re:It doesn't matter (1)

Anonymous Coward | more than 2 years ago | (#38695040)

You mean the prefetch where it keeps often used programs semi loaded into memory?

Re:It doesn't matter (0)

Anonymous Coward | more than 2 years ago | (#38695074)

You do realize there is only 1 instance of a virtual method table per class, right? And that removing entries in that table has nothing to do with hash collisions(because you don't hash that table, you hash objects, which are just a pointer)? And that much of Windows memory use is the SuperFetch system precaching data to avoid having to go to the disk? But don't let the facts get in the way of a good tirade.

Re:It doesn't matter (1)

idbeholda (2405958) | more than 2 years ago | (#38695082)

Let's not also forget that less lines of code also means that, generally, it's also easier to track down and fix bugs.

Re:It doesn't matter (0)

Anonymous Coward | more than 2 years ago | (#38695104)

I can't believe your trolling faggoty self got +5, but hey, this is Slashdot, home of the Linux Cocksucker Boy Toys.

Re:It doesn't matter (5, Informative)

smi.james.th (1706780) | more than 2 years ago | (#38695316)

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 [zdnet.com] . If you only have 512MB of RAM then Win7/64 will only use about 200MB of RAM.

Re:It doesn't matter (4, Insightful)

hairyfeet (841228) | more than 2 years ago | (#38695526)

And THIS gets modded "informative"? Did someone give the trolls extra mod points this week? Did I miss a memo? Because I'm sitting here with not one but TWO Win 7 X64 machines running, one an AMD EEE netbook with 8Gb, the other my AMD 6 core Thuban desktop, also with 8Gb, and I'm using less than 600Mb with the basic theme on the netbook and just a hair under 980Mb on the desktop and that's with Aero and all the bling cranked. You are probably using an old tool that counts cache as "used" memory but since Windows dumps the cache if ANY program requests the memory that simply isn't useful anymore. BTW your old XP box uses so little RAM because it'll dump to paging even if there is plenty of memory free which is just fricking stupid, the RAM is using the same voltage regardless so why not use it to speed things up?

But if you are seriously looking at 2gb and aren't trolling you need to have that thing checked, because either you have more bugs than a Bangkok Whore or one of your apps is leaking memory like a sieve.

remigrated to openoffice (0)

Anonymous Coward | more than 2 years ago | (#38694740)

I tried libreoffice a few days ago and as it repeatedly crashed within minutes of work, I reinstalled openoffice. For now. It looked promising and was significantly faster.

cb

oooh yes (3, Interesting)

Mr2cents (323101) | more than 2 years ago | (#38694744)

I've been working on a project where there were 3 separate wrappers around a database, each returning different objects containing the same data... So you had to convert those each time two modules using different wrappers needed to communicate. I tried to clean it up a bit, but eventually I stopped because my manager was frowning upon that because "I broke working code". Also there were parts that I didn't know if they were still in use. I also ran a profiler and found 80% of the functions never got called. That doesn't mean it's dead code of course, but looking at the function names I got an eerie feeling with a bunch of them. Anyway, I learned a lot about how not to manage software, I quit the company since then and I can only hope things have changed over there.

Re:oooh yes (-1)

Anonymous Coward | more than 2 years ago | (#38694772)

your an idiot for playing around with code you knew nothing about. lemme guess, after you "quit" you told you your future employers that the company sucked.

your an idiot.

cower in my shadows you feeb.

Re:oooh yes (2)

Mr2cents (323101) | more than 2 years ago | (#38694918)

Well, no, I got paid so if they don't want me to do that, I don't do it. Simple as that. But I did write a mail saying what parts of the code were going to continue to be bug-prone if if didn't get cleaned out. When I was packing, I found it back and I was completely spot on. One of the parts I mentioned needed a small change at that time, and it was already taking an engineer two weeks to implement it, constantly introducing new bugs. In hindsight my manager said I was correct. Nobody wanted to see me go, I rescued the project on more than one occasion. It was on an embedded platform so when performance was degrading I wrote a tool to find out where it was spending most of its time. Four months later we shipped a new version with more features and a lot of performance improvement, faster than it ever was. It's been in use ever since.

I also left the company without slamming doors, it was not directly related with that project but it did cause some changes: managers were now taking on smaller projects, with less R&D investments and less risks. I can understand their reasoning, but that didn't keep me motivated. That's all.

Re:oooh yes (1)

narcc (412956) | more than 2 years ago | (#38695180)

there were 3 separate wrappers around a database, each returning different objects containing the same data

It was on an embedded platform

I just threw up a little...

Re:oooh yes (1)

Bucky24 (1943328) | more than 2 years ago | (#38694962)

cower in my shadows you feeb.

Hehe I've only seen one person use that phrase on this site before... I know who you are ;)

The senior coder at the company I work for left this past August. Since then I've had to play with code that I know nothing about. I've broken things a fair few times, but there's really no way to get around that. Sometimes things that we'd rather not do are unavoidable.

Re:oooh yes (0)

Anonymous Coward | more than 2 years ago | (#38694976)

Indeed, I think I got crabs from his mother.

Re:oooh yes (1)

narcc (412956) | more than 2 years ago | (#38695218)

Hehe I've only seen one person use that phrase on this site before... I know who you are ;)

Clearly, that AC is not the real Michael Kristopherson!

Re:oooh yes (-1, Troll)

s0litaire (1205168) | more than 2 years ago | (#38694846)

Let me get this straight...

So you took a "Live" database
You played around with the code around it
You didn't know what you were doing,
You deleted some of that code,
Database went down.
The users who relied on the Database could not use it as you Buggered it up...
and you're blaming the manager for being annoyed that you "broke working code"?

Think you need to see a shrink about your memory lapses!

You were FIRED, you didn't quit!!

Re:oooh yes (2)

Mr2cents (323101) | more than 2 years ago | (#38694952)

OK, to clarify: I wasn't doing that on live code, it was a special experimental branch. My manager didn't want me to spend more time on it. But I was allowed to experiment, and then turn to the manager, present it and ask his input. Just stopping on my assignments and doing a weeks long rewrite needs approval of course, but fooling around a bit while you're stuck with another problem, was no problem. Is it really so abnormal to work that way?

Re:oooh yes (2)

zidium (2550286) | more than 2 years ago | (#38695044)

Mr2Cents, it is abnormal only because the majority of "coders" are not true craftsmen.

It's a great sign of a craftsman, the want to improve just for the beauty and elegance of the end-solution.

I wish you luck in your endeavors.

Re:oooh yes (0)

Anonymous Coward | more than 2 years ago | (#38695126)

This sounds like a pretty weak story, man. Why would your manager fuss over an experimental branch where you were encouraged to experiment on? Sounds like you're not giving the actual story or it never happened.

Re:oooh yes (1)

sjames (1099) | more than 2 years ago | (#38695224)

Probably the manager was concerned that the messing around was taking time that needed to be spent elsewhere.

Re:oooh yes (1)

zidium (2550286) | more than 2 years ago | (#38695250)

Or he was one of my previous managers!

Sadly, maintainability astigmatism is a serious problem in modern Creative Dev environments.

Re:oooh yes (4, Interesting)

Mr2cents (323101) | more than 2 years ago | (#38695300)

Well, it was an embedded company. This was the first project of such a large scale, and they lacked experience. The manager had worked there for 30 years, and had an electrical engineering background. So it wasn't an ideal situation: he was certainly competent and he could definitely write code, but lacked the experience in software engineering, like how to keep a large software base maintainable. So for example, he had this obsession with not changing code once it was tested. Since all these modules were tested, he was very nervous about changing it. What he failed to see, though, was that more modules were going to be added, and without a clean definition of how this data was to be represented, constant conversions were going to be needed (plus some other things I'm not going into now). Also, automated testing was not a practice there. This is one of the things I worked on introducing at the company, although frankly it was much to late to add it to the existing project. So he was never going to allow to merge the changes back in, because it "broke" tested code.

And I'm not saying I'm all for changing tested code - not at all , but in some circumstances, spending some effort up front can save you a lot of time later on. And I'm sure it would have.

Also, I'm quite confident of my skills. Sure I can still improve, but I surely developed a reputation of writing code that "just works". After 4 years, only a small fraction of the bugs were assigned to me, mostly they were located in parts I didn't write. Mastering the programming language is important, but there are lots of other very important things that matter. You just need a lot of discipline, checking all input, immediately failing when something goes wrong (not letting bad data trickle down the code), clean separations, higher order programming, trying to minimise the interface between modules etc... The list is so large, it becomes more of an intuition.

I hope this clarifies it a bit, I surely wasn't expecting the Spanish Inquisition.

Re:oooh yes (5, Informative)

zidium (2550286) | more than 2 years ago | (#38695026)

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.

Re:oooh yes (1)

SadButTrue (848439) | more than 2 years ago | (#38695270)

Bah just rewrite it. Having reference code and a stable target makes development really fast.

Re:oooh yes (2)

phantomfive (622387) | more than 2 years ago | (#38695392)

Bah just rewrite it. Having reference code and a stable target makes development really fast.

This sentiment is at the start of many disasters. Why would you ever rewrite code that works? You'll just end up spending time debugging it.

It sucks (0)

Anonymous Coward | more than 2 years ago | (#38694758)

Get over it.

A Natural Consequence of Change (3, Insightful)

Rubinstien (6077) | more than 2 years ago | (#38694768)

...lots of stuff is left lying about which might not be used any longer on the off chance that it might be adapted to some future purpose. Sounds like genetics.

Re:A Natural Consequence of Change (0)

Anonymous Coward | more than 2 years ago | (#38695298)

Yeah, except even microbes pare down their excessive unused code, especially in resource crunch situations.

Still no update system... (3, Insightful)

Kenja (541830) | more than 2 years ago | (#38694778)

so most people wont notice a new build.

Re:Still no update system... (2)

MonsterTrimble (1205334) | more than 2 years ago | (#38694816)

That's a good point - why the heck isn't there an update script or something on Windows & Macs? I get you don't want to push nightly build but major point releases couldn't hurt. I think my in-laws are still on OO 2.3...

Physical to virtual comparison (4, Insightful)

RelaxedTension (914174) | more than 2 years ago | (#38694786)

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...

Those would be perfectly valid if upon discovering your girder was 3 inches too short you could instantly create a copy of it, set the original aside, then alter and test that copy of the girder. Then you might leave a few extras lying around.

Re:Physical to virtual comparison (0)

Anonymous Coward | more than 2 years ago | (#38694900)

What you say is applicable to many computer related activities not just programming. Well said

Re:Physical to virtual comparison (1)

martin-boundary (547041) | more than 2 years ago | (#38695202)

Those would be perfectly valid if upon discovering your girder was 3 inches too short you could instantly create a copy of it, set the original aside, then alter and test that copy of the girder. Then you might leave a few extras lying around.

Only in a lab environment. If the bridge was taken out of the lab, and placed on a busy river, then even if you wanted to alter the girders, the traffic wouldn't allow it. You'd have to wait until midnight on Christmas Eve to fix not just the girder but make all the other design changes you've been preparing for months, and you'd have only an hour to do it all.

Bad examples (5, Insightful)

intx13 (808988) | more than 2 years ago | (#38694806)

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.

Re:Bad examples (4, Interesting)

Ethanol-fueled (1125189) | more than 2 years ago | (#38694882)

...subsystems replaced in boards by new designers not confident enough to remove the old design, etc.

It sounds crazy, but I work with a real-life example, a beamforming [wikipedia.org] circuit board that utilizes a certain technique, but has all the legacy components utilizing another technique that was never even implemented!

In that case, it wasn't a matter of confidence, but probably corporate sloth - engineers are expensive, and so they figure that paying the board-house more for the extra components per board would be cheaper than getting an engineer to redesign the board.

Re:Bad examples (0)

Anonymous Coward | more than 2 years ago | (#38694954)

Sounds familiar.
Around here, the reasoning would not be that the engineer is too expensive...

The reason for not changing the board is because the purchasing department has kept the price per unit down over the years. Any change to the design would be a crack in the armor and would allow the manufacturer to raise the price immensely (all the way up to reasonable levels even)

Re:Bad examples (3, Insightful)

kbielefe (606566) | more than 2 years ago | (#38695206)

It's not crazy. A major board redesign will set a schedule back three months or more, so if you have two options and aren't sure which one will work, it's not uncommon to design for both if you have the room. Maybe you're evaluating two vendors. There are also usually components that are only used during development. Sometimes there's an experimental or premium feature that requires an extra chip, but you don't want to make two boards. Of course, most of the time unused components get left off in mass production, but developer's boards or ones from prototype runs might still have them.

Re:Bad examples (1)

artor3 (1344997) | more than 2 years ago | (#38695380)

To expand on your example of chips, they typically have a large amount of area devoted to self-test and tuning systems which get used exactly once, in the factory (okay, maybe a few times e.g. to make sure you didn't break anything during packaging), and then never touched again. Scan chains in particular can add a lot of transistors.

It strikes me as a close analog to test code in software... that is, unless test code gets taken out of the final product with compiler directives. I don't really know how all that software black magic gets done.

Cruft in engineering... (4, Interesting)

Forbman (794277) | more than 2 years ago | (#38694862)

Oh yes, we built the bridge but there are a few hundred unnecessary iron girders that we forgot to remove...
Well, look at bridges built in the 1800's compared to the ones today. Would we build a modern bridge today using wrought iron links http://en.wikipedia.org/wiki/Clifton_Suspension_Bridge [wikipedia.org] ? Each building made in a certain period in a way represents a degree of refinement compared to its predecessors. Better materials, better methods. Buildings in general cannot be "cleaned up" the way code can, where "cruft" today was yesterday's conservative design.

Read a book about the differences in the construction of the World Trade Centers versus the Empire State Building, for example (the WTC has sibling buildings still around using the same techniques, such as the Aon [nee Amoco] Building in Chicago)...

Re:Cruft in engineering... (0)

Anonymous Coward | more than 2 years ago | (#38695172)

You mean "nee Standard Oil"

Re:Cruft in engineering... (2)

epyT-R (613989) | more than 2 years ago | (#38695246)

or, today's conservative design is yesterday's+cruft added by redundant bloat in managed runtimes that're already available from the host OS. this happens when programmers graduate and take their professors' ivory tower vacuum 'everything should be portable/who cares about performance/efficiency computers are so fast anyway' mentality with them to their employers.

Heijunka (1)

pcwhalen (230935) | more than 2 years ago | (#38694880)

The issue is similar to the Japanese concept of "heijunka." http://en.wikipedia.org/wiki/Production_leveling [wikipedia.org]
Pressure for speed of production of software vs. quality of product in speed and lack of bugs demand compromise. No one will use your software if you get beat to market by the competition. No one will buy your product if it's unreliable.

This happens in other disciplines. (4, Interesting)

tragedy (27079) | more than 2 years ago | (#38694910)

The quoted section in the summary asks if we could imagine this in other engineering disciplines. As the rest of the summary points out, it happens all the time in microchips. It also happens a lot in civil engineering, including bridge building. Removing things takes work. Unless there's work to be saved by doing it, or some way to profit from selling what's removed as scrap or it's a safety issue to leave it most engineers won't remove old parts of a structure. Consider underground pipes. How often are they removed when they're replaced? If the new ones are being laid down where the old ones went, they'll be replaced. Otherwise, 90% of the time they'll just leave the old ones there. Same goes for just about everything. Old installations of any kind are full of stuff that no longer serves any purpose. Brackets and supports for heavy equipment that isn't used anymore, old wiring and panels, concrete slabs that something mystery object used to sit on, etc. When was the last time you saw anyone take away some 30 ton piece of equipment then pay more money to have the floor where it used to sit un-reinforced? Now, sometimes they do. Usually it's when the place is being sold and the new owners are re-modelling. Other times the owners do decide to do a major cleanup. That's exactly what's being done here with libreoffice. Makes it no different than any other engineering discipline then.

Incidentally, if it's truly "dead" code, then it shouldn't actually be compiled, so it's not like the bridge engineer left in a bunch of extra girders, it's more like he's keeping addendum 6-c to revision 12b of the plans for section 3 in the same file cabinet as revision 13 rather than shifting it to a storage box and warehousing it.

Re:This happens in other disciplines. (1)

luther349 (645380) | more than 2 years ago | (#38694988)

very true stuff like old pipes etc they leave because it cost more to remove them. and they do not hurt anything staying.

Re:This happens in other disciplines. (2)

deodiaus2 (980169) | more than 2 years ago | (#38695010)

I once inherited a motor design which I was modifying. There was a strut going along the entire length. I was thinking of removing it, as I could not find a use for it. However, I wasn't sure if there might not be a manufacturing reason for it, or to provide additional structural support..
So I left it in.
Why, because 10 years ago, I was fired because I removed some venting slots on another generator. I removed them because they only provided minimal ventalation, but really interfered with the magnetic field distribution.

Re:This happens in other disciplines. (5, Interesting)

Anonymous Coward | more than 2 years ago | (#38695018)

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.

Re:This happens in other disciplines. (1)

thegarbz (1787294) | more than 2 years ago | (#38695108)

This happens in all facets of engineering, not just civil structures. Go into any oil refinery that's more than 10 years old and you may find whole units left in place filled with nitrogen as it's too costly to remove.

The only time unused stuff is cleaned up in the engineering world is if the realestate becomes valuable, or if it is mandated to by some safety / environmental code.

Re:This happens in other disciplines. (3, Informative)

FienX (463880) | more than 2 years ago | (#38695166)

I've worked on enterprise asset management systems in a number of different industries including electrical utilities, natural gas pipelines, and military. In almost every company they've had some variant of an "abandoned in place" asset status. In cases like power plants, trying to remove a single cable from a series of cable trays or raceways is rarely, if ever, worth the effort and risk. Some cable trays have dozens of cables (and I'm not talking cat5) in them, sometimes half of which are "dead" but removing those from the middle of a stack of hot cables in a working power plant doesn't have much of an ROI.

Re:This happens in other disciplines. (4, Informative)

Nethead (1563) | more than 2 years ago | (#38695472)

Ever been in the telco closets of a 50 year old office building? Old 9600 baud modems still powered up and connected to 66 blocks, old DS0 smartjacks with red lights, all next to Cat5 and fiber cross connects.

Look above the drop ceiling of an old department store store sometime and gander at all the serial cable wire that is covered by the Token Ring wire covered by the 10base5 wire that is covered by the ThinNet wire that is covered by the Cat5 wire that is covered by the fiber ducts. All that tangled in with the old 25 pair telco wire.

If it's not on your work order, you don't touch it.

Regular security reviews remove this problem (1)

Anonymous Coward | more than 2 years ago | (#38694926)

I used to work at a large, evil company that did a complete review every release of every single line of code in their products, requiring at least two and sometimes four (for critical areas) devs to sign off on it. Let me tell you; there was _no_ dead code.

Not to mention the human genome itself. (5, Interesting)

Freddybear (1805256) | more than 2 years ago | (#38694956)

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.

Thousands, if only... (0)

Anonymous Coward | more than 2 years ago | (#38695020)

Orders of magnitude :(

Room for improvement? (1)

hcs_$reboot (1536101) | more than 2 years ago | (#38695046)

From summary:

Exciting to think that LibreOffice has quite so much room for improvement

Sorry but removing the dead code is not really "room for improvement". It's rather "fix a code that lack(ed) a proper project management".

Smaller File Size... (0)

Anonymous Coward | more than 2 years ago | (#38695118)

Well this completely explains my confusion over why the latest release of LibreOffice was smaller than the older version.

80286 microcode (2, Interesting)

Anonymous Coward | more than 2 years ago | (#38695150)

Intel's microcode to support 16-bit protected mode became obsolete as soon as the 80386 was released, but they had to support it for backward compatibility, in case someone tried to install Windows 3.0 on an IBM AT clone, for instance. Probably that microcode has been carried forward ever since. Also, there are a lot of CISC instructions such as SCAS* with the "REP" prefix which were heavily used in assembly language in the eighties, but which are now deprecated and typically slower than the RISC-style replacements.

Load More Comments
Slashdot Account

Need an Account?

Forgot your password?

Don't worry, we never post anything without your permission.

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>
Sign up for Slashdot Newsletters
Create a Slashdot Account

Loading...