Multiple Returns in a Function: Good or Bad? - #Refactoring

Why can it be bad to have multiple return points in a function? It is commonly said that "there should only be one return in a function." In this video, we will analyze the reasons behind this mantra and see why, to this day, it lacks foundation in most scenarios :)

Here is the link to the StackOverflow post mentioned in the video to delve deeper into the topic: "Where did the notion of “one return only” come from?." Thanks to Marc Cornellà for bringing this topic to light in a comment on the video about guard clauses, a video I recommend watching if you haven't seen it yet :D

Pay according to your needs

lite (only monthly)

19 €
per month
  • Access to a subset of courses to lay the foundation for maintainable, scalable, and testable code
  • Company invoice
PopularLaunch Week

standard

20,75 €
Save 171
Annual payment of 249
per month
  • Full course catalog
  • Receive job offers verified by Codely
  • Company invoice
Launch Week

premium

37,42 €
Save 139
Annual payment of 449
per month
  • All previous benefits
  • Early access to new courses
  • Discount on workshops

We won't increase the price while your subscription is active