Hi,

I'm building a webservice, have 2 layers: webservice and database.

Webservice layer receives e.g. a product, to add to the database:

{:id 1 :name "phone" :price 100}

Database layer has a method to insert the product, insert-product.

I could do 1):

(defn insert-product [params])

or 2):

(defn insert-product [id name price])

or 3):

(defn insert-product [{:keys [id name price]})


I tend to prefer 2) because it's safer than 1) and will allow me to add 
type check later, don't think this is possible with 3). It doesn't feel 
very idiomatic though and makes me feel like I might be "thinking in 
Java"...


I also want make possible to change the keys before inserting in the 
database, where 2) and 3) are better than 1).


Is 2) the best option? Is there any reason to use 3) instead? Or is there 
maybe a different, better way?



Thanks!

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to