Re: numbers on web output
Re: numbers on web output
- Subject: Re: numbers on web output
- From: Art Isbell <email@hidden>
- Date: Tue, 10 Aug 2004 19:23:52 -1000
On Aug 10, 2004, at 12:12 PM, Wes James wrote:
protected int lineCount;
When I created this variable I also told it to create the "A method
setting a value" and "A method returning a value":
public int lineCount(){
lineCount++;
A problem with the above is that you will need to initialize it and
reinitialize it after the repetition completes its work in case the
component is displayed multiple times (e.g., when a user reloads the
page which is related to this component). This is doable but why
bother when merely binding it to the repetition's "index" key will take
care of this for you. Fewer lines of custom code means less chance of
a bug and less code to maintain.
return lineCount;
}
public void setLineCount(int newLineCount){
lineCount = newLineCount;
}
Art what is the difference between a public instance var and accessor
methods in this case.
public instance variables violate encapsulation which is an
object-oriented design feature that I feel should not be ignored,
especially when doing as you have done is easy using WO Builder. If an
instance variable is public, it can be directly accessed and set from
outside its object rather than using an accessor method that can
implement logic that might be necessary for proper access. Such logic
cannot be applied when instance variables are accessed directly.
Is the variable lineCount as a protected
variable with the methods above what you are talking about?
Yes.
Aloha,
Art
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.