lukkasz323
❔ How can I reuse code without inheritance?
I'm trying to learn composition over inheritance, and so far so good, but the problem is that quickly there is a lot of complex code reuse, just take a look at both of these constructors, so much things I have to keep consistent between two classes.
In case of inheritance I would just call the base class constructor, but what are my other possibilities here? The more of them, the better. Thanks.
21 replies
❔ Are these properties the same? `{ get => x; }` vs `{ get; } = x;`
I would like to know if these have any other differences besides the syntax.
Case 1:
public int TileSize { get; } = 64;
Case 2:
public int TileSize { get => 64; }
In my code below I have other properties that use the 2nd case, but that's because of more specific reasons, for example:
I'm not sure which one would be better in the long run (if there are no other differences).
Previously I always used the 1st case, but here 2nd case seems more consistent with properties below, so this leaves a little confused as I never even thought about the 2nd case.9 replies