Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • The only class that would be able to modify the input collection would be the PlayerParty. All NpcParty objects would be essentially immutable. Typical use-case would be to load the Foos from a repository, and would not be reassigned during runtime. If one wanted to change a value inside one of the Foos, they would have to do it in the repository. Only the Foos inside PlayerPartys can be modified during runtime, either in order, or reference. Commented Apr 22, 2016 at 7:05
  • @DocBrown "having a derived class with a stronger constraints would violate the LSP" - I'd rather say with conflicting constraints, e.g. ones that make it impossible to satisfy Party requirements and NpcParty requirements at the same time. If you satisfy a stronger constraint, you automatically satisfy the weaker one by definition and pass the LSP test successfully. Commented Apr 22, 2016 at 7:13
  • 1
    @DavidPacker your example isn't substitution to me. new NpcParty(collection) wouldn't work in the first place, regardless if you assign it to a Party or anything else. Commented Apr 22, 2016 at 7:22
  • 3
    @DavidPacker it seems to me that the premise of LSP is to have both a valid instance of type T and a valid instance of subtype S, otherwise it makes no sense trying to reason about what happens when you replace one with the other. Commented Apr 22, 2016 at 7:35
  • 1
    @Evan The provable property is not that the size can be zero, it's that it is greater than or equal to zero. The property is provable for any instances of Party or NpcParty. Commented Apr 22, 2016 at 9:23