tvkitchen / countertop

The entry point for developers who want to set up a TV Kitchen.
https://tv.kitchen
GNU Lesser General Public License v3.0
6 stars 2 forks source link

Do we need classes? #165

Closed slifty closed 2 years ago

slifty commented 2 years ago

We might be able to get away with a functional API instead of an object based API.

For instance, the new Payload class was pared down to the point that it really isn't much of a class -- it's an interface with two static methods.

I don't really think Countertop will make sense as an object without a class, but I do think Payload and `PayloadArray might so I wanted to make this issue to have a spot to consider it.

slifty commented 2 years ago

Even for Payload we do benefit from the use of a constructor: createdAt is populated automatically, which might seem like nothing but I think it does offer meaningful quality of life considering the fact that 99% of users will be creating payloads that want createdAt to be (new Date()).toISOString().

I also don't see a great way for Countertop to avoid being a full blown object with class methods.

I'm going to stick with the class based API for now. After moving everything to TypeScript maybe things will look different, but I'm doubtful.