views:

60

answers:

0

I somewhere heard that the .NET Framework was built around specific pattern, which they tried to uphold as much as possible.

var rsa = new RSACryptoServiceProvider(); // Create
rsa.ImportParameters(GetParameters()); // Set
byte[] encrypted = rsa.Encrypt(data, true); // Execute
// Destroyed by garbage-collector

Are there any variants of this? What are the general pros and cons?

This is in contrast to other ways to design constructors, properties and methods.

var unintuitiveObject = new UnintuitiveObject(true, true, false, true);
unintuitiveObject.Init();
unintuitiveObject.Property = property;
unintuitiveObject.ActivateOtherComponent();
unintuitiveObject.Object = unintuitiveObject.CreateNewObject();

This is not very intuitive. Sure, things like this could be going on under the hood, but the public-facing features in .NET has the goal to enforce this.