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

refactor!: remove not particularly useful features #418

Merged
merged 22 commits into from
Sep 12, 2024

Conversation

muktihari
Copy link
Owner

@muktihari muktihari commented Sep 12, 2024

After 1 year of using this SDK to create programs. I find that some features are not particularly useful such as (Message) WithMessages andfactory.CreateMesgOnly, we can just directly assign the value. Some of them can be omitted when certain features do not exist to begin with such as internal/kit package. I find some abstractions are a bit confusing such as Reserved and Architecture fields in proto.Message, these fields are just copied from proto.MessageDefinition during decoding and this does not add any value to my program.

These features/values were created at the time when I still didn't know the proper way to implementation of FIT protocol. Now I think these can be simplified.

This PR cleaning up those elements to help us maintain cleaner code in the future.

What's changed with breaking changes:

1. Behavior

decoder's Decode() and DecodeWithContext() are no longer required to be wrapped inside Next() loop, these methods can be invoked multiple times to decode chained FIT file directly. Method Next() is now just a convenience tool to do iteration.

2. Modified

Functions

  • proto.CreateMessageDefinition -> proto.NewMessageDefinition
  • proto.CreateMessageDefinitionTo -> (*Encoder) newMessageDefinition

Methods

  • (FileHeader) MarshalAppend -> (*FileHeader) MarshalAppend
  • (MessageDefinition) MarshalAppend -> (*MessageDefinition) MarshalAppend
  • (Message) MarshalAppend(n []byte) -> (*Message) MarshalAppend(b []byte, arch byte)

Structs or Fields

  • proto: FileHeader.ProtocolVersion type is changed from byte to proto.Version for consistency.
  • decoder: AccumulatedValue is now private with the new name value
  • decoder: Accumulator's Field: AccumulatedValues is now private with new name values

Errors

  • encoder: ErrNotAFitFile -> ErrNotFITFile

3. Removed

Package

  • internal/kit

Functions

  • factory.CreateMesgOnly

Methods

  • (*Factory) CreateMesgOnly
  • (proto.FIT) WithMessages
  • (proto.Message) WithFields
  • (proto.Message) WithDeveloperFields
  • (proto.Message) WithFieldValues
  • (proto.Message) Clone
  • (proto.Field) Clone
  • (proto.SubField) Clone
  • (proto.DeveloperField) Clone
  • (FileHeader) MarshalBinary
  • (MessageDefinition) MarshalBinary
  • (Message) MarshalBinary

Constants

  • proto: MaxBytesPerMessage and MaxBytesPerMessageDefinition are removed

@muktihari muktihari added the enhancement New feature or request label Sep 12, 2024
@muktihari muktihari self-assigned this Sep 12, 2024
@codecov-commenter
Copy link

codecov-commenter commented Sep 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (c1bf3fa) to head (1961084).

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #418   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           41        41           
  Lines         3695      3612   -83     
=========================================
- Hits          3695      3612   -83     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@muktihari muktihari added this to the v0.22.0 milestone Sep 12, 2024
@muktihari muktihari force-pushed the refactor/remove-not-particularly-useful-feature branch from e55bd82 to ad1f957 Compare September 12, 2024 07:21
@muktihari muktihari force-pushed the refactor/remove-not-particularly-useful-feature branch from ad1f957 to 1961084 Compare September 12, 2024 07:23
@muktihari muktihari merged commit 3e5a59e into master Sep 12, 2024
5 checks passed
@muktihari muktihari deleted the refactor/remove-not-particularly-useful-feature branch September 12, 2024 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants