I have a Cart class that has a lot of properties:
public class Cart
{
public Customer Customer { get; set; }
public Products Products { get; set; }
public Payments Payments { get; set; }
public DateTime TimeOfArrival { get; set; }
//...and so on
}
Whenever I want to instantiate a new Cart
, I need to initiate these properties. Some of them are already known (e.g. Customer), others not yet (e.g. Products and Payment). So this is what I ended up doing this when I instantiate a new ticket:
Cart Cart = new Cart
{
// for know properties:
Customer = currentCustomer,
TimeOfArrival = DateTime.Now,
// for properties that are going to be filled later:
Products = new List<Product>(),
Payments = new List<Payment>(),
// ...and so on
};
This solution obviously works but seems very bulky at instantiation, plus there's a lot of work done in initiator which I assume is a bad thing.
Am I doing this right or is having a lot of properties initiated at instantiation not a good practice ? If so, how should I do it ?
Thanks in advance