I would like to use nested classes for a "developing state":
public class WebSvcClient : IDisposable
{
//
// 10 private fields required by all methods
...
public Profile Profile { get; private set; }
public void Authenticate()
{
this.Profile = new Profile();
}
public class Profile
{
// public methods that do require authentication
...
}
// public methods that don't require authentication
...
}
I can see several benefits:
- Encapsulation,
Profilemakes sense only in the context ofWebSvcClient - Single
IDisposableunit - Lack of need for 3rd class just to pass the private fields to
Profile - No pollution of namespace
But is it considered good practice?
Aucun commentaire:
Enregistrer un commentaire