This week's book giveaway is in the Java 9 forum.
We're giving away four copies of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications and have Sander Mak & Paul Bakker on-line!
See this thread for details.
Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Whew--Release Is Done  RSS feed

 
Nate Forman
author
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Companies are so inconsiderate, scheduling releases during stuff like this. Now back to the good stuff

Seriously, so far, this has been a really great forum to participate in. I've really enjoyed discussing the topics you've posted, and look forward to continuing.

Best Regards,

Nate
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hope you had fun! Any new reflection insights after the current project release?

--
./pope
[the_mindstorm]
 
Nate Forman
author
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not much time for experimentation... the schedule was really tight. However, I did use a lot of the old standbys: dynamic loading and construction, inspection and access, some proxying... These things really seem to help a framework come up quickly when used in conjunction with the right patterns.

Ali, from your previous postings ('loading plugins') I know you've done this before, but here's an example for the body of the forum:

- data in the form of XML enters my application remotely. I want to handle these messages to do different things in my application.

- I grab a specific token from the XML and synthesize a class name.

- I check a property file for a property that may overload that specific class.

- I use Class.forName() to load the handler class by that name (or the overloaded version from properties)

- I use newInstance() on the loaded handler class to create a handler instance.

- I pass the handler instance my XML data, and the program continues.

This is classic delegation (Command pattern) with a twist. I can extend my application's capability to handle XML by just writing new classes and dropping them in the classpath. This technique is covered in more detail in Chapter 2 of our book.

Best Regards,

Nate
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In addition to insights that you provided above, do you wanna shine some light on us about some "watch-out" things to be prepared to start a new project using Java Reflection?

We do hope you have been in a great week here in the Ranch... Thanks a lot for sharing your valuable time with us...
 
Nate Forman
author
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ko Ko,

It was really my pleasure to participate. Thanks for your insightful questions and comments.

The thing that I like to think about reflection is that it's really good for doing what it does, but you don't want to use it for just anything. When you want to extend your program's flexibility past what you know at writing time, to what you can find out and do while the program is running, that's when to use reflection. We tried to capture as many specific patters (and antipatterns) as we could in the book.

In terms of other "watch outs" in starting a project, it seems like most are the same as starting any project. Misunderstanding requirements, over-design, under-design, lack of documentation, lack of process, lack of testing, etc. can all get you with reflection.

Nate
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!