[Uml-devel] Some Umbrello code style questions for a patch

Daniel Calviño Sánchez danxuliu at gmail.com
Sun Mar 26 22:12:04 UTC 2006


Hi. I'm adding an option to the "Export all views" action
(http://bugs.kde.org/58809) and I have some questions about code
style. The option I'm adding is keep the tree structure used to store
the views in the document in the target directory, so if you have your
diagrams in folders created by you in the document, those folders are
created when exporting (Logical view, use case view and so on aren't
created).

In order to add that option, I've also refactored a bit the
ExportViewAction class and the exportImage() method in UMLView. I've
made a class, UMLViewImageExporter, that contains the methods that do
"all the work", and that class is used by other methods that take care
of asking the user where to save the image, the format to use, and so
on.

The problem is that the non-interactive methods can fail due to
various things. So I thought in throwing exceptions and catch them
where they were called so an information message is shown to the user
if needed (for example, if the exporting was made through
command-line, the message box wouldn't be shown).

But, after a search, I found that no exceptions are thrown in Umbrello
code (at least, I haven't found them). So, the question is, can I use
exceptions? Or maybe I should think in another way to report errors
(with return values, for example)? I mean, perhaps you don't use
exceptions because of compiler compatibility or something like that.

The other question is related to where put the interactive code. Right
now, the "Export view" action code is in UMLView class. The "Export
all views" action is in ExportViewAction class, which is a KAction
subclass. I think that the UMLView class code should be extracted to
another class, maybe another KAction subclass.

Or maybe you prefer the UMLView code to stay there and move the
ExportViewAction code to UMLApp. Or maybe let it as it is now. But I
think that it'd be better if a more consistent approach is used than
an action for the "Export all views" and embedded code in UMLView for
"Export view".

Any thoughts on this? If I haven't been clear, ask and I'll try to
explain better. And sorry for my English, it isn't my mother tongue
:-)




More information about the umbrello-devel mailing list