Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104281 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 89646 invoked from network); 7 Feb 2019 14:36:41 -0000 Received: from unknown (HELO mail-it1-f174.google.com) (209.85.166.174) by pb1.pair.com with SMTP; 7 Feb 2019 14:36:41 -0000 Received: by mail-it1-f174.google.com with SMTP id w18so13880159ite.1 for ; Thu, 07 Feb 2019 03:18:18 -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=jJicfEg4Dq0tX6DCe2RB6DF0XGpRs1E8r9pwfHdOFao=; b=qotpIhXbA3LFJVb/6EvrwNiQDcddpw70N1+mXX0XqEScMv2/NDOJ8mSAqrwOoH3DtO PID3BJbiQNxqMiAza7ongOHB9ZtSEf/Q96/UwgFMc/pFdArk+92167XYD70G5eRYYwcV hjclSmWtZXy7/jBJSAnXZi30XmM7HLvMT61Ck7eQIwOGEXHNr1Dt6mRmnU5Onl0026zB fAWxSVxFJUR8rsdMojJQU+UnJF8LkaGWSwyDgnoQgAtAHkPlBYRBnc4Em29i6tPaka8s 3xR4paQ+cmmowJysCrJ+Rurbs0lZJcBFbzJgQXJ+De2Xq90st4yY0/AIoXQGBSySY+nT ITlw== 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=jJicfEg4Dq0tX6DCe2RB6DF0XGpRs1E8r9pwfHdOFao=; b=Z7p1qnRHDQeHFFDLq4F37IfCjUUfBNPyscJgJXwdemaD7NgjCOfpByWEmmmHMMGkhd ZBbgNW01zHugVZ2LSAj5qlEf0YkAz3C1kTWhXVw7mbNooxzS81zZs36Y2PS9nH2EHe5W +JCydNq2aJFlE6zWUsrmyvYJgGQ4Phv/UJJ7Alp3ljQsN3XPG8Y5choO7EFowV8KDOms eO4M6ajvPAO7IONp5h5fafevJFUrN4frx/pCj9GO+UwM4yfpxGQ8LoRLI2Vje7BN3j0A Pl0hBTKzxQXkBKT1H3RANbqPAqNzyMzqYMAsm2A0MyIqTiQgCLeBFPaHJC+nwPbsVrsp OqVg== X-Gm-Message-State: AHQUAuYkZsqf4TyKO6c/6igUjvaTL6Z5n4cdYISRciGv53TgbCXKTgjB +t3NQKa8ZHVRC1+qRb/2xqBvGtNqYDPVIzO+BNk= X-Google-Smtp-Source: AHgI3IYSe1XktEnNXiWv3VR2nYZcISbuFLSaTM2vmZqChJWpdDMxMqX3nB21e11cEXf6oY7PmJRSTJMVXDyki9GURMY= X-Received: by 2002:a24:d441:: with SMTP id x62mr4732201itg.141.1549538298103; Thu, 07 Feb 2019 03:18:18 -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 11:18:05 +0000 Message-ID: To: Benjamin Morel Cc: Rowan Collins , PHP Internals List Content-Type: multipart/alternative; boundary="000000000000d30a8305814bffdc" Subject: Re: [PHP-DEV] Re: [RFC] [VOTE] Typed properties v2 From: ocramius@gmail.com (Marco Pivetta) --000000000000d30a8305814bffdc Content-Type: text/plain; charset="UTF-8" Hey Ben, FWIW, I also worked on a similar feature via transparent proxying (never finished though): it is an edge case that can be handled in userland, and it doesn't need to be performance sensitive ("edge case"), since the trade-off is more CPU vs less I/O and memory usage (skip loading of LOB fields, for example). This does not warrant special attention until it becomes very much a bottleneck for execution. You already have two different ways of achieving this: 1. The reflection API added by this RFC 2. `array_key_exists()` + `(array)` cast Both of the above work well and are perfectly OK to use, considering what partial loading is designed for (memory/IO usage reduction). On Thu, 7 Feb 2019, 11:08 Benjamin Morel > > > 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] > > > --000000000000d30a8305814bffdc--