partial class

Christopher Wright dhasenan at gmail.com
Sat Nov 1 09:24:41 PDT 2008


Julio César Carrascal Urquijo wrote:
> Hello Ary,
> 
>> Conclusion: the motivation is coming from the UI, and to make life
>> easier for them. (Maybe there are other reasons? I've been programming
>> a lot in C# lately, and I never needed a partial class)
>>
>> Since D doesn't have a UI designer or nothing is integrated that
>> much... what would you use partial classes for?
>>
>> If it's not for that reason, I think it makes it harder to know where
>> is defined the code you are looking for.
> 
> One place I've used them is when calling web-services. Most web-services 
> calls need to generate a very specific XML document and building this 
> manually means that methods grow hundreds of lines. I use partial class 
> to separate each of this monster methods form connection pooling and 
> other concerns of the same class:
> 
> ServiceConnection.cs // Connection pooling
> ServiceConnection.OTA_AirAvailRQ.cs
> ServiceConnection.OTA_AirBookRQ.cs
> ...
> 
> An the usage is like this:
> 
> using (var conn = new ServiceConnection(connectionString))
> {
>    conn.Open();
>    var result = conn.OTA_AirAvailRQ(...);
>    ...
> }
> 
> You might say that we could separate things into several objects but 
> that's the whole point of the Facade pattern: Making one big call with 
> all the data needed to avoid several round trips over a slow network.

Model / view / presenter?
http://martinfowler.com/eaaDev/SupervisingPresenter.html

I'm not sure what you mean by "avoid several round trips over a slow 
network" -- having one extra class won't force that. It's the difference 
between your view generating a partial request and your view generating 
a complete request (and perhaps submitting it at the same time). You'd 
have the exact same approach with partial classes as with multiple classes.



More information about the Digitalmars-d mailing list