Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Nest Moon and MoonPhase objects under TinyMoon namespace #12

Merged
merged 2 commits into from
May 31, 2024

Conversation

mannylopez
Copy link
Owner

@mannylopez mannylopez commented May 31, 2024

Closes #13

Simplifies the API by nesting the Moon and MoonPhase objects under the TinyMoon namespace.

This helps with namespace clarity, making it clearer that Moon is part of TinyMoon, TinyMoon.Moon vs just Moon. Also helps to reduce global namespace pollution.

Current behavior:

public struct Moon: Hashable {}

public enum MoonPhase: String {...}

public enum TinyMoon {
  public static func calculateMoonPhase(_ date: Date = Date()) -> Moon {
    Moon(date: date)
  }
}

let moon = TinyMoon.calculateMoonPhase(Date())
let moon2 = Moon(Date())

Expected behavior:

public enum TinyMoon {
  public static func calculateMoonPhase(_ date: Date = Date()) -> Moon {
    Moon(date: date)
  }

  public struct Moon: Hashable {}

  public enum MoonPhase: String {...}
}

let moon = TinyMoon.calculateMoonPhase(Date())
let moon2 = TinyMoon.Moon(Date())

@mannylopez mannylopez merged commit e1ea809 into main May 31, 2024
@mannylopez mannylopez deleted the move-moon-to-tinymoon-namespace branch May 31, 2024 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[API Design] Nest Moon and MoonPhase objects inside of TinyMoon namespace
1 participant