Is this a case for metaclasses?

H

Hartmut Goebel

Hi,

I'm currently implementing a tool for auto-generating webforms from a
desription file. The output should become a php-script, an asp-script,
zope-formulator or such. Each if it may (or may not) have javascript
additions. The output format should be defined ar runtime (php,
php+javascrip, asp, asp+javascript, etc.).

Currently I have a fixed class hierarchy:

generic : implements generic html widgets (input, radiobuttons)
php : "mixin" for adding php-specifi code to the widget,
eg. getting values from HTTP_POST_VARS/_POST
javascript : adds javascript scripts, eg. error checking

Obviously this does not scale as soon as I add more mid-layers (asp,
psp, etc.).

For me this sounds like I could benefit from using metaclasses here.
Before I start implementing such a beast, I want to be shure, there will
be a benefit.

Any suggestions?

--
Schönen Gruß - Regards
Hartmut Goebel

| Hartmut Goebel | IT-Security -- effizient |
| (e-mail address removed) | www.goebel-consult.de |
 
M

Michele Simionato

Hartmut Goebel said:
Hi,

I'm currently implementing a tool for auto-generating webforms from a
desription file. The output should become a php-script, an asp-script,
zope-formulator or such. Each if it may (or may not) have javascript
additions. The output format should be defined ar runtime (php,
php+javascrip, asp, asp+javascript, etc.).

Currently I have a fixed class hierarchy:

generic : implements generic html widgets (input, radiobuttons)
php : "mixin" for adding php-specifi code to the widget,
eg. getting values from HTTP_POST_VARS/_POST
javascript : adds javascript scripts, eg. error checking

Obviously this does not scale as soon as I add more mid-layers (asp,
psp, etc.).

For me this sounds like I could benefit from using metaclasses here.
Before I start implementing such a beast, I want to be shure, there will
be a benefit.

Any suggestions?

Metaclasses are essentially syntactic sugar. You can do more or less
everything without them. For instance you can use a poor man function
to
format your classes as you wish. Then, you have to apply the function
to the every subclass by hand. If you use a metaclass, subclasses are
automatically reformatted, instead. So, using a function means
a bit more typing but greater expliciteness. Metaclasses are okay
if you want to hide to your users the fact that something magic is
going on.


Michele Simionato
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top