View Issue Details

IDProjectCategoryView StatusLast Update
0007609ScribusInternalpublic2015-06-29 04:12
Reporterdclemente Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Product Version1.3.5svn 
Summary0007609: In code: Replace constant numerical values with helpful named constants
DescriptionSee for instance annot.cpp:

        case 0:
            item->annotation().setActionType(0);
            break;
        case 1:
            item->annotation().setActionType(1);
            switch (ScrEdited)
                {
                case 0:
                    item->annotation().setAction(EditJava->text());
                    break;
                case 1:
                    item->annotation().setD_act(EditJava->text());
                    break;
                case 2:
......


This is a mess, because you don't know what the values 0, 1, 2, ... represent. Neither the meaning of 1 in setActionType(1) nor all the „case“.
This makes developing und understanding the code hard, specially for new programmers.

It's better to use named constants like:
AppMode.modeDrawRegularPolygon.
Some of them are defined in scribusstructs.h, others somewhere also.
Some are defined in an enum (good), but they are however accessed via a number (bad). This breaks the code if someone adds a new value in the middle of the enum, because numbers will change.

To do: change all numerical constants into named constants (stored in enum)
TagsNo tags attached.
Patch

Relationships

child of 0002382 acknowledged Metabug: Code quality, structure, readability 

Activities

Issue History

Date Modified Username Field Change
2008-11-13 12:46 dclemente New Issue
2015-06-20 13:23 Kunda Note Added: 0035464
2015-06-29 04:12 Kunda Relationship added child of 0002382