View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0007609 | Scribus | Internal | public | 2008-11-13 12:46 | 2015-06-29 04:12 |
Reporter | dclemente | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | always |
Status | new | Resolution | open | ||
Product Version | 1.3.5svn | ||||
Summary | 0007609: In code: Replace constant numerical values with helpful named constants | ||||
Description | See 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) | ||||
Tags | No tags attached. | ||||
Patch | |||||
child of | 0002382 | acknowledged | Metabug: Code quality, structure, readability |
|
Quick access to see this: https://github.com/scribusproject/scribus/blob/master/scribus/ui/annot.cpp |