[Interest] Are slots even needed these days?

Scott Aron Bloom scott at towel42.com
Thu Mar 17 00:02:17 CET 2016



From: Interest [mailto:interest-bounces+scott=towel42.com at qt-project.org] On Behalf Of Bob Hood
Sent: Wednesday, March 16, 2016 3:42 PM
To: interest at qt-project.org
Subject: Re: [Interest] Are slots even needed these days?

On 3/16/2016 3:37 PM, André Pönitz wrote:


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();

I would argument that it does when you have legions of people out there already conditioned to this:

   ...
   public slots:
       void  bar();
       void  foo();
   ...

instead of:

   ...
       // This is a slot!!!
       void foo();
   ...
       // Oh, hey, this is a slot too!!!
       void bar();
   ...

As a Qt developer, I find the former more elegant and self-documenting.
I find them both pretty bad ☹ …  I have spent too much time, looking at other people’s code trying to figure out “why” it wont connect, only to realize someone had snuck in a “private:” second so moc didn’t generate the slot information.

I prefer “slotFoo” and “slotBar” as well as “sigFoo” and “sigBar”

It really lets the methods stand out as slots and signals.. It also means, don’t think “sender()” can ever valid if you are not in a “slotXYZ” function.

Scott



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160316/835c608c/attachment.html>


More information about the Interest mailing list