Created
October 28, 2013 23:42
-
-
Save dtchepak/7206785 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class Thingoe { | |
public Thingoe(string id, int quantity) { ... } | |
public string Id { get; private set; } | |
public int Quantity { get; private set; } | |
} | |
public class WidgetThingoe : Thingoe { | |
public WidgetThingoe(string id, int quantity) : base(id,quantity) {} | |
} | |
public class OtherThingoe : Thingoe { | |
public OtherThingoe(string id, int quantity) : base(id,quantity) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mausch,
Closed type is fine. We'd like to be able to work with ids and quantities across all thingoes, but also restrict certain operations to specific types of thingoes.
e.g. (in haskellish)
I think I'm after structural typing?
The motivation for this is porting some existing code that uses sub-typing, and I'm trying to think of alternative representations that have the same power.