Re: [dabo-users] Subclass Dabo objects.

Author: Paul McNett

Posted: 2012-03-07 at 10:35:53

On 3/6/12 11:48 AM, Ed Leafe wrote:

> On Mar 6, 2012, at 1:27 PM, Paul McNett wrote:

>

>> The examples you cite do not, in and of themselves, suggest making a subclass in

>> Dabo, although they sure did in VFP.

>

> While it's certainly easier to do in Dabo, I tend to be lazy. If I have to add dozens of controls with the same changes across many forms, I'd rather define the subclass once and then use that in all my forms.

True, I do that as well. The point being, in Python/Dabo it is so much easier to

refactor your class structure after the fact that you may as well do the simplest

thing that will work at the time, rather than doing all the thinking ahead that was

commonplace in VFP development.

So when crafting a form, start out using the Dabo base classes. Then if you find

yourself setting the same properties over and over again, you have a candidate for a

small or large refactor. I'm constantly refactoring stuff in my codebase because,

like Ed, I'm lazy when I'm heads-down developing something for the first time getting

it to work. But later on, maybe months or even years later, when I'm revisiting to

add something anyway, I'll spend 15 minutes reading the code and refactoring the

obvious things.

>> hs.append(dabo.ui.dTextBox(self, DataField="name", **dataCtrlProps))

>

> I prefer the properties parameter rather than the ** form:

>

> hs.append(dabo.ui.dTextBox(self, DataField="name", properties=dataCtrlProps))

>

> They both work the same, but that's what that parameter was created for.

I prefer the ** way because it is more Pythonic, shorter to write, and easier to

immediately understand.

Paul

_______________________________________________

Post Messages to: Dabo-users@leafe.com

Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users

Searchable Archives: http://leafe.com/archives/search/dabo-users

This message: http://leafe.com/archives/byMID/4F578E69.2070809@ulmcnett.com

©2012 Paul McNett