When do I need to separate some codes from a function to another function?

Written by
Link to Post



I’m exploring several open source projects. One thing I notice is that they separate many parts of the code into different functions as like below:

func myFunc() { getUserId() //some code specific to myFunc() generateSlug(data) //some code specific to myFunc() savePost(post) }

As you can see, instead of writing all the codes in a single function, he separates them into other functions.

My question is when should I consider moving code to different functions? What are the standards?

submitted by /u/CrappyFap69
[link] [comments]

Article Tags:
· ·
Article Categories:

Leave a Reply