design patterns – How to organize functions that need to do multiple things?


How to organize functions that need to do multiple things? For example logout function in client applications. Logout function needs to do:

  • clear cookies,
  • clear local storage,
  • clear user state,
  • clear user theme style,
  • clear user specific feature,
  • some other things…

Last logout function that I wrote has 25 lines of code.

I think that there are better patterns to solve this problem, but I don’t now which…