Partial classes

S

Sanjay

Class PersonBO(Person):
<OT>
shouldn't it be:
class PersonBO(Person):
def block(self):
self.blocked = True
</OT>

Yes, it should be as you mentioned. However, I had posted it to
elaborate the case. Actually, I tested using the following code:

class PersonBO(Person):
pass
Care to explain your solution ?

For the time being, I am not separating the plumbing and business
logic. When I need to, I shall come back to this post, study all the
ideas suggested, and jot down the pattern suitable to me. The code
pattern using metaclass looked interesting to me.

Thanks
Sanjay
 
J

John Salerno

Bruno said:
What the ... is GUI code doing in a domain object ???

well, as far as visual studio goes, it puts the GUI code in a partial
class that you don't see, and then you do the rest of your coding in the
other part of the same class...i suppose you can change it however you
like, but that's the way it starts...
 
R

Rob Williscroft

Bruno Desthuilliers wrote in in comp.lang.python:
What the ... is GUI code doing in a domain object ???

It doesn't (shouldn't) really work like that.

The partial classes are used by GUI designer tools (Visual Studio[1]
and SharpDevelop[2] for example) to seperate code that the tool generates
from code (event handlers etc) that the programmer writes.

IOW hopefully both parts of the class have GUI code in them.

[1] http://msdn.microsoft.com/vstudio/
[2] http://www.sharpdevelop.net/OpenSource/SD/

Rob.
 
M

Michele Simionato

Sanjay ha scritto:
Thanks for the code showing how to implement partial classes. Infact, I
was searching for this code pattern. I will have a study on metaclass
and then try it.

Thanks
Sanjay

Anyway, I would suggest you NOT to use this code in production. Yes,
Python
can imitate Ruby, but using this kind of classes would confuse
everybody and
make your code extremely unpythonic. As always, consider changing your
mindset,
when you switch language. For you problem, you could just put your
client
methods in a file, and add them to your original class with setattr, if
you don't
want to use inheritance. It would be still better that magically
transform your
classes with a metaclass.

Michele Simionato
 
S

Sanjay

Anyway, I would suggest you NOT to use this code in production. Yes,
Python
can imitate Ruby, but using this kind of classes would confuse
everybody and
make your code extremely unpythonic. As always, consider changing your
mindset,
when you switch language. For you problem, you could just put your
client
methods in a file, and add them to your original class with setattr, if
you don't
want to use inheritance. It would be still better that magically
transform your
classes with a metaclass.

Thanks for the much needed guidence.

Sanjay
 
S

Stefan Behnel

Kay said:
What about letting your teammates editing certain data-structures in
different files ( physical modules ) but using them in a uniform way
and enable a single access point. If you have partial classes there is
no reason why your team has to share a large file where they have to
edit a single class but break the class into different parts and edit
the parts separately. No one has to care for including any module
because the CLR fits all partial classes together at compile time.

I can't believe I always used version control systems for that use case if
it's that easily solved with partial classes.

Stefan
 
B

Bruno Desthuilliers

Stefan said:
I can't believe I always used version control systems for that use case if
it's that easily solved with partial classes.

Collaborative work is only one of the needs solved by VCS.
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top