A common pattern I've been using for JS/NodeJS applications is the following:

import { utility1, utility2 }

function exampleScript() {
// Does something

Basically my main application function would rely on smaller helper functions that I could separate and modularize. But I'm not sure what style you would consider this as (e.g. procedural)? I've been told that I should follow Object Orientated design patterns. Is this considered bad practice?

  • 6
    "Bad practices" are those which produce an undesirable result. Does this practice produce an undesirable result? Commented Sep 20, 2018 at 16:08

2 Answers 2


Not necessarily. Decomposing program functionality into smaller, reusable parts with limited responsibilities is good. My concern here would be whether utility1 and utility2 are clear on what they are doing (if it's too hard to name them, then they probably aren't). As a concrete example, think of setUpPlayfield and setUpScoringSystem: what there two do seems clear enough.

I would personally prefer that they explicitly returned something and/or got some explicit input. As they are here, you are relying on whatever their side effects are and, if it's not clear (or it changes at a later point) you will want to reconsider your choices.


In JavaScript terms, this like the following C# code:

using Utility1;
using Utility2;

public class ExampleClass
    public void Foo()
        // Use a class in Utility1
        // Use a class in Utility2

Yes, your code is in JavaScript, and this is in C#, but the principal is the same. Import code from another library and use it.

This is pretty standard across languages and tech stacks.

Not the answer you're looking for? Browse other questions tagged or ask your own question.