I've recently started working with Elixir and am working hard to write my code "the elixir way." In doing this, I've written some code which is obviously bad and unreadable.

I would like to post a question showing several snippets of code that explains what I've done, why I wrote it the way I did, and ask for suggestions on better ways to write the same functionality that is more idiomatically "good" Elixir code.

I do realize that this may be slightly prone to personal opinions. I also think that the established norms for Elixir code combined with how much my code looks like spaghetti will mostly negate any the potential problems with opinion driven answers.

Would posting my question on the main site be appropriate? Have I misunderstood the basis of the site?

  • 5
    \$\begingroup\$ Posting a complete, working program is preferred over posting snippets. \$\endgroup\$
    – Mast Mod
    Jun 8, 2016 at 9:55
  • 1
    \$\begingroup\$ The term "refactoring" gets thrown around a lot, when in most cases the intention is just to seek improvements. Unless you have a specific refactoring operation in mind, I suggest that you just post your code for open-ended review. \$\endgroup\$ Jun 8, 2016 at 16:43
  • \$\begingroup\$ If anyone is curious, here is the question I ended up posting: codereview.stackexchange.com/questions/131502/… \$\endgroup\$ Jun 9, 2016 at 5:22

1 Answer 1


Assuming your code works as intended, just show us what you've got, walk reviewers through your code - include as much context as possible (well, try to keep the post digestible, put yourself in the reviewers' shoes!).

Also keep in mind:

Posting a complete, working program is preferred over posting snippets.

It's harder for reviewers to "put the pieces together" and get the "big picture" if the code is scattered across a number of small snippets. If possible, make it one code block. If that's really a lot of scrolling and there's a logical place to split it (e.g. a class), then make it multiple code blocks; at the end of the day it's about making your post interesting and easy to read, with enough explanation to know what problem you're solving without having to read the code, and enough code for reviewers to chew on.

Include what your concerns are - looks like spaghetti is very much a valid concern!

You don't need to explicitly ask for help refactoring your code: if refactoring is in order, reviewers will suggest it naturally - after all, making code slightly less wrong is about refactoring, too.

I don't think you misunderstand the site. Just make a well-formatted question, you'll do great!

Some helpful meta posts (browse around, there's a lot more!):


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .