Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Eliminates ProxyAdmin code duplication in ProxyAdminProject and AppProject using TypeScript Mixins #815

Merged
merged 1 commit into from
Apr 17, 2019

Conversation

ylv-io
Copy link
Contributor

@ylv-io ylv-io commented Apr 17, 2019

The goal of the PR is to eliminate code duplication at ProxyAdminProject and AppProject classes as well as introduce and showcase TypeScript Mixins usage in the project.

Notes on TypeScript Mixins

TypeScripts Mixins is a relatively new feature with no official or community consensus on usage or established library. It is under development and presents certain challenges. Mixins are great for development but should be used with caution. Official documentation is outdated but there is PR introducing a new approach.

Regarding ZOS I struggled with mixin abstract classes. Generally speaking it is not possible to mixin abstract classes in TypeScript at that moment. There are some workarounds but will probably cause a loss of compile type checks which defeats the entire purpose of using TypeScript. I believe in the long term we should replace abstract classes & inheritance with mixins.

Another issue is mixins constrain for constructor signature constructor(...args: any[]). That doesn't allow mixins to type their constructor parameters and forced to use a workaround in order for mixins to access their constructor arguments.

Despite all current struggles I believe using Mixins in a typed way clearly outweighs limitations of inheritance and abstract classes. As TypeScript language support for Mixins will improve over the time we should rely more on them at ZOS.

@ylv-io ylv-io added kind:research Research on a particular topic kind:refactor Refactoring of existing code preserving functionality labels Apr 17, 2019
@ylv-io ylv-io self-assigned this Apr 17, 2019
Add Mixin class and showcase Mixin usage;
@ylv-io ylv-io marked this pull request as ready for review April 17, 2019 14:03
@spalladino spalladino changed the title Eliminates ProxyAmdin code duplication in ProxyAdminProject and AppProject using TypeScript Mixins Eliminates ProxyAdmin code duplication in ProxyAdminProject and AppProject using TypeScript Mixins Apr 17, 2019
@spalladino spalladino merged commit 4e43e82 into master Apr 17, 2019
@spalladino spalladino deleted the feature/mixins branch April 17, 2019 20:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind:refactor Refactoring of existing code preserving functionality kind:research Research on a particular topic
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants