[Interest] Are slots even needed these days?

Till Oliver Knoll till.oliver.knoll at gmail.com
Thu Mar 17 08:35:39 CET 2016



> Am 16.03.2016 um 22:37 schrieb André Pönitz <apoenitz at t-online.de>:
> 
> On Wed, Mar 16, 2016 at 02:31:33PM +0000, Gian Maxera wrote:
>>> I can connect to Foo::bar either way. If I don't intend to ever use
>>> the old-style connect syntax, is there a reason to have "public
>>> slots:" anymore?
>> 
>> One reason that for me it’s fundamental: Readability of your code !!!
> 
> It doesn't make the code more readable then a comment
> 
>   // This is a slot !!!
>   void foo();

Extend your example to a dozen or so slots and you'd quickly agree that

private slots:
  void foo();
  void bar();
  void baz();
  ...

is much more readable, as compared to, say, repeating your comment or writing something like "The following 12 methods are slots (but the 13th isn't! And I'm pretty sure that the next Joe Programmer will insert his/her "barFooWhichIsNotASlot()"-method randomly between the first 12 methods anyway... so whatever!)"

Off course you can try to emphasise your slots with nice ASCII art comments, start a fight with your colleagues about the style guide for comments...

Or just write

  private slots:

;)

Cheers,
  Oliver


More information about the Interest mailing list