BaseList (and all other custom List implementations) refactor#171
Merged
avlo merged 7 commits intotcheeric:developfrom Jun 2, 2024
Merged
BaseList (and all other custom List implementations) refactor#171avlo merged 7 commits intotcheeric:developfrom
avlo merged 7 commits intotcheeric:developfrom
Conversation
Collaborator
Author
|
btw, upcoming encoder / decoder refactor is implemented atop changes submitted in this PR- so assuming this PR is accepted, an encoder / decoder PR will follow in step- which finalizes PR/submissions from me for the foreseeable future (unless otherwise needed/requested/etc). much thx for your time and accommodation 🙏 |
Owner
|
Understood, and thanks again. 🙏
--
Sent with Tuta; enjoy secure & ad-free emails:
https://tuta.com
2 Jun 2024, 09:44 by ***@***.***:
…
btw, upcoming > "encoder / decoder refactor" <https://github.com/avlo/nostr-java-avlo-fork/tree/encoder_decoder-refactor>> branch is implemented atop changes submitted in this PR- so assuming this PR is accepted, the encoder / decoder branch will follow in step- which finalizes PR/submissions from me for the foreseeable future (unless otherwise needed/requested/etc). much thx for your time and accommodation 🙏
—
Reply to this email directly, > view it on GitHub <#171 (comment)>> , or > unsubscribe <https://github.com/notifications/unsubscribe-auth/ABQMG7DS2PKWEF5IXKN3G4DZFLLOVAVCNFSM6AAAAABIUSZG3SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBTG42TOMJSHA>> .
You are receiving this because you are subscribed to this thread.> Message ID: > <tcheeric/nostr-java/pull/171/c2143757128> @> github> .> com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
hi, eric. per your consideration, upon careful attention to
@guilhermecomment inBaseList.java, commit2803d1111af47069d7470e6917c7d714d527f3d0:diff --git a/nostr-java-event/src/main/java/nostr/event/list/BaseList.java b/nostr-java-event/src/main/java/nostr/event/list/BaseList.javaindex f23837a..054c9d4 100644--- a/nostr-java-event/src/main/java/nostr/event/list/BaseList.java+// TODO: Why are we using this instead of just use a regular java collection?<--- @guilherme's commenti think he is absolutely correct. it appears the existence of
BaseListcustomListimplementation is exclusively used to enforce uniqueness when adding items to a list:which instead, can- and should- be achieved by using
Setrather thanList.in general, extending
List/Collectionimplementations are commonly considered an anti-pattern (turns out, commonly known as pseudo-type) for the following reasons among others:to that end, i experimented with a quick refactoring of all code requiring custom List implementations:
which have now been removed and all existing project classes (in particular, classes implementing
IElementstill do implement it) refactored as below, with all unit tests passing (and incidentally, my nostr-relay implementation, which relies heavily on these classes and their serializers/deserializers), functioning as expected:before:
EventList<GenericEvent> events;after:
List<GenericEvent> events;before:
PublicKeyList<PublicKey> authors;after:
List<PublicKey> authors;before:
KindList kinds;after:
List<Kind> kinds;before:
EventList<GenericEvent> referencedEventsafter:
List<GenericEvent> referencedEvents;before:
PublicKeyList<PublicKey> referencePubKeys;after:
List<PublicKey> referencePubKeys;anyway, just wanted to bring the consideration to your attention and provide this PR as an alternate/"correct" implementation if you think there's value to it.