Identify and eliminate dead code (100+ lines)BRL-CAD
Status: ClosedTime to complete: 96 hrs Mentors: Popescu Andrei, Mihai Neacsu, DeepakTags: C, consolidation, code reduction, refactoring, cleanup

BRL-CAD is huge. With any large body of code, one inevitably ends up with a mix of good and bad coding practices. On the whole, BRL-CAD is actually better than most but we are constantly working on improving the code. This includes eliminating duplication.

References:

  • http://en.wikipedia.org/wiki/Don't_repeat_yourself
  • http://brlcad.org/wiki/Code_Cleanup
  • http://brlcad.org/wiki/Compiling
  • http://brlcad.org/wiki/SVN

This task involves reducing BRL-CAD's source code by 100 or more lines of code by refactoring and eliminating duplicate code. You can use whatever method you like to identify duplication, but beware that there are more than 1 million lines of code in BRL-CAD, so you're not likely going to find this duplication just by browsing.

We suggest using a code duplication detection tool like Simian. See our Code_Cleanup page for details.

Download our latest Subversion trunk sources and make sure you can compile cleanly first. Then you can run Simian or do whatever you need to find sources of code duplication. Make your edits, then make sure the code still compiles (run "make", "make test", "make regress" and "make benchmark" to test your changes). Finally, create and submit a patch file of your changes (see the references, svn will create the patch file for you).

Feel free to join the brlcad-devel mailing list or IRC channel to discuss your changes beforehand.

Uploaded Work
File name/URLFile sizeDate submitted
factory_patch29.1 KBDecember 15 2014 20:33 UTC
Comments
rj60001on December 1 2014 17:27 UTCTask Claimed

I would like to work on this task.

Deepak on December 1 2014 17:28 UTCTask Assigned

This task has been assigned to rj60001. You have 100 hours to complete this task, good luck!

rj60001on December 1 2014 17:28 UTCClaim Removed

The claim on this task has been removed, someone else can claim it now.

Prestion December 4 2014 13:34 UTCTask Claimed

I would like to work on this task.

Popescu Andrei on December 4 2014 13:36 UTCTask Assigned

This task has been assigned to Presti. You have 100 hours to complete this task, good luck!

Melange on December 7 2014 17:36 UTCTask due soon

There are less than 24 hours left until the deadline, please submit your work soon.

Melange on December 8 2014 17:36 UTCTask Reopened

Melange has detected that the final deadline has passed and it has reopened the task.

Marc Tannouson December 15 2014 12:24 UTCTask Claimed

I would like to work on this task.

Popescu Andrei on December 15 2014 12:25 UTCTask Assigned

This task has been assigned to Marc Tannous. You have 96 hours to complete this task, good luck!

Marc Tannouson December 15 2014 20:38 UTCWhat I did

First, I tried using simian on my VM, and after 2 hours of letting it work I realized that there is no point in doing that and finally got together and started installing a Debian which runs in Dual boot with windows 8.1 .


This seemed like an easy task, but for someone that has 2 weeks of practice in a VM of Linux, this was not the case. I learned that everything in Linux needs to be package installed, learned a bunch of terminal commands to ease my job and had to ask a lot of questions on IRC, but in the end I got a somewhat stable build of BRL-CAD running on Debian 7.5, after about 6 hours.


After that, running simian took 3 seconds and I quickly found some duplicate code I could remove in two Factory.cpp files.


My solution was simple : add the duplicated code in a common library.


Upon more research, they both had a Factory.h library in their respective folders and both Factory.h-s had the exact same code, so I deleted those, and created a Factory.h library in their parent directory that they both now use, where I added the duplicate code.


Overall, I added 200 lines of code, and erased 760, so I removed around 560 lines of duplicate code, I think I went a little bit overboard.


Hope what I did makes sense, and if it does not then I will try my best at fixing it. I am now exhausted, will go to bed, it's been a great ( but stressful ) day.


Regards,


Marc

Marc Tannouson December 15 2014 20:38 UTCReady for review

The work on this task is ready to be reviewed.

Marc Tannouson December 15 2014 20:41 UTCAlso, something to help out others

I said that if I manage to get linux working and simian functioning, I'd create a pastebin with duplicated code to help others that are working on a VM and it takes them 1-2 hours to run a simple process like that. So I outputted the results in a log and copied it into a pastebin for everyone to use, but keeping in mind there are lots of false positives in there.


http://pastebin.com/z5TRvLqe


Regards,


Marc

Sean on December 16 2014 06:07 UTCTask Closed

Congratulations, this task has been completed successfully.