Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Reorganize Nostr event code to be grouped by event kind #144

Merged
merged 2 commits into from
Apr 17, 2024

Conversation

tyiu
Copy link
Contributor

@tyiu tyiu commented Apr 15, 2024

We have one massive EventCreating.swift file that contains all the Nostr event creation functions. That approach is not scalable because the file will grow without bound as we support more event kinds. Moreover, it becomes increasingly difficult to maintain that code.

Similarly, we have massive EventCreatingTests.swift and EventDecodingTests.swift test files which also grow without bound and are difficult to maintain.

I've reorganized the code so that the EventCreating protocol function(s) that create a specific Nostr event kind will be located in the same file as where the Nostr event kind class is defined. Moreover, the tests for each Nostr event kind were reorganized such that the creation and decoding is located in the same test file, specific to that Nostr event kind.

There is no change in any functionality or public function contracts. The only changes were:

  1. Where the functions are located, and
  2. Naming of some test functions to distinguish event creating tests from event decoding tests in the same test file.

@tyiu tyiu requested a review from bryanmontz April 15, 2024 03:10
Copy link
Collaborator

@bryanmontz bryanmontz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes a lot of sense and will help the SDK scale better. Thanks! And thanks for not mixing in any functional changes; that limits the scope and makes it much easier to reason about.

@bryanmontz bryanmontz merged commit b6e6eae into main Apr 17, 2024
4 checks passed
@bryanmontz bryanmontz deleted the tyiu/reorganize-by-kind branch April 17, 2024 11:22
RandyMcMillan pushed a commit to RandyMcMillan/nostr-sdk-ios that referenced this pull request Sep 1, 2024
* Move EventCreating protocol extension functions to be in the same file as their respective event kind classes

* Reorganize tests out of EventCreatingTests and EventDecodingTests into event kind specific tests
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants