File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Agile and Other Processes and the fly likes Clean Code: A Handbook of Agile Software Craftsmanship - Granularity Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » Agile and Other Processes
Bookmark "Clean Code: A Handbook of Agile Software Craftsmanship - Granularity" Watch "Clean Code: A Handbook of Agile Software Craftsmanship - Granularity" New topic
Author

Clean Code: A Handbook of Agile Software Craftsmanship - Granularity

Tomasz Prus
Ranch Hand

Joined: May 20, 2008
Posts: 73
I see that functions are covered in the book. There is something about granularity? I have often problem what is good way for example in webservices:

login(Person person)

or

login(String userName, String password, String ip)

?
Petr Shilkin
Greenhorn

Joined: Aug 05, 2008
Posts: 2
Of course, Person is much better.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Petr Shilkin:
Of course, Person is much better.


Why? I'm not sure it's that obvious - or even possible to decide without knowing more about the context.


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
Alaa Nassef
Ranch Hand

Joined: Jan 28, 2008
Posts: 460
What I assumed from Petr's comment is that he favors the second style since it uses less parameters, and all the data are contained in one object which might seem more OO. I totally agree with Ilja that the context must be known upfront to be able to make a better decision


Visit my blog: http://jnassef.blogspot.com/
Jeff Langr
author
Ranch Hand

Joined: May 14, 2003
Posts: 762
Kent Beck recently posted an article on the topic: http://www.threeriversinstitute.org/AbstractVsConcreteParameters.html


Books: Agile Java, Modern C++ Programming with TDD, Essential Java Style, Agile in a Flash. Contributor, Clean Code.
Robert Martin
Author
Ranch Hand

Joined: Jul 02, 2003
Posts: 76
Originally posted by Tomasz Prus:
I see that functions are covered in the book. There is something about granularity? I have often problem what is good way for example in webservices:

login(Person person)

or

login(String userName, String password, String ip)

?


The fewer arguments you pass into a function the better. If there are more than three, you should turn them into an object. Even three is a lot, and probably should be turned into an object.


---<br />Uncle Bob.
 
 
subject: Clean Code: A Handbook of Agile Software Craftsmanship - Granularity