Visit my blog: http://jnassef.blogspot.com/
maximum of 15 lines of code per method.
Visit my blog: http://jnassef.blogspot.com/
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by arulk pillai:
Having the API handy and using third party utility packages like Apache Commons, etc can help you replace a number of lines of code with just one line. For example StringUtils.isEmpty(...) that will check for both null and empty string.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Ilja Preuss:
In my opinion, the typical method should be much smaller than 15 lines. I like one to five lines. Of course there are some that simply are bigger, not because they are complex, but because they have a big, simple switch statement or something similar.
Books: Pragmatic Unit Testing in Java, Agile Java, Modern C++ Programming with TDD, Essential Java Style, Agile in a Flash. Contributor, Clean Code.
Originally posted by Ganesh Bhambure:
For clean code we have to write small methods.
Please any body tells how many max Loc for a method is consider as sign of good coding ?Any idea or pointer regarding this.
Hope !!I am not asking foolish one
---<br />Uncle Bob.
Originally posted by Ganesh Bhambure:
Since each methods having its own significance so group related statement must be in same method so it is not acceptable to restrict method to 5-15 lines, for every cast.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
When I see methods that are fifteen lines or longer, the lines are almost invariably already clustered into groups - either by indentation, or by empty lines between them, perhaps even line comments.
See Keith Braithwaite's remarkable study on this:
http://peripateticaxiom.blogspot.com/2006/05/complexity-and-test-first-0.html
Personally I like my functions to be 4 or 5 lines.
Originally posted by Kuldeep Yadav:
But that lead to thousands methods in single class.
Also calling number of method will completly destroy abstraction of you code. isn't it ?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Kuldeep Yadav:
But that lead to thousands methods in single class.
Books: Pragmatic Unit Testing in Java, Agile Java, Modern C++ Programming with TDD, Essential Java Style, Agile in a Flash. Contributor, Clean Code.
Originally posted by Robert Martin:
The vast majority of functions should be very small, but a very few will be >20 lines of code.
Visit my blog: http://jnassef.blogspot.com/
Originally posted by Kuldeep Yadav:
Hi Robert,
But that lead to thousands methods in single class.
Is it then clean code ? Also calling number of method will completly destroy
abstraction of you code. isn't it ?
---<br />Uncle Bob.
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|