Identify and eliminate code duplication (100+ lines) #5BRL-CAD
Status: ClosedTime to complete: 72 hrs Mentors: Kesha ShahTags: C, programming, refactoring, reduction

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
duplicate_removal_4.diff29.2 KBDecember 31 2013 05:22 UTC
Comments
Kartikey Kanton December 14 2013 12:58 UTCTask Claimed

I would like to work on this task.

Kartikey Kanton December 14 2013 13:03 UTCClaim Removed

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

Peter Amidonon December 30 2013 23:37 UTCTask Claimed

I would like to work on this task.

Kesha Shah on December 31 2013 01:00 UTCTask Assigned

This task has been assigned to Andromeda Galaxy. You have 72 hours to complete this task, good luck!

Peter Amidonon December 31 2013 05:22 UTCReady for review

The work on this task is ready to be reviewed.

Sean on December 31 2013 05:53 UTCtool changes

Andromeda, this is interesting but did you verify that you didn't just make two different tools now produce the same output?  The brep_simple and twisted cube tools created slightly different geometry.  There was still massive duplication between the two so I'm sure it's conveivable that you didn't change behavior but it's worth quickly checking.  Just make sure that the output from the tools you modified matches what they produced from before you modified them.  I believe they reside in the src/proc-db build directory as unpublished dev testing tools.


As for the patch, it needs one tiny minor correction.  You name the header as twistedcube.hpp in the build file but twistedcube.h in the source file.  Probably need to adjust the CMakeLists.txt file to reflect the name you actually used.


 

Sean on December 31 2013 05:53 UTCTask Needs More Work

One of the mentors has sent this task back for more work. Talk to the mentor(s) assigned to this task to satisfy the requirements needed to complete this task, submit your work again and mark the task as complete once you re-submit your work.

Peter Amidonon December 31 2013 06:00 UTCReady for review

The work on this task is ready to be reviewed.

Peter Amidonon December 31 2013 06:02 UTCCorrect tools

I checked files generated from a clean checkout and from the source with this patch applied in Archer; they appear to be the same, and there is a definite difference between brep_simple and brep_cube

Sean on December 31 2013 06:41 UTCclarity

not sure I'm reading your reply right -- are you saying that brep_simple from before and after your edit produce the same output?  or just that brep_simple and brep_cube after the edit produce different output?


 

Sean on December 31 2013 06:41 UTCTask Closed

Congratulations, this task has been completed successfully.

Peter Amidonon December 31 2013 07:00 UTCoutput


Both: brep_simple from before and after look the same (in Archer), as does brep_cube; brep_simple after and brep_cube after produce different output.