[Qt-creator] Use IBuildStepFactory in IBuildConfigurationFactory
Tobias Hunger
tobias.hunger at digia.com
Thu Nov 14 10:23:05 CET 2013
On 13.11.2013 18:38, Mateusz Loskot wrote:
> Is the creation of a factory so terribly complex that it excuses
> copy-n-paste of code and managing of strings with process arguments
> and overall initialisation of a processing step instance in multiple places?
I think
WhatEverStep *step = new WhatEverStep;
step->setSomething(42);
step->setSomethingElse("42");
step->setSomethingSpecial("this needs to be different from the
default");
step->setDisplayName("whatever is appropriate here");
is simpler to follow than this:
WhatEverStepFactory *factory =
ExtensionSystem::PluginManager::getObject<WhatEverStepFactory>();
QTC_ASSERT(factory, return);
WhatEverStep *step = factory->create(...);
// Use factory defaults for Something and SomethingElse
step->setSomethingSpecial("this needs to be different from the
default");
step->setDisplayName("whatever is appropriate here");
Of course that does depend on the situation and the number of properties
to set on a buildstep.
The code should differ in some properties to be set -- and those need to
match up with the other properties set on that object to make sense. So
in those situations I think it is better to not split up the
initialization between the factory and wherever the special setup is
needed -- if such a split can be avoided. When you change the factory
you will then have to check this other place anyway to make sure the
overall settings still make sense.
If "default steps" are needed though, then the factories should indeed
be used instead.
Best Regards,
Tobias
--
Tobias Hunger, Senior Software Engineer - Digia, Qt
Digia Germany GmbH, Rudower Chaussee 13, D-12489 Berlin
Geschäftsführer: Mika Pälsi, Juha Varelius, Tuula Haataja
Sitz der Gesellschaft: Berlin. USt-IdNr: DE 286 306 868
Registergericht: Amtsgericht Charlottenburg, HRB 144331 B
More information about the Qt-creator
mailing list