What do you call the design where the object's constructor is responsible for all/any subsequent actions. Usage of this class involves simply creating an instance and then it's all fire-and-forget.
A silly example:
public class Order
{
public Order(int ammount,Product type)
{
Ammount = ammount;
Namespace.OrderManager.RegisterNewOrder(this);
Namespace.WarehouseManager.Substract(this);
Namespace.OrderManager.Invoice(this);
Namespace.DeliveryManager.Deliver(this);
.. well, you get the point;
}
// Called back later from DeliveryManager
public void OrderHasBeenDelivered()
{
//save some data to the DB, or notify the UI
}
// Called back later from OrderManager
public void OrderHasBeenCanceled()
{
Namespace.DeliveryManager.CancelDelivery(this);
}
}
... usage of the Order class :
public void CreateOrder_click(object sender, EventArgs e)
{
new Order(50, CDs);
new Order(10, DVDs);
new Order(10, DVDs);
}
Edit:
Well, the difference between using this and a simple static method, is that the newly created Order object is going to be used in many different places, just not by the function/thread/object that created it.
I simply create the order object, it registers itself with the OrderManager, then the OrderManager will close the order at a later time. I don't throw the object away per-se, it will continue to exist in the app.