开发者

To separate functions or not to separate functions? That is the

开发者 https://www.devze.com 2023-02-25 18:37 出处:网络
At this point in time I am approaching the 1800 line mark in my code. It contains a series of different forms and one big function which checks, validates, and determines the next step in the proces

At this point in time I am approaching the 1800 line mark in my code.

It contains a series of different forms and one big function which checks, validates, and determines the next step in the process. I have a total of 12 functions and I'ld like to know the开发者_Python百科 programming philosophies and thoughts on whether or not (or when?) to separate the functions into their own file and when to leave them all on the same page.

Any thoughts on both your style of programming and any links to established programming standards of a particular group or philosophy of programming?

Thanks


According to Code Complete book, a function needs to contain -one- logical unit, if it contains more than one, then break it into two functions. Another hint is if function name is too cumbersome or long. That too is a hint about a function that can be refactored.

Incidentally, Code Complete book should be on reading list of any serious software developer.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号