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

chore: Override arguments in all services inheriting from templates #597

Merged

Conversation

pbmiguel
Copy link

@pbmiguel pbmiguel commented Feb 8, 2020

Problem - Code Readability

  • When using MergeRequestNotes all method it's not explicit what its parameters consist. The only thing we know is that it receives two parameters -> resourceId; and resource2Id.
    (just as depicted in the image bellow)
    image

  • So here lies the problem, what really is resourceId and resource2Id, is it projectId and merge-requestId, or the other way around?

Solution Proposal

  • Override ResourceNotes methods just to rename the arguments.

@pbmiguel
Copy link
Author

pbmiguel commented Feb 8, 2020

@jdalrymple what do you think of this approach?

@jdalrymple
Copy link
Owner

There might be a way just to override the types, but im not sure.

@jdalrymple
Copy link
Owner

Something like this:

export interface MergeRequestNotes extends ResourceNotes {
  all(
    projectId: string | number,
    mergeRequestsId: string | number,
    options?: PaginatedRequestOptions,
  );
}

export class MergeRequestNotes extends ResourceNotes {
  constructor(options: BaseServiceOptions = {}) {
    super('projects', 'merge_requests', options);
  }
}

@pbmiguel pbmiguel force-pushed the chore-rewrite-mergerequestnotes branch 2 times, most recently from fa37954 to 0472b88 Compare February 8, 2020 16:06
@pbmiguel pbmiguel changed the title (WIP) chore: Override MergeRequestNotes methods (WIP) chore: Apply inteface for MergeRequestNotes class Feb 8, 2020
@pbmiguel pbmiguel changed the title (WIP) chore: Apply inteface for MergeRequestNotes class (WIP) chore: Override types in MergeRequestNotes Feb 8, 2020
@pbmiguel pbmiguel force-pushed the chore-rewrite-mergerequestnotes branch from 0472b88 to 9f7e809 Compare February 8, 2020 16:25
@pbmiguel
Copy link
Author

pbmiguel commented Feb 8, 2020

@jdalrymple changed as you've suggested to methods: all, create, edit, remove, show

So through this approach (I think):

  • It has the advantage of being more readable (as it becomes explicit what resourceId and resource2Id are about);
  • However it has the disadvantage of being less maintanable (cause it creates a dependency between the interface, and the baseClass ResourceNotes. If you change ResourceNotes, you also have to change the interface too).

Nervertheless, it seems okay to me 👍

@pbmiguel pbmiguel changed the title (WIP) chore: Override types in MergeRequestNotes chore: Override types in MergeRequestNotes Feb 8, 2020
@jdalrymple
Copy link
Owner

@jdalrymple changed as you've suggested to methods: all, create, edit, remove, show

So through this approach (I think):

* It has the advantage of being more readable (as it becomes explicit what resourceId and resource2Id are about);

* However it has the disadvantage of being less maintanable (cause it creates a dependency between the interface, and the baseClass ResourceNotes. If you change ResourceNotes, you also have to change the interface too).

Nervertheless, it seems okay to me +1

Seems like a fair trade off to me. 👍

@jdalrymple
Copy link
Owner

Im going to hold off a little bit before merging it. I feel like we might as well add the interfaces for all the services that extend templates

@pbmiguel
Copy link
Author

pbmiguel commented Feb 8, 2020

sure. I can do that. no problem

@pbmiguel pbmiguel changed the title chore: Override types in MergeRequestNotes (WIP) chore: Override types in MergeRequestNotes Feb 10, 2020
@pbmiguel pbmiguel force-pushed the chore-rewrite-mergerequestnotes branch 2 times, most recently from aff4354 to 88701b7 Compare February 10, 2020 19:06
@pbmiguel pbmiguel changed the title (WIP) chore: Override types in MergeRequestNotes chore: Override types in MergeRequestNotes Feb 10, 2020
@pbmiguel
Copy link
Author

@jdalrymple, added interfaces for the child classes of the following templates:

  • resourceawardemojis
  • projectbadges child
  • resourcecustomattributes
  • resourcediscussions
  • resourcelabels
  • resourcenotes
  • projectvariables
  • and resourcemilestones

@pbmiguel pbmiguel changed the title chore: Override types in MergeRequestNotes chore: Override arguments in all services inheriting from templates Feb 10, 2020
@pbmiguel
Copy link
Author

@jdalrymple, Is there anything I can do to help finalize this merge-request?

@jdalrymple
Copy link
Owner

With all the freetime this week lol I should be able to merge this in ASAP!

@jdalrymple jdalrymple merged commit a04a9fa into jdalrymple:master Mar 22, 2020
jdalrymple pushed a commit that referenced this pull request Mar 22, 2020
# [15.2.0](15.1.0...15.2.0) (2020-03-22)

### Features

* **core:** Override arguments in all template children ([#597](#597)) ([d9c97d4](d9c97d4))
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.

None yet

2 participants