Class or library

  • Greetings.

    I am working with Qt + OpenCV. However, my question is can qualify rather as a general question about OOP (and for that reason I put it in this forum section)

    I am currently writing a class that implements a series of morphological operations that are not in openCV (like erosion and dilation geodesic among others).

    Given the characteristics of what I want to develop (or I'm developing) the class has only static member functions, and this is my question:

    My class is just a collection of functions (all static), more like a library. So, I have a doubt which is the best approach to work in this case:

    1. Just like that as I did ... a class with no attributes and only static member functions.

    2. A library of functions (style C)

    3. Any other approach more efficient or appropriate.

    I must say that I choose the first option (1) because I'm working with C++, Qt and C++ API of OpenCV (all Object Oriented), but obviously, I was not sure it was the best choice to work in a case like I described.

    Furthermore, in the case of Option 1:

    Does the class constructor and destructor must have?

    Thanks in advance for any responses and/or comments.

  • Hi

    Here is my take on it (my comment is based on the assumption that you need access to these functions across different classes): Since all your functions are static, you will never need to instantiate an object of your class, which means having the class in the first place is obsolete. In this instance, I would personally have used a namespace to group (what seems to me to be) a bunch of utility functions together and the reason for my decision is this:

    "How non-member functions improve encapsulation":

    Hope that helps :)

Log in to reply

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