nifi-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Hunyadi (Jira)" <j...@apache.org>
Subject [jira] [Updated] (MINIFICPP-1264) Add getter interface helper
Date Thu, 18 Jun 2020 09:18:00 GMT

     [ https://issues.apache.org/jira/browse/MINIFICPP-1264?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Adam Hunyadi updated MINIFICPP-1264:
------------------------------------
    Summary: Add getter interface helper  (was: Add getter-setter interface helper)

> Add getter interface helper
> ---------------------------
>
>                 Key: MINIFICPP-1264
>                 URL: https://issues.apache.org/jira/browse/MINIFICPP-1264
>             Project: Apache NiFi MiNiFi C++
>          Issue Type: Improvement
>    Affects Versions: 0.7.0
>            Reporter: Adam Hunyadi
>            Assignee: Adam Hunyadi
>            Priority: Minor
>             Fix For: 0.8.0
>
>
> *Background:*
> In our codebase we have quite a lot of getter functions that follow this signature:
> {code:c++|title=Current Interface}
> void getMemberField(Type& argToModify);
> bool getNullableMemberField(OtherType& argToModify);
> {code}
> Most developers would much rather use an interface that looks like this though:
> {code:c++|title=Proposed Interface}
> Type& getMemberField();
> const Type& getMemberField();
> optional<OtherType> getNullableMemberField();
> {code}
> The problem with the former version is that in some cases it makes the code unnecessary
verbose. An example from our codebase:
> {code:c++|title=Example}
>  # Version 1
>  utils::Identifier sourceUuid;
>  source->getUUID(sourceUuid);
>  connection->setSourceUUID(sourceUuid);
>  # Version 2
>  connection->setSourceUUID(source->getUUID(sourceUuid));
> {code}
> Unfortunately more ofthen than not this is the exact pattern the getters appear in.
> *Proposal:*
>  A godbolt implementation for a convenience function is available here:
> [[Proof of Concept]|https://godbolt.org/#z:OYLghAFBqd5QCxAYwPYBMCmBRdBLAF1QCcAaPECAM1QDsCBlZAQwBtMQBGAFlICsupVs1qhkAUgBMAISnTSAZ0ztkBPHUqZa6AMKpWAVwC2tQVvQAZPLUwA5YwCNMxENwBspAA6oFhdbT1DE0FvXzU6Kxt7IycXd0VlTFV/BgJ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5MY3DpBwLAMCICgqAFng7BkBQEBoOrmsoMIoicMsJukFQGvhsQX0QA4iOk6QDjWOkjx26jusAQQbK0KwLty6QWC7aI7AU6j%2BA6ckyJfX7mAAB5JHc/Si0qyiu0IeAOLSxDchgidk3MRiux0ND0EwbAcDw/CCIbYh4zIacOF9sCkSAfasKQyIuA84ZU2LkL%2BFHAC0H6uRIMhyJwArjAPbKDJLiTJBoEDmHUOSkOYzTlC4uShH4dAryEPi77QG8xBUDTzwURS1Po2SCEo%2BQpDUJTWGUp9b4oT/7w0T8n60nAdAoQmvQuDw0RijNGIcxaIxjszAebhuDjFjE%2BY2HZlioPGBAXAhASCTBJrWPQetnC4MGP/JstdpBkxDj3GmSNpYIz6ELUgBd4GoMZnaJGSMBQCmNsseBAoIF%2B3FpLEA0tZaUwVsrCASAugEE8HccglBdaeA1mfNe%2BBUSCGLowFgwdGakAAO60k8IXAWyNhaQPFkMTg4x9GEAQOMGBbg4EIKQXqFBaDRZiLhh0BABwsAuGcqYxhBdBhIw7GzTgjMBTcG4JIbmbM2ahN4CLLGiNhGiKodTEAHCOwCiRpwQY7hlhIzZtwtwuR6GzwEaLIRMtMmmMkOYwRaS6lyx7h3XwGhuBAA%3D%3D%3D]
> We can introduce this and simplify later usages of getters.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Mime
View raw message