On 23 April 2010 12:21, joshua-choi <rbysam...@gmail.com> wrote:

> When it comes to naming factory functions—functions that create things—
> clojure.core gives four precedents:
>
> 1. Name it exactly what the new object is called. vector, hash-map,
> set.
> 2. Name it a shortened version of #1. vec.
> 3. Prefix #1 with "make-". make-hierarchy, make-array.
> 4. Prefix #1 with "create-". create-ns, create-struct.
>
> Are there any guidelines for naming a library's own factory functions?
>
> (I find #1 and #2 pretty annoying, since they interfere with my
> binding of symbols in let forms, but between #3 and #4 I'm not sure.)
>

I tend to prefer #1 and then either qualify the binding name or use a single
character depending on the depth of the let:
eg: If button makes a JButton
(let [ok-button (button "Are you sure this is ok?")]
  ...
  (something ok-button)
  ...)
(let [b (button "This is a small scope")
  (.add foo b))

;; just my 2cents... interested to hear what others prefer.

-- 
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

Reply via email to