Inline function / Inline method

Examine

Identify a function or method which you would like to replace with its body in some or all of the places it’s used.

Prepare

If you plan to remove the original function or method, you should make a list of all the places it is used so you can go through and inline them one by one. If you only want to inline some usages, then you probably don’t need to.

Implement

If that doesn’t work, these are some manual steps:

Clear

Follow up

If you have inlined something in a lot of places you may have created duplication. You may want to extract a new method for some or all of it.

Prompted by Code Smells

Relevant Learning Hours

Sources

Back to All Refactorings