You are an enterprise application developer. You are manipulating a collection of customer, product, and supplier objects.
The collection objects must fulfill the following requirements:
The objects must use custom sort methods on different properties of the respective classes.
The objects must be strongly typed.
A developer from your team decides to use the following collection classes.
abstract class MyCollectionBase : System.Collections.CollectionBase { abstract public void Sort();
}
public class CustomerCollection : MyCollectionBase { //Code overriding CollectionBase methods
public override void Sort(){
//Customer sorting code
}
}
public class SupplierCollection : MyCollectionBase { //Code overriding CollectionBase methods
public override void Sort(){
//Supplier sorting code
}
}
public class ProductCollection : MyCollectionBase {
//Code overriding CollectionBase methods
public override void Sort(){
//Product sorting code
}
}
You need to review the code and recommend improvements to simplify maintenance, if necessary. What should you conclude and recommend?
A.
The code does not need to be modified.
B.
The code needs to be modified. The MyCollectionBase class must implement the ICollection interface instead of inheriting from the CollectionBase class.
C.
The code needs to be modified. Use List<T> class instead of creating custom collections.
D.
The code needs to be modified. The child collection classes must inherit from the CollectionBase class instead of the MyCollectionBase class.