1) What is the better way for resolving parameter type of a method i.e. double dispatching
(using > .NET 4.0 )?
Example with dynamic:
class Customer {
void Process(IProduct product) { ... }
}
interface IProduct {
}
class Product..A..B..etc. : IProduct {
}
//------------------------------------
var customer = new Customer();
IProduct product = new ProductA();
customer.Process((dynamic)product);
Visitor:
class Customer {
void Process(IProduct product)
}
interface IProduct {
void Accept(Customer customer)
}
class Product..A..B..etc. : IProduct {
void Accept(Customer customer) {
customer.Process(this);
}
}
//------------------------------------
var customer = new Customer();
IProduct product = new ProductA();
product.Accept(customer);
2) Let's say I have over 100.000 customers and over 1 Mil. Products. Which way is more performant?
3) Is 'dynamic' using reflection ?
Aucun commentaire:
Enregistrer un commentaire