kalekundert / byoc

MIT License
0 stars 0 forks source link

Switch to functional/stateless architecture #49

Open kalekundert opened 1 year ago

kalekundert commented 1 year ago

Currently, BYOC is tightly coupled to the app object. This has some downsides:

I believe that moving to a functional/stateless architecture would address both of these points, and make the code more extensible in general. By "functional/stateless architecture", I mean roughly that there would be a load(params, configs) function that would return a dict/object with all the specified information.

However, it's not clear how all of the useful features of BYOC would be reimplemented in such a system. The purpose of this thread is to enumerate and discuss such features.

kalekundert commented 1 year ago

DocoptConfig: Using parameters when loading configs

kalekundert commented 1 year ago

UpstreamConfig: Reusing configs from other apps


kalekundert commented 1 year ago

Part: Deriving multiple parameters from a single config value

kalekundert commented 1 year ago

Never overwrite manually specified values

kalekundert commented 1 year ago

Config initialization

kalekundert commented 1 year ago

Class-based interface

kalekundert commented 1 year ago

Method getter

kalekundert commented 1 year ago

Having thought about this for a while, I don't think I can transition stepwise to a stateless architecture:

However, the stateless architecture makes much more sense for a general-purpose library: it's simpler, more efficient, and more extensible. Without a stateless architecture, I couldn't see myself recommending this library to other people, nor could I see myself using it for anything other than stepwise. So I think a stateless architecture is essential.

Putting this all together, I think I need to support both architectures. More specifically, I need to implement a stateful architecture using the stateless architecture. This would actually be a good way to demonstrate the extensibility of the stateless architecture.

Some implementation details I have in mind:

Pseudocode for load():

Pseudocode for stateful parameter access: