Giter Club home page Giter Club logo

Comments (3)

skyerus avatar skyerus commented on August 16, 2024 3

I like this approach a lot, I think this resolves any of the concerns with the alternatives I had found. Thanks @james-milligan , I’ll proceed with this method

from go-sdk.

james-milligan avatar james-milligan commented on August 16, 2024 2

we could create an UnimplementedHook struct to be placed within any new hooks, this unimplemented hook would contain all the required, but empty, methods to satisfy the interface. A developer would then 'replace' the unimplemented methods with their own:

https://go.dev/play/p/XXcPF3ffLMS

this pattern is seen in grpc generated code and I believe will help with the reduction in breaking changes if, for example, a new method is added. Any implemented methods should still break the interface if they change

from go-sdk.

skyerus avatar skyerus commented on August 16, 2024

If we go ahead with this we lose any type assurances at compile time. A developer can no longer be confident that their hook will get called as anything will be accepted as a hook (and subsequently not called if it doesn't match one of the before/after/error/finally funcs).
If, for example, the hook interface gets changed down the line in a breaking change, any developers who update the sdk would know immediately that they needed to update their hooks. If, however, we've made this change they wouldn't see any compile time errors and their hooks would cease to work silently.

I'm now of mind that keeping the interface as it is provides more benefits (at the cost of forcing developers to have empty functions). Thoughts? @james-milligan @beeme1mr @toddbaert

from go-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.