Notes on ‘Refactoring ‘ — 5.1 Seperate Query from Modifier

Before Refactoring

  getPersonAndIncreaseCounter(){
     counter ++;
     return person; 
  }


After Refactoring

  getPerson(){
     return person; 
  }
  
  increaseCounter{
     counter ++;
  }

Benefits

    You can call getPerson() as often as you like. You have a lot less to worry about.

Exception

   It’s OK to change personCache in getPerson() method.

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.