Skip to content

bikeshed: is contract really needed? #9

@millermedeiros

Description

@millermedeiros

JavaScript is a dynamic, loosely-typed, language so type checking is really a code smell. Also by shifting the validation logic into the manager you need to update 2 files when the API changes, which doesn't seem like a good idea.

I know for sure that this kind of type checking won't make the Calendar code easier to understand and/or catch real bugs; you still need to read the implementation to understand that 'string' refers to an ID and that 'object' should actually implement a certain interface to be usable...

I would rather see the service automatically throwing an error when trying to call a method that doesn't exist (without the need of a contract). And also list the available events on the service itself (or implement something like signals that ensures you can only dispatch and listen to known event types).

IMO the manager should only know about the src and type. In most cases the manager will probably be defined on the front-end and the services will be on the back-end, sometimes even on separate repositories.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions