200

Splitting 5 lines of code to 3 functions

Comments
  • 5
    what is that dev thinking of? 1. its a 5 line code
    2. if it is not a reusable code why making it functions?
    3. was he drunk?
  • 4
    @AlexDeLarge could be, but its a five line code I wonder what kind of code that can be reused unless it is something like:

    if(value == null){
    return y;
    }
  • 3
    Sounds to me like this was prob something like a setData function that then sets 3 variables in class. Which could have their own setters... Just a stab in the dark for 5 lines of code.
  • 2
    5 functions can be quite concise with arrow functions.

    Unless it is OOP
  • 1
    @thisisnikos
    over-engineering I guess...
  • 1
    A Perfect "hello world" Example!
  • 1
    Depends on the 5 lines
  • 2
    It's not about the amount of lines, but the amount of "transformations" happening in those lines.
  • 1
    @faddeefaddee Prepare python fanboys comming
  • 0
    "extract till you drop"
    - Robert C Martin
  • 2
    If it express intention with the functions, yes it's clean code
  • 1
    You can put those 3 function into 3 node packages. :)
  • 1
    Since it's 5 lines I'm assuming it's hello world in c

    include<stdio.h>

    void print_hello() {
    printf("hello");
    }

    void print_space() {
    printf(" ");
    }

    void print_world() {
    printf("world");
    }

    int main(int argc, char* argv[]) {
    print_hello();
    print_space();
    print_world();
    return 0;
    }
Add Comment