3

An excerpt from Beginning Java Objects: From Concepts to Code by Jacquie Barker:

As mentioned previously, one of the arguments against declaring public attributes is that the object loses control over its data, for as we saw earlier, a public attribute’s value can be changed by client code without regard to any business rules that the object’s class may wish to impose. On the other hand, when an accessor method is used to change the value of a private attribute, value checking can be built into the “set” method to ensure that the attribute value won’t be set to an “improper” value.

I don't understand that phrase. If it simply were as we saw earlier, then, yes, that would make perfect grammatical sense. But with that for at the beginning, I'm confused.

3 Answers 3

4

For as is not a single expression here.


Given two clauses (not phrases or words) X and Y, the construct:

X, for Y

can mean "X is true/do X because of something Y does or causes."

You should not climb the trees, for the bark may be poison.

Don't run after her, for she doesn't love you.

As X in the way it is used above means in a manner similar to X or like X.

So:

one of the arguments against declaring public attributes is that the object loses control over its data, -

for -

as we saw earlier, a public attribute’s value can be changed by client code without regard to any business rules that the object’s class may wish to impose.

The "as we saw earlier" modifies "a public attribute's value can be changed by client code without regard to any business rules that the object's class may wish to impose." and is referring to an example earlier provided.

3

In the particular sentence that lead to your confusion, a simple explanation would be that for in this usage means because

As is part of the phrase as we saw earlier which should have been set off with commas.

loses control over its data, for , as we saw earlier, a public attribute’s value can be changed

is equivalent to

loses control over its data , because, as we saw earlier, a public attribute’s value can be changed

2
  • Why didn't the author simply use "because" instead of "for"? May 2, 2015 at 13:25
  • I don't know why she chose to use for instead of because. The real problem that left you confused was caused by the missing comma. Note that because and for cannot always be interchanged, and generally should not be considered as synonyms.
    – Ast Pace
    May 2, 2015 at 17:04
-1

I am sorry you don't understand the sentence. I had to read it twice and English is my native language!

"As mentioned previously, one of the arguments against declaring public attributes is that the object loses control over its data, for as we saw earlier, a public attribute’s value can be changed by client code without regard to any business rules that the object’s class may wish to impose."

  1. The sentence is too long. There are too many sentence fragments.
  2. The sentence has many wasted words.
    • Some authors think high word count is better.

Does this make more sense?

"Objects lose control over data declared with public attributes. Client code can change public attributes without referring to business rules written in the class."

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .