[Qt-interest] 答复: capture screen

Scott Aron Bloom Scott.Bloom at onshorecs.com
Tue Jun 15 22:19:57 CEST 2010


-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Carsten Breuer
Sent: Tuesday, June 15, 2010 12:48 PM
To: Malyushytsky, Alex
Cc: qt-interest at trolltech.com
Subject: Re: [Qt-interest] 答复: capture screen

Hi Alex,

> There is nothing wrong with using "this" even though it is not required.
> Sometimes it saves you time clearly stating that you are calling the member function and not global one.

I disagree here. The "this" desease started with scripting languages like
python, java etc. C++ works over a decade without it because developers
understand namespaces.It make the code less readable, worse maintainable
and is pretty much useless. Torvalds would say "stupid and uggly" ;-).
There are cases, where the use of "this" clarify things, i agree.
To use this for every access of class members is IMO pretty worse
and in the context of the given example it was totally useless, more
than then that, redundant:

--------------
I think it also started when C++ developers stopped being concerned about prefixing their member objects.
Hide() vs this->hide() is a problem in my view...

However, when you have a function isHidden(), and inside the class you store a variable to store if its hidden, and you call it isHidden, without a prefix (f,s, m_ etc etc ) 

Your function will have to look like..
bool className::isHidden() const
{
return this->isHidden;
}


Frankly, I HATE in Qt where they do this, and it gets done a ton.. But Ive learned to live with it...

In my view, The formatting of function names and methods should be different then member variables for just this reason.

Scott





More information about the Qt-interest-old mailing list