DEV Community 👩‍💻👨‍💻

Andrey Bodoev for MyCareersFuture

Posted on • Updated on

Code Review: Name file after exposed function

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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,

Top comments (0)

All DEV content is created by the community!

Hey, if you're landing here for the first time, you should know that this website is a global community of folks who blog about their experiences to help folks like you out.

Sign up now if you're curious. It's free!