Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Brainstorm
  4. Using or not using a namespace?
Forum Update on Monday, May 27th 2025

Using or not using a namespace?

Scheduled Pinned Locked Moved Unsolved Brainstorm
4 Posts 2 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    isaacEnrique
    wrote on last edited by
    #1

    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.

    Isaac Pérez
    Programming is understanding.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Out of curiosity, why rename the files ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • I Offline
        I Offline
        isaacEnrique
        wrote on last edited by
        #3

        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.

        Isaac Pérez
        Programming is understanding.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved