473,396 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

PyProtocols, Components, and Inheritance

I've been discussing PyProtocols with a a friend
collaborating with me on a SF game project, about
the benefits and design concept of "component architecture",
and I'm a little confused by what I'm learning.

I learned the concepts of "component architecture" from
the Zope project, where if I'm not mistaken, "components"
are essentially python "mix-in" classes, and you make
a class from components by using multiple inheritance
and document this with an interface declaration:

So in this model, I have (let's say):

Interfaces: IVehicle, IAnimal
these are special (non-class) objects,
even though their declarations look like class
declarations

Components: Vehicle, Animal (each provide these interfaces)
these are just ordinary python classes

Then I can make a class by combining components:

class Horse(Animal, Vehicle):
implements(IAnimal, IVehicle)
pass

(This is an interactive fiction engine, so it would be
reasonable to think of a horse both as an animal and
as a means of transportation -- but it's just an example).

However, this is apparently not how PyProtocols works.

The PP way apparently looks something like this:

Components: are special (non-class?) objects (just like
interfaces?)

So I need something like:

class Vehicle(Component):
#... implementation snipped
pass

class Animal(Component):
#... implementation snipped
pass

then I use it by making a class:

class Horse(object):
pass

and only then do I "attach" components:

Horse.addComponent(Vehicle)
Horse.addComponent(Animal)

To me, this looks like madness. Aren't we just reinventing
multiple inheritance with obtuse syntax? Why is multiple
inheritance such a bad thing? (I can see that it can be
abused, but ISTM that real trouble comes not from broad,
shallow multiple inheritance as in the component model, but
from deep inheritance chains (as one is forced to do in
single-inheritance languages)).

Anyway, my question is WHY? I know PyProtocols is
fairly popular, so there must be some benefit to this,
but I'd really like to hear what it's supposed to be.

My friend seems to think there is a great evil in
doing it with multiple inheritance, yet the PyProtocols
way seems to be kind of complex. I had erroneously
assumed that PyProtocols and Zope component models
were more-or-less equivalent, with PP being perhaps
a bit more complete (for example, PP's interface module is
apparently a superset of Zope's).

I realize that at some level we're just having a "cultural
conflict" since we learned different versions of this
concept, but I would like to make a real attempt to
understand where he's coming from. (And yes, of course
I've asked him, but since he only knows the PP way of
doing this, I don't think he's able to tell me -- I guess
we need an interpreter. ;-) ).

I feel like there's something going on here that
I just don't "get".

Is there someone out there who can give me a PyProtocols
advocate's PoV on this? Can you tell me why PP's approach is
"better" than Zope's? (Or perhaps what you think it is
more appropriate for?). Anyway, c.l.python seemed like the
(neutral) place to ask since this is comparing two major
python packages.

Cheers,
Terry

--
Terry Hancock (ha*****@AnansiSpaceworks.com)
Anansi Spaceworks http://www.AnansiSpaceworks.com

Feb 17 '06 #1
0 1176

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Phillip J. Eby | last post by:
What is PyProtocols? -------------------- PyProtocols is an extended implementation of PEP 246, adding a new "declaration API" that lets you easily define your own interfaces and adapters, and...
0
by: Phillip J. Eby | last post by:
I goofed, missing a unit test for one of the new features: 'protocols.Variation' was broken in the 0.9.1 release. 0.9.2 fixes the bug. Sorry for the inconvenience. PyProtocols Resources...
2
by: Gonçalo Rodrigues | last post by:
Hi all, I'm not sure if this is the best forum to place this question, but haven't found a better one, so here goes. I have Python 2.3 in my machine (Windows 2000) and downloading PyProtocols...
0
by: Phillip J. Eby | last post by:
PyProtocols 0.9.3 release candidate 1 is now available for download. Assuming there are no bugs reported in the next 3-4 weeks, it will become the 0.9.3 final release in early August. What is...
0
by: Phillip J. Eby | last post by:
PyProtocols 0.9.3 release candidate 2 is now available for download. Assuming there are no bugs reported in the next 3-4 weeks, it will become the 0.9.3 final release in early August. (The...
0
by: Phillip J. Eby | last post by:
As there were no further bugs reported for PyProtocols 0.9.3rc2, PyProtocols 0.9.3 final is now available for download. There are no practical changes from rc2, except for file and documentation...
0
by: Michael Andersson | last post by:
Given a set of classes class A { enum [ ID = 0x0001} }; class B { enum [ ID = 0x0002} }; class B { enum [ ID = 0x0004} }; I wish to generate a composite class, perhaps using something like...
3
by: Junkguy | last post by:
Hi, I'm having a problem in Visual Studio in C#, using .NET Framework 1.1 Version 1.1.4322 and Microsoft Development Environment 2003 Version 7.1.3088 I make a form A and subclass it with form...
0
by: Terry Hancock | last post by:
Hi all, PyProtocols is a very nice interface/component/adapter library, but it appears to lack one thing I'm quite hooked on, which is the ability to verify that objects implement a given...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.