Using or not using a namespace?



  • Greetings.

    I developed an application, which has a functionality that allows to apply various operations of mathematical morphology on an image. That part of the application consists of the following libraries and classes:

    Morph.h / Morph.cpp: A set of operations (operators of mathematical morphology) enclosed in the "Morph" namespace. (Not a class).

    MorphAppDlg.ui / MorphAppDlg.h / MorphAppDlg.cpp: A class that implements a dialog box with all the widgets and funcinalities to apply the morphological operations.

    MorphConfDlg.ui / MorphConfDlg.h / MorphConfDlg.cpp: A class that implements a dialog box with the widgets and functionalities to configure the parameters of the morphological operations.

    These three classes or libraries are obviously interrelated. About that respect are my doubts.

    Although they are related, the only thing I have done to express that relationship is to put all the files in the same directory (called Morph) within the main directory of the application.

    I wonder if, in order to better express the relationship between them, should I put everything within the same namespace? I intended to call that namespace "Morph" (and rename Morph.h / Morph.cpp to MorphUtils.h / MorphUtils.cpp).

    Would this be a good design decision? Are there better options?

    I would also like to know about material (books, guides, etc.) where such design topics are treated.

    In advance, grateful for any help and/or suggestion.


  • Lifetime Qt Champion

    Hi,

    Out of curiosity, why rename the files ?



  • I thought to change the name to make it clearer. I thought of calling "Morph", the namespace of all that pertaining to morphology, and within that, give a different but appropriate namespace (like "Utils" or "MorphUtils") to the set of morphology operations.

    I did the publication because I really do not know what would be the correct / appropriate way to work in a case like the one I exposed.


  • Lifetime Qt Champion

    I'd avoid repeating the namespace name in sub-namespaces: Morph:MorphUtils vs Morph:Utils. The second is cleaner.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.