component

2016-01-05T02:05:34.000029Z

How are people managing large component maps

2016-01-05T02:05:44.000030Z

is everyone just keeping it in one big file?

sveri 2016-01-05T13:48:42.000031Z

@drusellers: What exactly do you mean with "large component maps"?

2016-01-05T13:49:26.000032Z

@sveri: as I build out my application I’m seeing a pattern of components needing to be built - an endpoint / database calls / core logic that needs the database etc

2016-01-05T13:49:56.000033Z

if my application has 20 major features x 3-4 sub components per piece that would be 60 to 80 entries in the system map

2016-01-05T13:50:08.000034Z

then 60-80 using vectors

2016-01-05T13:50:19.000035Z

that just seems large to me

sveri 2016-01-05T13:57:15.000036Z

When I started using component I also noticed that the system map is getting larger and larger. However, I got accustomed to it and never noticed any drawbacks. So I don't really know if this is a problem or not, as long as it does not convolut my application logic, I am fine with that.

sveri 2016-01-05T13:57:42.000037Z

I mean, it's just a map with simple data, compared to other data that might flow / stay in your application it is nothing, usually

2016-01-05T13:57:49.000038Z

absolutely a fair point

2016-01-05T13:57:57.000039Z

i’m just new and have these random questions. :simple_smile:

2016-01-05T13:58:13.000040Z

i don’t want to make random assumptions.

sveri 2016-01-05T13:58:39.000041Z

Yea, like I said, starting out I had the same feeling, especially when I tried to understand the structure and see if I built them right, this is hard to do when the map is so large

2016-01-05T13:59:03.000042Z

how do you structure your map? i have like accounts (core logic), accounts-endpoint (compojure), accounts-db (database access)

sveri 2016-01-05T14:00:10.000043Z

I structure them component wise, so one component for all compojure routes for instance, one for the server, one for the database

sveri 2016-01-05T14:00:34.000044Z

But, splitting them could also be an option, if it fits you better...

2016-01-05T14:00:59.000045Z

I’d say its a legacy of how I tend to think of code from C# where I could just type scan in all of these little components

2016-01-05T14:01:27.000046Z

i can see the value in one big endpoint with the way compojure does routing

2016-01-05T14:01:54.000047Z

so if you have one database component what does that look like for you?

2016-01-05T14:02:04.000048Z

(get-entityx db args)

2016-01-05T14:02:10.000049Z

(get-entityy db args)

2016-01-05T14:02:19.000050Z

and you just have 300 of those in the db.clj?

sveri 2016-01-05T14:04:03.000051Z

this is my database component, in the case of korma it just opens a db connection: https://github.com/sveri/closp/blob/master/resources/leiningen/new/closp/clj/components/db.clj

sveri 2016-01-05T14:04:30.000053Z

the thing with korma is, it just setups a default connection which can be used everywhere, so I dont even need to pass it around, so maybe this is a bad example

sveri 2016-01-05T14:05:26.000058Z

you can see them being passed to my routes

sveri 2016-01-05T14:05:45.000059Z

not sure if this answers your question, but this is how I always use them, so I have rather large components

2016-01-05T14:06:54.000060Z

it helps, just seeing examples

2016-01-05T14:07:22.000061Z

moving from a language that doesn’t like large code files to clojure which prefers them is a mental shift

2016-01-05T14:07:34.000062Z

My current system map looks like this: https://github.com/eventgonegood/app/blob/master/src/app/server/system.clj

2016-01-05T14:07:46.000064Z

and I just see my system map growing and growing

2016-01-05T14:08:00.000065Z

but my patterns are coming from C# and i’m trying to find my way into clojure patterns

2016-01-05T14:08:01.000066Z

:simple_smile:

2016-01-05T14:09:23.000067Z

and its weird seeing functions with all of these params still. 😜 (still thinking in method land)

sveri 2016-01-05T14:09:51.000068Z

It always helped me thinking in terms of something that can be start and stopped during development. So, when I dont need to restart single routes, I can keep them all in one component. But if I have extra routes for websockets for instance, they could be put into their own component

2016-01-05T14:10:41.000069Z

yeah, i have the reloaded process working and that is super nice

sveri 2016-01-05T14:10:42.000070Z

Also you dont need to have large source files, I am not sure if there is a best practice on that already in clojure. Keeping them small surely is a good thing

2016-01-05T14:11:06.000071Z

it helps me, but then i end up with this huge :require in my system map

2016-01-05T14:11:16.000072Z

I need to find a way to better compose these things

sveri 2016-01-05T14:11:39.000073Z

I think you might try several approaches and see how they fit you

2016-01-05T14:12:28.000074Z

fair enough. :simple_smile:

2016-01-05T14:13:10.000075Z

Thank you very much for taking the time to chat through this with me. You have definitely helped me come to terms with a few things. :simple_smile:

2016-01-05T14:13:17.000076Z

and thank you for sharing your code

sveri 2016-01-05T14:14:49.000077Z

No problem, if you have more questions, just go ahead, talking about things often helps :simple_smile:

2016-01-05T14:15:08.000078Z

agreed

stuartsierra 2016-01-05T15:22:39.000079Z

Remember that systems are just records, which are maps. If you have groups of components you can merge them together.

stuartsierra 2016-01-05T15:23:52.000080Z

I like to define using dependencies in the component constructors, and only override them in the system map if necessary.