Click here to Skip to main content
15,906,574 members

Comments by Nick4978 (Top 4 by date)

Nick4978 27-Sep-17 20:42pm View    
Okay. So that being the case then, if I didn't make the abstract class Deal with the <T> type, then I would have to get rid of the abstract methods that returned the specific Deal subclass and move them to the subclass?

i.e. -
public abstract class Deal {       
    ...properties...         
    public abstract T Add();            
    public abstract T Add(string id);            
    public abstract T Update();            
    public abstract T Update(string id);            
    public abstract T Get(string id);            
    public abstract List<T> Find();            
    public abstract bool Delete();            
    public abstract bool Delete(string id);
}
Nick4978 27-Sep-17 12:34pm View    
Maybe I'm misunderstanding then. But in your example, you have class Car which inherits from Deal. Those two are completely different. A "Car" is a unit of "Inventory" whereas a "Deal" is a base class of a Finance, Lease, Cash, Wholesale, etc. type of transaction (deal) where the unit of inventory is only a property of it.

For example, I lease a car to John. The car is a 2014 Ford Mustang which I lease to John for $15,000.

Now I have a "lease" deal which has an lease amount (sales tax, fees, etc.) as part of the Deal, but the deal also contains a customer (which has name, address, phone, etc.) and the deal also has the car that I leased him (which has a year, make model, color, etc.)

So a Car would never inherit anything from Deal. The Deal would have to have a reference to the car that was sold. (As well as the customer it was sold to.)

The problem I have is that it might be a car, or it might be a truck, an RV, a boat, etc. And the deal itself might be a cash deal, lease deal, finance, wholesale, etc.

Am I making sense with this example? Or am I still misunderstanding what exactly you're saying?

Thanks!
Nick4978 27-Sep-17 8:22am View    
But neither Deal nor Inventory should ever be created on their own because by themselves, they are nothing. They only have some base properties that are used in the real classes. For example, all Inventory objects have a Uid and some sort of serial number and all Deals have a sold unit and a customer. Even if I removed abstract, I still have the same problem with any deal type having a property of any inventory. It would be too messy to make something like:

public class Deal<T>
{
    public Car SoldCar {get; set; }
    public Truck SoldTruck {get; set; }
    public RV SoldRV {get; set; }
    public Boat SoldBoat {get; set; }
}

etc..
Nick4978 27-Sep-17 7:44am View    
In a nutshell, this is the part I'm trying to make work:

    
    public abstract class Deal<T>
    {
        public Inventory<AnyVehicleType> Vehicle { get; set; }
        public Inventory<AnyVehicleType> SoldUnit { get; set; }
    }


AnyVehicleType is just psuedo-code here but would be a property of type Inventory (car, truck, boat, etc.) inside of the Deal class which could be things like finance, lease, wholesale, etc.