[Buildbot-devel] best way to override the createSummary() function in different custom steps

shiny knight theshinyknight at me.com
Tue Feb 19 23:53:41 UTC 2013

Thanks for the reply Jeff

Didn't considered that I can just call the superclass function from the other class; this will shorten the length of the specific functions, since I can just use an IF to see if I need to call the main generic createSummary() or the specific one.


On Feb 19, 2013, at 9:36 AM, Jeff Licquia wrote:

> On 02/19/2013 02:28 AM, shiny knight wrote:
>> I wrote a sub class of ShellCommand, called "MyShell" and I wrote my own createSummary.
>> Now I realized that I have some steps that require more specific data, and that perform some other tasks, so I have 2 subclasses of this custom ShellCommand class, called "MySubShell1" and "MySubShell2". Each one has it's own createSummary, to handle the specific needs of that step.
>> Now from my understanding, when I call the createSummary in either MySubShell, it will override the one on the parent class. This means that createSummary in either MySubShell will override the function in MyShell.
>> Much of the code is very similar, so I was wondering which would be the correct way to handle this situation.
>> I use all 3 classes in the same builder, but each one gotta return me a different set of information, so I cannot just use 1 createSummary on the parent class (unless I use a bunch of IF cases, to specify which case I am handing), and as is now, I have 3 classes with 3 createSummary, which share 70% of the same code, and seems to me a big waste of code.
>> Any suggestion about how to tackle the problem? Should I just leave it with the 3 createSummary() or there is a more efficient way?
> There are a few strategies you can use:
>  - You can refactor createSummary() for the three classes such that the 
> shared code is in a separate, unrelated function, which you then call at 
> the appropriate time.
>  - You can call MyShell.createSummary(self, ...) from the child class 
> createSummary() functions.
> The right answer will depend on the details of how createSummary() works 
> for your custom classes.
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb
> _______________________________________________
> Buildbot-devel mailing list
> Buildbot-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/buildbot-devel

More information about the devel mailing list