Skip to content

Latest commit

 

History

History
43 lines (39 loc) · 1.06 KB

File metadata and controls

43 lines (39 loc) · 1.06 KB

Refactoring

Change Function Declaration

Why?

You have a function which name doesn't explain what the function does.

Benefits:

Improve code readability.

What?

Replace the name of the function.

How?

Replace the name of the function everywhere is used.

Sample

For simplicity, I commented the code that is not changed.

/*class Person{
    constructor(firstName, lastName, dateOfBirth){
        this.firstName = firstName;
        this.lastName = lastName;
        this.dateOfBirth = dateOfBirth;
    }*/

    getFName(){
        return this.firstName + ' ' + this.lastName;
    }
//}

After refactoring

/*class Person{
    constructor(firstName, lastName, dateOfBirth){
        this.firstName = firstName;
        this.lastName = lastName;
        this.dateOfBirth = dateOfBirth;
    }*/ 

    getFullName(){
        return this.firstName + ' ' + this.lastName;
    }
//}

See code before refactoring
See code after refactoring