Mike,

I write incredibly good code!     :-)

That's one of the best improvements to my incredibly good code that I've ever seen anyone make. What a great idea.

Interesting that I've been doing something similar in log4j Logger instantiations for a long while, but it never occurred to me to do it here, i.e.:

private static org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger.getLogger(MyComponent.class.getName());



Regarding Chuck's comment about KVC, Ravi Mendis's book recommends KVC in such situations, so I didn't think anyone would call me on it.

Like Chuck, I tend to use straight assignment for many of the same reasons. However, in this example I just didn't want to make arbitrary decisions on whether the members whose values I was setting were iVars or methods.

Immediately after I sent the message, I had second thoughts about including KVC coding for someone who's already admitted that they're very new to WO. By then it was too late. Now I'm pleased that I did because, since Chuck has called me on it, the whole (incredibly valuable) KVC concept will be brought to Zac's attention.

Listen up there, Zac.  :-)

Regards,
Jerry

On Feb 9, 2006, at 4:45 PM, Mike Schrag wrote:

For what it's worth, I do:

public WOActionResults someActionMethod() {
MyNewPage nextPage = (MyNewPage)pageWithName (MyNewPage.class.getName());
        nextPage.setSomeKeyName(value);
        nextPage.setSomeOtherKeyName(otherValue);
        return nextPage;
}

the class.getName() allows Eclipse to do proper refactoring and you can right click=>References=>Workspace your class and truly find all the refs vs just havign a string ref ... Minor change but really nice benefits.

ms

On Feb 9, 2006, at 4:40 PM, Chuck Hill wrote:

I usually do it the way that Jerry posted:

     public WOComponent someActionMethod()     {
          MyNewPage nextPage =  pageWithName("MyNewPage");     // 1
nextPage.takeValueForKey(aValue, "someKeyName"); // 3
          nextPage.takeValueForKey(aValue, "someOtherKeyName"); // 4
          return nextPage;         // 5
     }

'cept I usually avoid KVC unless I need it for dynamic reasons. I prefer the way that straight Java reads and the compiler checks don't hurt either.


Chuck


On Feb 9, 2006, at 11:46 AM, zac wrote:

What's your preffered method of initializing components?

Chuck Hill wrote:

WOComponent, right? The constructor that you should call is the one taking a WOContext as its sole parameter. This is the one called when pageWithName() is used. I'm not sure if there are any potential bad side effects of constructing a top level page manually as opposed to using pageWithName. You might be better off adding a static method to use as a constructor. That can call pageWithName and then set the parameters.

Chuck


On Feb 9, 2006, at 11:20 AM, zac wrote:

I'm an old java hack who is picking up webobjects. When I try to overload a component's default constructor I get build warnings about overloading a deprecated api. I'm wondering what the best practices policy is for initializing components with more than one set of parameters.

Thx,

Zac
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/chill% 40global-village.net

This email sent to [EMAIL PROTECTED]




--
Coming in 2006 - an introduction to web applications using WebObjects and Xcode http://www.global-village.net/wointro

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems. http://www.global-village.net/products/ practical_webobjects




_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/mschrag% 40mdimension.com

This email sent to [EMAIL PROTECTED]

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/jerrywwalker% 40gmail.com

This email sent to [EMAIL PROTECTED]


--
__ Jerry W. Walker,
WebObjects Developer/Instructor for High Performance Industrial Strength Internet Enabled Systems

    [EMAIL PROTECTED]
    203 278-4085        office



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to