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

Written by
Link to Post

https://www.reddit.com/r/golang/comments/aee548/when_do_i_need_to_separate_some_codes_from_a/

Hi,

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:
reddit

Leave a Reply