Re: singleton naming
Philippe Fremy <
phil@...>
2006-12-19 16:49:22 GMT
Dmitry Suzdalev wrote:
>> So, the solution would be to use only YZSession::self() and
>> QYZSession::self(), and have the YZSession::me private or protected. That
>> way, we would always know exactly what is returned.
> In fact there's no YZSession::self() method. And there can't be.
> Because then it would clash with QYzisSession::self().
> And overriding non-virtual methods is a bad thing (tm).
> And X::self() can't be virtual because it's static
.
>
>> Did you see in the code any reason why YZSession::me is used in some
>> places
>> and not YZSession::self() ? It might just be because it is easier to type
>>
> "cd qyzis && grep self *" gives me:
>
> editor.cpp: QYZisSession::self()->setCurrentView( mParent );
> main.cpp: v =
> QYZisSession::self()->createBufferAndView( args.at(i) );
> main.cpp: first =
> QYZisSession::self()->createBufferAndView();
> main.cpp: QYZisSession::self()->setCurrentView( first );
> qsession.cpp:QYZisSession* QYZisSession::self() {
> qsession.h: static QYZisSession* self();
> viewwidget.cpp: : YZView( _buffer, QYZisSession::self(), 10 ), buffer(
> _buffer ), m_popup( 0 )
>
> So it seems like in all these cases YZSession::me would do - no need
> for QYzisSession::self() at all. Correct me if I wrong.
(Continue reading)