Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104280 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 86061 invoked from network); 7 Feb 2019 14:27:00 -0000 Received: from unknown (HELO mail-yb1-f175.google.com) (209.85.219.175) by pb1.pair.com with SMTP; 7 Feb 2019 14:27:00 -0000 Received: by mail-yb1-f175.google.com with SMTP id k9so3807236ybg.1 for ; Thu, 07 Feb 2019 03:08:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=VFtmGO1I/ZTTltVh+fm7Cx9zLh5CNmBTd7ANQNKE3WE=; b=Wu3cvlhVbb1jYsB5Z8QdWTlO07KbiQX+CYb2IdljRmYvrLkID0uyJzNTqxndT8/zXb lel8BBdBseW2MS4k0q9L18E+YVp/zA0nzQMJFm3McsVD0xstNePuAH67HQs6TZsD/N4w Bazj5dV3Fu8x0Pq0wvRorzaOYwVy7amydIZgwQJwnUhWLOfyOrp2elZJn7tjGaSRJ5Bv wabu9atTTl032Ym/7qiwj4BKN4EyPetcVR2vfYDa0i4tFm83Tsb8qTWJtVGVkIIPqzru frMiMyYYXKPmdnYnuYXno8po6sj5P9497RyWgmhWH0pPaldpzAg6vE00DhVGCIn1JSFo NjsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VFtmGO1I/ZTTltVh+fm7Cx9zLh5CNmBTd7ANQNKE3WE=; b=adX7dqETLzYhBjYBfcUo6R+Cr+kIi8tv/HySYA/awowsyP+tEiAesJdNekRrIzPZS0 8ek9ai79vUfL9WQQ8BraD0flwwKo1pWCusFDK+NFYrtZ0xHxmd/cbsDyqnNCptODyaCm oRkl2Nw62KfeQKQQMHnOD8p/owlFRPqkWh93Znq7eQgGE/18wZZcRa21tEZdJGUMAwrN ZLYJZSIW46ih3qO/+yxQKRFKp0GkObWX1QfdqS9XwYl8pNXSb1k36Qn4XmCWW5WcyYLj 9QXjJsErusmxKqGGPbVJ7nRoUJXijtkejpCPXU/fQdcoOhx6HsLaiv7ff0d2JVf+xuDb ko4w== X-Gm-Message-State: AHQUAuY6qDJOqw5gfJpRp4N+MlnhYxB6G/cdn3ZliZr431lFyrllum7E Bc7x8qEcinRLs/pGP2epEnk1ytAQHpxQ01oF6+0= X-Google-Smtp-Source: AHgI3Ib+7ZGxMcwuEi7JjsIhnHCHmzAe89kbz/T+ik3Ipgyg4MV6WNCJnGjY1M9Zr2JyU5DJ8FAf0eTH2RjHR8imsxY= X-Received: by 2002:a25:a181:: with SMTP id a1mr5552471ybi.260.1549537717439; Thu, 07 Feb 2019 03:08:37 -0800 (PST) MIME-Version: 1.0 References: <595b374c-bc4f-9b8a-0013-6485abbfb477@php.net> <41D0A782-E4E2-4B98-9C5D-174143DE9A76@gmail.com> In-Reply-To: Date: Thu, 7 Feb 2019 12:08:25 +0100 Message-ID: To: Rowan Collins Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000036d12305814bddd5" Subject: Re: [PHP-DEV] Re: [RFC] [VOTE] Typed properties v2 From: benjamin.morel@gmail.com (Benjamin Morel) --00000000000036d12305814bddd5 Content-Type: text/plain; charset="UTF-8" > > So this entire feature request is to support something which the Doctrine > manual spends several paragraphs saying you should probably never use? If Doctrine authors thought that you should *never *use it, they would never have added the feature in the first place. They just place a big caveat on top of it, that it's for specific optimizations, and that it may break your code; it's obvious that you should always start with full objects and optimize later, but these kind of optimizations can make a huge difference in a high traffic app, performing many small updates. Adding this small function may contribute to writing a very fast data mapper, that could allow us to use objects where we would have typically reverted to plain PDO for maximum throughput in specific cases, which makes a huge difference in code quality and maintainability if you ask me. 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 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. You could argue that this property could be created dynamically on the object by the data mapper, but then the mapper would have no way to determine if another property, that was not part of the loaded properties, has been initialized between the load() and save() calls. So back to square one, we need to be able to quickly determine which properties are initialized at any given time. Ben On Thu, 7 Feb 2019 at 11:42, Rowan Collins wrote: > On Thu, 7 Feb 2019 at 09:35, Benjamin Morel > wrote: > >> apologies if I've missed it, but have you actually said what that >>> use case is? >> >> >> Sorry if it wasn't clear in my original post. The use case is the >> following: >> >> - a data mapper retrieves an object from the database >> - for optimization purposes, we can ask the data mapper to return a >> partial object, with only a handful of properties initialized >> - when saving the (potentially partial) entity to the database, the data >> mapper needs to read initialized properties only >> > > > So this entire feature request is to support something which the Doctrine > manual spends several paragraphs saying you should probably never use? > > 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. > > Regards, > -- > Rowan Collins > [IMSoP] > --00000000000036d12305814bddd5--