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
Popular

standard

24,92 €
Save 121
Annual payment of 299
per month
  • Full course catalog
  • Design and architecture challenges
  • Highlighted solutions videos for challenges
  • Receive job offers verified by Codely
  • Company invoice

premium

41,58 €
Save 89
Annual payment of 499
per month
  • Everything above
  • More benefits coming soon

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