[Ktechlab-devel] simulatormanager branch

Julian Bäume julian at svg4all.de
Tue Jul 27 08:44:24 UTC 2010


moin,
I had a look into the simulatormanager branch and want to add some
comments to the interface.

There are some methods that aren't supposed to
change the state of their class in any way. These should be declared as
const. These are:

virtual QString&
ISimulatorFactory::simulationType();
should be:
virtual QString
ISimulatorFactory::simulationType() const;

The way it is now means that you
will be able to get the simulation-type and change it's value outside the
class, because it returns a reference to the string. Making the method const
means, that you won't be able to change internal state of the class using
this method. This would make the returned reference const. It's better to
just return a QString there, because it would break existing code,
otherwise. That's not a performance problem, because of QStrings
implicit-sharing. The string-data will only get copied, when you try to
manipulate the string itself. If you only call const methods of QString,
there won't be any copying.

More methods, that count in here:
virtual
QString &ISimulatorFactorysupportedDocumentMimeTypeName();
virtual QString
&SimulatorFactory::simulationType();
virtual QString
&SimulatorFactory::supportedDocumentMimeTypeName();

I'm not sure about the
ISimulatorFactory::create-method, though. The current implementation doesn't
change the internals, but may be, it will do later.

The IElementFactory
class looks better, concerning constness. I dont't think, you should return
const QString&, but just plain QStrings. This would make it easier to use,
because you don't have to copy things around yourself, if you want to "work"
with the returned data. Same for the const QList.

The private member
variables in GenericElementFactory should have the "m_"-prefix, just to be
consistent.

Okay, that's all for now. I think the next step should be to
try to implement some elements using all this and see, if this interface
works out. If we find some problems, we can still adapt (Yay, we're all
gonna be Borg!) :)

bye then
julian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/ktechlab-devel/attachments/20100727/b92fff43/attachment.sig>


More information about the Ktechlab-devel mailing list