Code Review: Name file after exposed function

shonoru profile image Andrey Bodoev Updated on ・1 min read

In code reviews which we conduct in our team, I might find some examples of code, which is can be misleading or with no clear intent. This post is about to share reasoning and hear critique on some of these examples. 

Name file after exposed function

One of the cases is having few functions in one file, related or maybe not, or can be completely not related, but somehow group in one file.

    export getSomething :: Int -> Int
    export getSomethingElse :: String -> String

Few things we can tell immediately, 

Instead, try to name files after exposed function,  and move each of them into it's own file, like so

  export getSomething :: Int -> Int

  export getSomethingElse :: String -> String

It shows intent by looking at filename. 

Few side effects which you may discover later,

  • Functions are enclosed in file to ensure there's no shared variables; which leads to proper unit tests and maintainability.

  • And after this change, there's powerful way to quickly go through project structure; by opening files which named after function and not searching through functions in search output of your text editor.


  • Name file after exposed function;
  • Breaking up into small modules for unit testing and maintainability; 
  • Browsing code within file vs. browsing code within project. 

One of the great examples in wild, https://github.com/lodash/lodash/tree/master/

Posted on by:

shonoru profile

Andrey Bodoev


Up-and-coming filmmaker. Algebraic baker


Technical writings from the MyCareersFuture product team


markdown guide