filmov
tv
Java Clean Code Tutorial #8 - How long should a method be??

Показать описание
A very common question when writing software is, how long should a method be? My initial response to this question is the single responsibility principle, a method should do one thing and do one thing very well.
That being said, I feel effort and care should be taken to try and keep methods to around 20 lines maximum. This is just my opinion and not a stone rule!
Where did i get this magic number?
I found this was a sweet spot from my own personal experience and while working with many programmers at all levels. In general, we felt that methods that had over 20 lines of code had the potential to be broken down and certain logic extracted into other methods with cool descriptive names. Effectively making the code more like poetry.
Whats your opinion? Please share in the comments for other developers searching for this question!
Software is written once and read hundreds of times. So let’s make our fellow developers life easier.
Why clean code?
Simple. Clean code allows us to confidently make changes and deliver more features quickly to our customers.
Don’t forget to subscribe for your regular dose of Java Tutorials!
STOP THE ROT.
Till episode 9!
Philip
That being said, I feel effort and care should be taken to try and keep methods to around 20 lines maximum. This is just my opinion and not a stone rule!
Where did i get this magic number?
I found this was a sweet spot from my own personal experience and while working with many programmers at all levels. In general, we felt that methods that had over 20 lines of code had the potential to be broken down and certain logic extracted into other methods with cool descriptive names. Effectively making the code more like poetry.
Whats your opinion? Please share in the comments for other developers searching for this question!
Software is written once and read hundreds of times. So let’s make our fellow developers life easier.
Why clean code?
Simple. Clean code allows us to confidently make changes and deliver more features quickly to our customers.
Don’t forget to subscribe for your regular dose of Java Tutorials!
STOP THE ROT.
Till episode 9!
Philip
Комментарии