Difference between revisions of "Writer/ToDo/Writer Refactoring/Writer Refactoring"
(→Steps) |
|||
Line 30: | Line 30: | ||
* Wrong initialization sequence of class members | * Wrong initialization sequence of class members | ||
* Lack of documentation | * Lack of documentation | ||
+ | * Duplicate code - Using CPD [3] with a minimum token count of 100 on SRC680m156 'sw/source' leads to the following results: 11324 duplicate lines of roughly 739620 overall lines of code which nearly amounts to ~1.53% duplicate code. | ||
== Goal statement == | == Goal statement == | ||
Line 46: | Line 47: | ||
'''Status:''' in progress '''Details:''' There is a lot of code commented out via #if 0 ... #endif, /* */, or no longer used defines e.g. 'JAVASCRIPT'. | '''Status:''' in progress '''Details:''' There is a lot of code commented out via #if 0 ... #endif, /* */, or no longer used defines e.g. 'JAVASCRIPT'. | ||
'''Reason:''' Inactive code is a unnecessary burden and often confuses potential maintainer of the code. | '''Reason:''' Inactive code is a unnecessary burden and often confuses potential maintainer of the code. | ||
+ | * Minimize code duplication | ||
+ | '''Status:''' new '''Details:''' Using CPD [3] with a minimum token count of 100 on SRC680m156 'sw/source' leads | ||
+ | to the following results: 11324 duplicate lines of code of roughly 739620 overall lines of code which nearly amounts to | ||
+ | ~1.53% duplicate code. '''Reason''' Less duplicate code means less code to maintain. Bugs in duplicated code need | ||
+ | to be fixed in all duplicate places which are hard to detect without the help of tools, so less duplicate code means | ||
+ | fewer redundant sources of bugs. | ||
* Write unit test | * Write unit test | ||
'''Status:''' in progress '''Details:''' 1 unit test for BigPtrArray has been introduced | '''Status:''' in progress '''Details:''' 1 unit test for BigPtrArray has been introduced | ||
Line 64: | Line 71: | ||
* Backspace may take several seconds in documents with many hidden redlines | * Backspace may take several seconds in documents with many hidden redlines | ||
* Undo-delete still doesn't work in all circumstances (section-to-section) | * Undo-delete still doesn't work in all circumstances (section-to-section) | ||
+ | |||
+ | [3] Copy Past Detector (CPD) http://pmd.sourceforge.net/cpd.html |
Revision as of 07:58, 10 February 2006
Caution
This page is still under construction hence the content is still very tentative.
Problem statement
As Bertrand Meyer [1] describes external software qualities (experienced by the user of the software) like
- Correctness - The ability of software products to perform their exact tasks, as defined by their specification.
- Robustness - The ability of software systems to react appropriately to abnormal conditions.
- Efficiency - The ability of a software system to place as few as possible demands on hardware resources, such as processor time, space occupied etc.
for instances are in direct relation to internal software qualities (experienced only by computer professionals with access to the source code of the software) like modularity, testability, maintainability.
The current Writer code base has some serious quality problems with regards to these internal software qualities what consequently leads to external quality problems like crash reports, malfunctions, performance problems, memory leaks. See [2] for some concrete examples otherwise use IssueZilla and search for defects in OOo Writer.
Some facts and numbers about the writer code and and the code quality (still) in random order
- Build time - to build the Writer from scratch takes
- Link time dependencies - linking the Writer roughly takes x minutes on a
- Code not testable because of cyclic dependencies
- No unit tests available - Until milestone SRC680m147 there exist not a single unti test for the Writer code
- Code optimized for legacy computer systems e.g. Win16 - Example: BigPtrArray (see sw/source/core/bastyp/bparr.cxx)
- Redundant code
- Big and complex classes with multiple responsibilities - Example: SwDoc
- No clearly designed and documented interfaces and abstractions
- Hand crafted data structures (no STL)
- Unwanted dependencies between UI, Core, Layout
- Fragile code (Undo, Redlining, ...)
- Base classes without virtual destructor
- Single argument constructors are not declared 'explicit'
- Wrong initialization sequence of class members
- Lack of documentation
- Duplicate code - Using CPD [3] with a minimum token count of 100 on SRC680m156 'sw/source' leads to the following results: 11324 duplicate lines of roughly 739620 overall lines of code which nearly amounts to ~1.53% duplicate code.
Goal statement
- Prioritize problems
- Break problems into pieces <= 3 man months
Steps
On cws writercorerefactoring the following steps are planned:
- Removal of unused files
Status: done Details: 19 files which were not build anymore have been removed
- Removal of unnecessary includes of headers
Status: done Details: 850 unnecessary includes of header files have been removed in the Writer code base
- Removal of unused/inactive code (how many lines?)
Status: in progress Details: There is a lot of code commented out via #if 0 ... #endif, /* */, or no longer used defines e.g. 'JAVASCRIPT'. Reason: Inactive code is a unnecessary burden and often confuses potential maintainer of the code.
- Minimize code duplication
Status: new Details: Using CPD [3] with a minimum token count of 100 on SRC680m156 'sw/source' leads to the following results: 11324 duplicate lines of code of roughly 739620 overall lines of code which nearly amounts to ~1.53% duplicate code. Reason Less duplicate code means less code to maintain. Bugs in duplicated code need to be fixed in all duplicate places which are hard to detect without the help of tools, so less duplicate code means fewer redundant sources of bugs.
- Write unit test
Status: in progress Details: 1 unit test for BigPtrArray has been introduced
- Make SwDoc interface based, changes clients of SwDoc to just include the header files for these interfaces instead of the whole doc.hxx
Goal: Reduce unnecessary build time dependencies, first step to break SwDoc into managable and testable pieces Status: in progress Details: SwDoc (see sw/inc/doc.hxx) is a huge class with more than 130 data members and hundreds of member functions. This class has mutliple responsibilities this implies that SwDoc has a lot of different clients. Each of these clients usually requires just a small part of the SwDoc interface. With SRC680m146 434 of 763 source code files directly or indirectly include doc.hxx in which the interface of SwDoc is declared. This results in undesirable build times when changing doc.hxx. X Interfaces for SwDoc have been introduced related code has been changed to use these interfaces instead of the whole doc.hxx
References
[1] Betrand Meyer, Object Oriented Software Construction, ISBN: 0-13-629155-4
[2] Long existing, hard to fix quality problems in OOo Writer (to be extended)
- Cannot select whole document when table is at beginning
- Backspace may take several seconds in documents with many hidden redlines
- Undo-delete still doesn't work in all circumstances (section-to-section)
[3] Copy Past Detector (CPD) http://pmd.sourceforge.net/cpd.html