mirror of
https://github.com/nspcc-dev/neofs-sdk-go.git
synced 2026-03-01 04:29:18 +00:00
Provide constructors for type instances #192
Labels
No labels
I2
I3
I4
S1
S2
S3
S4
U0
U1
U2
U2
U2
U3
U4
blocked
bug
client
config
discussion
documentation
enhancement
epic
feature
go
good first issue
help wanted
performance
pool
question
security
task
test
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
nspcc-dev/neofs-sdk-go#192
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @cthulhu-rider on GitHub (Aug 3, 2023).
there are several reasons, one of them https://github.com/nspcc-dev/neofs-sdk-go/pull/479#discussion_r1279235656
currently, we almost always initialize type instances via methods:
one of the obvious disadvantages of this approach is the need to explain in the docs (and hope that a beginner will read it) mandatory methods, without which the instance remains invalid
one of the obvious advantages is readability:
it's proposed to provide constructors - functions with required parameters. For example, for signatures:
with this
Calculate/ReadFromV2methods won't be needed (their use will remain in the reuse of the instance, but in practice this is rarely necessary)as we can see, we still need to write docs like
must be signedand hope user will follow them. We can try to go further and make constructors finalizers, but that would require subtypes:or with different naming
@cthulhu-rider commented on GitHub (Sep 12, 2023):
we may also provide decoding constructors
and for some types
could replace 2 instructions with 1 when there is no instance yet