component

2016-08-23T18:35:29.000014Z

Whats the best way to have a component and make the component global?

2016-08-23T18:35:51.000015Z

right now we have our system as an argument to most of our functions but we kind of need to move away from that

2016-08-23T18:47:04.000016Z

I would say you shouldn't be passing the system to any functions

2016-08-23T18:50:19.000017Z

the component systems I have written tend to have the components as sort of top level entities, that depend on other components, and call functions passing those components the functions need as arguments

2016-08-23T18:53:11.000018Z

if you find yourself unable to write functions that don't take the whole system, you may have some layering / modularity issues. do you really have a system and a subsystem?

2
2016-08-23T18:58:44.000019Z

I have seen some people write programs assuming the whole system is being passed around everywhere, and maybe others have had some success with it. I view component as a tool for managing code bases and building things in a modular way, avoiding a big ball of functions calling functions all over the place. I think passing around the system runs counter to that because it breaks modularity, everything sees and has access to everything

1
seancorfield 2016-08-23T19:49:16.000020Z

Agree. We have a database subsystem and an environment subsystem and those operate purely in terms of a database component and an environment component respectively. Then we have an application component that has database and environment subcomponents and the application is passed in at the top-level but then only the relevant subcomponent is passed in to functions within the database subsystem or environment subsystem etc.

seancorfield 2016-08-23T19:49:55.000021Z

(we’re still migrating from a nasty global state everywhere legacy setup so our component usage is a bit piecemeal right now but slowly improving)

donaldball 2016-08-23T19:56:17.000022Z

I have a web app using system. Each of the major route groups declares the components on which it depends, which are then threaded into the handlers along with the request.

donaldball 2016-08-23T19:57:09.000023Z

A nice aspect of this is that the web app can function without a “complete” system; handlers without required dependencies automatically return 503 responses.