Skip to content

refactor: codehealth rename types to reflect axis of transformation#1451

Merged
jzacsh merged 2 commits into
dtinit:masterfrom
jzacsh:refactor-fix-confusing-types
Apr 9, 2025
Merged

refactor: codehealth rename types to reflect axis of transformation#1451
jzacsh merged 2 commits into
dtinit:masterfrom
jzacsh:refactor-fix-confusing-types

Conversation

@jzacsh

@jzacsh jzacsh commented Apr 7, 2025

Copy link
Copy Markdown
Collaborator

this is entirely a change for code clarity, because if you read (before this patch) the AnyToAnyImporter#import generic-params you'll see To being passed in as the source of data (what should be a conceptual "From").

The cause of that confusion is that there's multiple different orthogonal transformations happening with/around the TransferCompatibilityProvider and its supporting AnyToAnyImporter class and DTP generally:

  1. DTP moves data from a Exporter producing models to an Importer consuming models
  2. we have static functions that convert model A to model B (eg: from Photos model to a Media model via MediaContainerResource::photoToMedia)
  3. TransferCompatibilityProvider converts an importer (via AnyToAnyImporter and a model-transformer like above) from an importer of one model type to an importer of another model type.

I'm now using the language of "stand-in importer" to indicate which importer was selected as the input (think the g in f(g(x)) to indicate the key moving piece in that last kind of transformation listed above.

this entirely a change for code clarity, because if you read (before
this patch) the `AnyToAnyImporter#import` generic-params you'll see
`To` being passed in as the source of data (what should be a conceptual
"From").

The cause of that confusion is that there's multiple different
orthogonal transformations happening with/around the
`TransferCompatibilityProvider` and its supporting `AnyToAnyImporter`
class and DTP generally:

1. DTP moves data from a Exporter producing models to an Importer
   consuming models
1. we have static functions that convert model A to model B (eg: from
   Photos model to a Media model via
   [`MediaContainerResource::photoToMedia`][pToMedia])
   - this is parallel to the `From` and `To` generic params of
     [`java.util.function.Function<From, To>`][Function].
1. `TransferCompatibilityProvider` converts *an importer* (via
   `AnyToAnyImporter` and a model-transformer like above) from an
   importer of one model type to an importer of another model type.

I'm now using the language of "stand-in importer" to indicate which
importer was selected as the input (think the `g` in `f(g(x)`) to
indicate the key moving piece in that last kind of transformation listed
above.

[Function]: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/function/Function.html
[pToMedia]: https://github.com/dtinit/data-transfer-project/blob/bca0c7926fb871c7fdd7e206908a87874ec624f2/portability-types-common/src/main/java/org/datatransferproject/types/common/models/media/MediaContainerResource.java#L45
@jzacsh jzacsh force-pushed the refactor-fix-confusing-types branch from 45d122b to cac8470 Compare April 7, 2025 21:51
@jzacsh jzacsh requested a review from calumcalder April 8, 2025 16:08
@jzacsh jzacsh marked this pull request as ready for review April 8, 2025 16:08
@jzacsh jzacsh changed the title noop(codehealth) rename types to reflect axis of transformation refactor: codehealth rename types to reflect axis of transformation Apr 8, 2025
@jzacsh jzacsh merged commit 4e30916 into dtinit:master Apr 9, 2025
@jzacsh jzacsh deleted the refactor-fix-confusing-types branch April 9, 2025 15:15
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.

2 participants