Re:Can you help me understand the benefit of require.js?
by williamcotton on Monday July 22, 2013 @11:26AM
(#6084287)
Circular dependencies ARE a problem with your architecture. You've got two modules that are strongly coupled. They should either be in one module or you should rethink things. It is impossible to need one without the other in that case, so including one without the other makes no sense, so just merge them.
[ Parent
| on HN ]
Re:Can you help me understand the benefit of require.js?
by anaptdemise on Monday July 22, 2013 @01:09PM
(#6085031)
> Circular dependencies ARE a problem with your architecture
This whole thread reminds me of the PHP days before namespaces. If you have circular dependencies within your own codebase, you have an architecture problem. If they are introduced by third-party libraries, maybe the usage of the library should be questioned.
Re:Can you help me understand the benefit of require.js?
by delambo on Monday July 22, 2013 @03:31PM
(#6085968)
Here's a trivial example:
I have a Modal class which depends on some utilities in a Utility class, but the Utility class depends on the Modal class because there are some utilities that show Modals.
This is not a broken architecture and is handled just fine by other programming languages/dependency handlers.
Re:Can you help me understand the benefit of require.js?
by tretiy3 on Monday July 22, 2013 @11:56PM
(#6088148)
You want to use inversion of control in your Utility class. Just pass function, which will operate on Modal class instance (not Modal class instance itself but function) as argument to its utilities that show Modals.
Re:Can you help me understand the benefit of require.js?
by williamcotton on Monday July 22, 2013 @06:25PM
(#6086871)
The concept of a "Utility Class" is normally a sign that there is something else going on!
What are the utilities contained in this module?