component

2017-01-14T06:00:30.000016Z

2017-01-14T16:14:55.000018Z

@dhruv1 So here's a long-winded answer

2017-01-14T16:15:25.000020Z

I mean @dhruv1

2017-01-14T16:15:59.000021Z

The question I always ask about any tool is: What value does it provide me in this situation?

2017-01-14T16:16:41.000022Z

For Component, the short answer is: It provides dependency injection and lifecycle management.

2017-01-14T16:18:49.000024Z

Lifecycle management is obvious, and it doesn't appear that's your primary concern. (Though I will point out that you could create a resource pool for accessing App-B, and then you would need lifecycle management. This isn't necessarily a good idea, but it's not necessarily a poor one either.)

👍 1
2017-01-14T16:20:42.000025Z

The main benefit of dependency injection is: Flexibility.

2017-01-14T16:21:31.000026Z

You can dynamically configure how an interaction will occur at runtime.

2017-01-14T16:24:49.000027Z

So back to your scenario:

2017-01-14T16:26:59.000028Z

Idea1: You've created a component that, I'm assuming, implements some protocol, and that can be swapped out with another implementation at any time.

2017-01-14T16:29:00.000029Z

Idea2: You've created an implementation-dependent interaction. My-App now must know 1) there exists a string that is a URL to App-B, and 2) that string is contained in an atom.

2017-01-14T16:31:14.000030Z

My take is: If you're going to use a dependency injection scheme, make sure you're getting the full benefit from it. As far as I can tell Idea1 provides more flexibility than Idea2.

2017-01-14T16:33:39.000031Z

That's not to say that you must use a dependency injection scheme. Some apps don't warrant that level of flexibility.

2017-01-14T16:33:58.000032Z

And I'm not sure what your use-case is.

2017-01-14T16:35:22.000033Z

But, if you don't need that level of flexibility, I would do the absolute easiest thing: (defonce url "http://...")

2017-01-14T16:37:50.000034Z

I should note that, in a professional setting, I would always opt for dependency injection. Most professional-grade applications have such a long lifespan that flexibility is key to longterm success.

2017-01-14T16:41:13.000035Z

One last observation: For Idea1, you don't seem to need lifecycle management at all as it stands. I would just construct the record with a url (map->App-B {:url "http://..."}) and then mark it as a dependency of My-App. I don't see what benefit associng/dissocing the url provides.