PDA

View Full Version : using "public slots:"



TheKedge
1st February 2006, 17:00
Hello all,
silly question, I suppose, but: is there any disadvantage in declaring public functions in a class, per default, as public slots ? That is, even though the "slot" aspect may never be used.

thanks,
Kev

jacek
1st February 2006, 17:36
IMO it will only make the code bigger.

Chicken Blood Machine
1st February 2006, 17:59
^^^^ Ditto.

GreyGeek
1st February 2006, 18:11
Hello all,
silly question, I suppose, but: is there any disadvantage in declaring public functions in a class, per default, as public slots ? That is, even though the "slot" aspect may never be used.

thanks,
Kev

Kev,
I am curious. What would be the purpose for doing that?:confused:

Bojan
2nd February 2006, 00:58
Other disadvantage may be that it produces a little more confusing, or at least, not as intuitive interface and design. For example it makes very little sense to make any accessor methods slots. For example in this toy class:


class Point2D
{
public:
Point2D(double x, double y) : m_x(x), m_y(y) {}

public slots:
double x() { return m_x; }
double y() { return m_y; }

private:
double m_x;
double m_y;
};

This is a joke of a code that I just typed up, but nevertheless, it makes very little sense for x() and y() functions to be slots. If I had documentation comments, doxygen would pick them up as slots and document them as such. This would lead to the client using the Point2D class to believe that these are slots, which is kind of unintuitive considering using these functions as slots woulb be silly. I don't know if I explained this well, but it's kind of a disadvantage I think. Maybe I am just being picky. I know it's not technical, like jacek's point. There could be also other situations where making a function a slot doesn't really make sense, depending on the context, design, etc...

Bojan