Re: OO Programmer trying to move to Clojure: Namespace Organization
I wouldn't get too hung up on imitation as whilst there are style guides [1] I you will find a lot of diversity in "published" Clojure code. I would suggest you internalise the style guide, lean on "lein kibit" and "lein eastwood" and then do some navel gazing and ask yourself what problem you are trying to solve. Not to get all meta, but I often find seemingly "obvious" questions can hide a whole bunch of risk and complexity. For example, some answers (as to why you are looking for this "standardisation") are: - I obsess over details whilst not actually caring about the answer - somebody just make a decision! - I care very much about this and have a strong opinion on how I should do it but I want to make sure I am not in conflict with prior art - I plan on publishing this work and want the lowest barrier to entry - I want to make this future proof and/or I have a team of people who all need to find this intuitive and so on. Each answer would leave to a slightly different direction. Alternatively, ignore completely the above (except the style guide and lein references ;)), grab a cup of coffee and just start writing some code :) [1] https://duckduckgo.com/?t=lm&q=clojure+style+guide On 11 February 2015 at 15:21, Dru Sellers wrote: > Yeah, it wouldn't surprise me if I'm over thinking it too much. But in the > model of 'shu-ha-ri' I am still very much in the shu stage so i'm looking > for concrete stuff to imitate. :) > > Thank you everyone for the ideas and thoughts, > > -d > > > On Saturday, February 7, 2015 at 10:23:43 AM UTC-6, Dru Sellers wrote: >> >> Greetings, >> >> I am trying to convert my mind from OO (C#) to one more functionally >> friendly. I am increasingly comfortable with simple applications in clojure, >> but as I start to build more complex applications, I start to fall down >> about how to structure my application. I don't want to just shove OO ideas >> into the functional nature of Clojure. I'm looking for any help someone can >> provide to help shimmy my brain into the right mental patterns. >> >> Background: Long time C# developer who leans heavily on IoC / DI / >> Interfaces / Testing / Object Encapsulation. >> >> Specific Questions: Namespace Organization >> >> Now I know this is almost entirely personal preference, but I'm playing >> with a namespace model that looks like this and I'd love some feed back. >> Tear it about, bust that red pen out and help me to better think of things >> in clojure way. I only have my C# / OO background to lean on and need some >> fresh brain juice. :) >> >> I currently organize my projects like this. a spin off of 'duct' >> https://github.com/weavejester/duct but i'm looking for a bit more detail. >> >> Context: Project name is going to be "ford", feature is going to be a >> simple log of text >> >> >> ~/ >> src/ >> ford/ - the project >> log/ - the feature name >> http.clj - contains clojure routes at 'http/routes' - orchestrate >> the business calls >> model.clj - contains my 'defrecords' / yesql / db calls >> core.clj - the "business" calls >> >> >> I def have a preference for shorter files rather than longer files >> I also tend to have a heavy use of 'ceremony' - right now I need a lot of >> structure because I'm still learning to think in terms of clojure. and I >> spend a lot of time still reading it rather than thinking about it. >> >> Again, thank you. >> >> -d > > -- > 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. -- 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.
Re: OO Programmer trying to move to Clojure: Namespace Organization
Yeah, it wouldn't surprise me if I'm over thinking it too much. But in the model of 'shu-ha-ri' I am still very much in the shu stage so i'm looking for concrete stuff to imitate. :) Thank you everyone for the ideas and thoughts, -d On Saturday, February 7, 2015 at 10:23:43 AM UTC-6, Dru Sellers wrote: > > Greetings, > > I am trying to convert my mind from OO (C#) to one more functionally > friendly. I am increasingly comfortable with simple applications in > clojure, but as I start to build more complex applications, I start to fall > down about how to structure my application. I don't want to just shove OO > ideas into the functional nature of Clojure. I'm looking for any help > someone can provide to help shimmy my brain into the right mental patterns. > > Background: Long time C# developer who leans heavily on IoC / DI / > Interfaces / Testing / Object Encapsulation. > > Specific Questions: Namespace Organization > > Now I know this is almost entirely personal preference, but I'm playing > with a namespace model that looks like this and I'd love some feed back. > Tear it about, bust that red pen out and help me to better think of things > in clojure way. I only have my C# / OO background to lean on and need some > fresh brain juice. :) > > I currently organize my projects like this. a spin off of 'duct' > https://github.com/weavejester/duct but i'm looking for a bit more detail. > > Context: Project name is going to be "ford", feature is going to be a > simple log of text > > > ~/ > src/ > ford/ - the project > log/ - the feature name > http.clj - contains clojure routes at 'http/routes' - orchestrate > the business calls > model.clj - contains my 'defrecords' / yesql / db calls > core.clj - the "business" calls > > > I def have a preference for shorter files rather than longer files > I also tend to have a heavy use of 'ceremony' - right now I need a lot of > structure because I'm still learning to think in terms of clojure. and I > spend a lot of time still reading it rather than thinking about it. > > Again, thank you. > > -d > -- 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.
Re: OO Programmer trying to move to Clojure: Namespace Organization
On Feb 8, 2015, at 6:42 PM, David James wrote: > I often group functions that operate on similar data structures together in a > namespace. This isn't always clear-cut, because some functions may "fit" in > more than one namespace. I sometimes use a (soft) convention to group > functions by the first argument. Yes, this means that my Clojure projects > resemble OO projects, at least in terms of what logic goes where. See what > works for you. At World Singles we’ve ended up with just over 40 main namespaces that correspond to the major "domain concepts" in our application, with a handful of more generic names that match external system integration points or clearly defined subsystems, and then sub-namespaces for implementation variants and general decomposition (e.g., worldsingles.payment, worldsingles.payment.braintree, worldsingles.payment.sbw, worldsingles.transparensee - search engine, worldsingles.data - our general persistence layer). Our average namespace is about 200 lines long (we have just over 100 namespaces in our main app - they range from 16 lines to 1,266). Sean Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ "Perfection is the enemy of the good." -- Gustave Flaubert, French realist novelist (1821-1880) -- 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.
Re: OO Programmer trying to move to Clojure: Namespace Organization
I often group functions that operate on similar data structures together in a namespace. This isn't always clear-cut, because some functions may "fit" in more than one namespace. I sometimes use a (soft) convention to group functions by the first argument. Yes, this means that my Clojure projects resemble OO projects, at least in terms of what logic goes where. See what works for you. Some Clojure projects I see use fairly long files. I tend to prefer smaller files myself. In my opinion, just as a function that is too long often indicates unnecessary complexity, I think files/namespaces that are too large indicates a complicated design. -- 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.
Re: OO Programmer trying to move to Clojure: Namespace Organization
When I first came to Clojure (from C# of all things), I had questions like this too. But over time I've become convinced that it was something I worried to much about. The guiding rule for code organization should be this: does it slow you down from the complexity? Are there so many files, that you're constantly context switching from one file to another? Are there so few files that you're having problems introducing new programmers to the code. I don't think there's any one size fits all solution to this. I think it's different from one project to another. I have clojure files with just 4 lines of code, and others with 3000 lines of code (that's a lot for Clojure). It's also not hard to refactor these things when needed. Especially if you don't use :refer :all in your namespace declarations. Use one of these forms: (ns my-ns (:require [foo.bar :as f] [foo.baz :refer [qux qox]])) Both of these allow for rather quick namespace conversion. If a function moves locations, it's fairly easy to just do a find/replace on the code. And the Clojure compiler will also help you, complaining about undefined vars. I hope this helps, in short, relax, it's not as big of a problem as it seems. Timothy On Sun, Feb 8, 2015 at 2:48 AM, Atamert Ölçgen wrote: > Hi Dru, > > I find it easier to organize things when I follow TDD. It's easier for me > to spot something is in the wrong place (module or maybe as a > responsibility of a function) by looking at the tests. (This is true for > any language I work with.) > > http://butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd > > > On Sat, Feb 7, 2015 at 6:23 PM, Dru Sellers wrote: > >> Greetings, >> >> I am trying to convert my mind from OO (C#) to one more functionally >> friendly. I am increasingly comfortable with simple applications in >> clojure, but as I start to build more complex applications, I start to fall >> down about how to structure my application. I don't want to just shove OO >> ideas into the functional nature of Clojure. I'm looking for any help >> someone can provide to help shimmy my brain into the right mental patterns. >> >> Background: Long time C# developer who leans heavily on IoC / DI / >> Interfaces / Testing / Object Encapsulation. >> >> Specific Questions: Namespace Organization >> >> Now I know this is almost entirely personal preference, but I'm playing >> with a namespace model that looks like this and I'd love some feed back. >> Tear it about, bust that red pen out and help me to better think of things >> in clojure way. I only have my C# / OO background to lean on and need some >> fresh brain juice. :) >> >> I currently organize my projects like this. a spin off of 'duct' >> https://github.com/weavejester/duct but i'm looking for a bit more >> detail. >> >> Context: Project name is going to be "ford", feature is going to be a >> simple log of text >> >> >> ~/ >> src/ >> ford/ - the project >> log/ - the feature name >> http.clj - contains clojure routes at 'http/routes' - orchestrate >> the business calls >> model.clj - contains my 'defrecords' / yesql / db calls >> core.clj - the "business" calls >> >> >> I def have a preference for shorter files rather than longer files >> I also tend to have a heavy use of 'ceremony' - right now I need a lot of >> structure because I'm still learning to think in terms of clojure. and I >> spend a lot of time still reading it rather than thinking about it. >> >> Again, thank you. >> >> -d >> >> -- >> 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. >> > > > > -- > Kind Regards, > Atamert Ölçgen > > -+- > --+ > +++ > > www.muhuk.com > > -- > 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
Re: OO Programmer trying to move to Clojure: Namespace Organization
Hi Dru, I find it easier to organize things when I follow TDD. It's easier for me to spot something is in the wrong place (module or maybe as a responsibility of a function) by looking at the tests. (This is true for any language I work with.) http://butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd On Sat, Feb 7, 2015 at 6:23 PM, Dru Sellers wrote: > Greetings, > > I am trying to convert my mind from OO (C#) to one more functionally > friendly. I am increasingly comfortable with simple applications in > clojure, but as I start to build more complex applications, I start to fall > down about how to structure my application. I don't want to just shove OO > ideas into the functional nature of Clojure. I'm looking for any help > someone can provide to help shimmy my brain into the right mental patterns. > > Background: Long time C# developer who leans heavily on IoC / DI / > Interfaces / Testing / Object Encapsulation. > > Specific Questions: Namespace Organization > > Now I know this is almost entirely personal preference, but I'm playing > with a namespace model that looks like this and I'd love some feed back. > Tear it about, bust that red pen out and help me to better think of things > in clojure way. I only have my C# / OO background to lean on and need some > fresh brain juice. :) > > I currently organize my projects like this. a spin off of 'duct' > https://github.com/weavejester/duct but i'm looking for a bit more detail. > > Context: Project name is going to be "ford", feature is going to be a > simple log of text > > > ~/ > src/ > ford/ - the project > log/ - the feature name > http.clj - contains clojure routes at 'http/routes' - orchestrate > the business calls > model.clj - contains my 'defrecords' / yesql / db calls > core.clj - the "business" calls > > > I def have a preference for shorter files rather than longer files > I also tend to have a heavy use of 'ceremony' - right now I need a lot of > structure because I'm still learning to think in terms of clojure. and I > spend a lot of time still reading it rather than thinking about it. > > Again, thank you. > > -d > > -- > 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. > -- Kind Regards, Atamert Ölçgen -+- --+ +++ www.muhuk.com -- 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.
OO Programmer trying to move to Clojure: Namespace Organization
Greetings, I am trying to convert my mind from OO (C#) to one more functionally friendly. I am increasingly comfortable with simple applications in clojure, but as I start to build more complex applications, I start to fall down about how to structure my application. I don't want to just shove OO ideas into the functional nature of Clojure. I'm looking for any help someone can provide to help shimmy my brain into the right mental patterns. Background: Long time C# developer who leans heavily on IoC / DI / Interfaces / Testing / Object Encapsulation. Specific Questions: Namespace Organization Now I know this is almost entirely personal preference, but I'm playing with a namespace model that looks like this and I'd love some feed back. Tear it about, bust that red pen out and help me to better think of things in clojure way. I only have my C# / OO background to lean on and need some fresh brain juice. :) I currently organize my projects like this. a spin off of 'duct' https://github.com/weavejester/duct but i'm looking for a bit more detail. Context: Project name is going to be "ford", feature is going to be a simple log of text ~/ src/ ford/ - the project log/ - the feature name http.clj - contains clojure routes at 'http/routes' - orchestrate the business calls model.clj - contains my 'defrecords' / yesql / db calls core.clj - the "business" calls I def have a preference for shorter files rather than longer files I also tend to have a heavy use of 'ceremony' - right now I need a lot of structure because I'm still learning to think in terms of clojure. and I spend a lot of time still reading it rather than thinking about it. Again, thank you. -d -- 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.