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:
Notice that in a good OO design, you don't have many setters or getters...
42
[OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Originally posted by Jeroen Wenting:
Or do you advocate tons of public members?
In every application there are things like DTOs.
I'd venture to say that most Objects created by the JVM in many large applications fall into this category.
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:
I don't understand what you mean by "Objects created by the JVM" - could you please elaborate?
42
Originally posted by Jeroen Wenting:
Any object instance is created by the JVM, that's all.
You write code which tells the JVM to create an object, you don't create it yourself![]()
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
42
Originally posted by Jeroen Wenting:
In that case, do you also disagree with things like JSTL and the JavaBeans standard in general which make copious use of getters and setters?
Or DTOs which basically are objects for transferring data between parts of an application?
In an ideal world an object would never need to tell you anything about itself maybe
Say I have a database of user records which I query using JDBC.
Each row is stored in an object for processing.
Now would your disagree that I will want some way to retrieve the data that's stored in that record for display or use to feed data to other objects? That's what getters and setters are for after all.
Or maybe the User record can do that verification, but if it can't get the data from the ID card record because that one has no getters it's blind as well as mute and deaf.
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
Books: Pragmatic Unit Testing in Java, Agile Java, Modern C++ Programming with TDD, Essential Java Style, Agile in a Flash. Contributor, Clean Code.
Something about .... going for a swim. With this tiny ad ...
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
|