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

Embedded Types to Prevent Redundant Code #5

Closed
cnguy opened this issue Dec 8, 2017 · 2 comments
Closed

Embedded Types to Prevent Redundant Code #5

cnguy opened this issue Dec 8, 2017 · 2 comments

Comments

@cnguy
Copy link
Owner

cnguy commented Dec 8, 2017

It seems I can use this feature to clean up the code a lot.

A lot of the charts have similar properties & methods (WithTitle, With..., etc) and so this can be refactored to an embedded type.

Some examples of embedded types I could make are:
AggregatableChart which provides the ShowAverages ShowSums etc
BaseAxisChart which has height name values etc

@cnguy cnguy mentioned this issue Dec 8, 2017
@cnguy
Copy link
Owner Author

cnguy commented Dec 11, 2017

Due to the fact that there are no generics, I will switch from the builder-based API to the more common functional options-based API as described here.

Using this approach, the library will still have a type-safe and concise API with sensible defaults and a thin abstraction to allow more idiomatic Go code.

edit: In this codebase, it seems the varadiac configuration pattern will be better due to naming problems.

LineChartConfig vs BarChartConfig is a lot better than
LineChartTitle, BarChartTitle, LineChart etc

This design decision is still WIP >//<

@cnguy
Copy link
Owner Author

cnguy commented Dec 12, 2017

Frappe/charts is best represented with OOP and Go doesn't seem too good at that. Every approach I can think of has redundant code and so I think just leaving this library as it is right now is fine since the lib is tiny anyways.

@cnguy cnguy closed this as completed Dec 12, 2017
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

No branches or pull requests

1 participant