On Thu, 7 Feb 2019 at 11:08, Benjamin Morel <benjamin.mo...@gmail.com> wrote:
> Plus, as I stated earlier, I'm confident that typed properties will give > much more credit to this approach, as we'll get an immediate Error should > we accidentally access an uninitialized property, as opposed to a null > value previously. > I don't think that solves the fundamental problem, which is that if a partial object leaks into a wider application context, *correctly written* code will misbehave. Code that previously ran safely suddenly throwing exceptions is just as likely to cause serious bugs as code receiving unexpected nulls, so all the caveats still apply. > > I can see that it would be elegant if this function existed, but it seems >> a thin justification for adding it, when the whole problem could just be >> approached a different way - e.g.add a property to the model called >> $_partialFields that stores which fields were initialised. > > > This breaks the separation of concerns: the model should only be concerned > about business logic, and not contain any persistence-related fields. > I think you've already broken encapsulation by forcing the object to be partial in the first place. Every piece of code interacting with this object needs to know that it's given a partial, and handle it appropriately, so it feels unnecessary to pretend that this is still just a dumb data object to be persisted later. Regards, -- Rowan Collins [IMSoP]