Components and Aspects


I’d like a lesson on components and how best to use them.

Coming from Java development using Spring, I’m used to components getting lots of behavior layered onto them via AOP (audit, caching, logging, security). What’s the best way to do this kind of overlay onto components in a Clojure application?

Please vote. Comments are encouraged!

  • :thumbsup: Yes, please teach this!
  • :thumbsdown: No, I’m not interested.

0 voters


Also interested in Component vs. Mount - separate topic?



I use Component, but this year’s Clojure Remote talk from the author of mount made me thinking to look at Mount as an alternative. Seems like it make sense to use it even in clojurescript and handle stop/start events when the code is updated.


I’ve used component and we decided to give mount a try on a recent project. I prefer component. There are things that look good on a Readme and are very easy to get started with, but when a project starts growing, it becomes a headache. That is the issue we ran into with mount. Also, the reloaded workflow didn’t work for us with mount. No matter how much we tried (we even copied the code directly from the examples in mount) it wouldn’t work for us.

Component adds some constraints about how we think about structuring our application. And that is a good thing. I had a difficult time understanding it at first. One day I decided to take a break from work and just focus on learning component. Did a lot of whiteboarding and writing on scrap paper and came out with a better understanding at the other end. It didn’t take me an entire day, but it felt good to know that I had time and there was no need to rush into it.

Learning mount was quite the opposite. It was easy, and fast to get going. However, because it is so permissive, it is very easy to make some very bad design decisions, which eventually came back to bite us once our code base grew.

So, my take away is that mount is easy to learn and to get started with, but requires much more discipline to use and not make huge mistakes that can make life much harder once the code base starts to grow. Component is more difficult to learn and to get started with. It is more opinionated. But it adds constraints and structure and forces us to think (always a good thing) about design choices.

One last thing I have to say about constraints. Many times we don’t like constraints because we think it is limiting our freedoms. However, it is important we establish constraints. Jack White in an interview talks about how he set constraints on himself and how that forces him to be more creative. With the White Stripes they set some hard rules: only use 3 colors (Red, White, Black) and only use guitar, drums (and sometimes keyboards). Here is the interview where he explains how constraints are important for the creative process


good feedback - thanks!