Hi Andy, 

 We use component at SMX, and do follow an approach similar to the one you 
hint at but as Stuart suggests we tend to have protocols that are more 
application-centric.
 
 For instance, we use Cassandra extensively and our general interaction 
with that is captured by the protocol:

(defprotocol Connection
  (bind [this stmt vals] "bind values to a prepared statement")
  (prepare [this query] "provide a prepared statement from a query")
  (execute [this stmt] [this stmt opts] "execute a query or statement")
  (execute-batch [this stmts] [this stmts opts] "execute a batch of 
statements")

That isn't an attempt to create an abstraction of Cassandra, it captures 
one way in which a number of our applications use Cassandra.

In certain test cases that allows us to use a stub-component which returns 
canned responses, in other cases we integrate with a test Cassandra 
cluster, both have merits.

One further advantage is this protocol would allow us to swap the 
underlying implementation (which is currently based on Alia 
- https://github.com/mpenet/alia) with something else if we ever wanted to 
without impacting consumers of that protocol. That wasn't the driver for it 
though, stubbed tests was.



On Thursday, April 30, 2015 at 1:54:38 PM UTC+10, Andy Chambers wrote:
>
> Hi All,
>
> I'm trying to follow the "component" architecture for an app I'm working 
> on and wondered if I was missing something. In the "Just enough structure" 
> talk, one of the examples Stuart presents is a DB component that contains 
> just a small selection of DB related functions (i.e. insert, and query 
> IIRC) so that when you need to mock it out for your tests, you don't have 
> to implement the entire JDBC interface.
>
> This makes sense but I'm wondering if anyone has released such a subset 
> (possibly expanded to include things like transactions, and maybe a few 
> utility query builders) as open source ideally with a corresponding mock 
> implementation. With the popularity of the component library, I'm surprised 
> not to find ready made components I can just plug into my app.
>
> If there's nothing like this already, then I guess I have an idea for a 
> new project. Anyone think this is a good idea or would everyone's ideal DB 
> component look a little different? Look forward to hearing your thoughts.
>
> Cheers,
> Andy
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to