Monday, February 18, 2013

Recommendation for Custom Method in ADF BC View Object Implementation Class

When working in different projects, reviewing ADF code and doing quality audits - one of the most often encountered issues is oversized Application Module Implementation class. Let's say there are 20 - 30 use cases based on the same Application Module (which is perfectly fine) and all the custom methods from these use cases are implemented in the single class - Application Module Implementation class. It becomes hard to maintain oversized class and even hard to read. Very often these custom methods are even not reusable across different use cases, it just developer decided to implement them all in the same place. In some cases we must implement custom methods in Application Module Implementation class: method is accessing different VO instances, method is not really related to some specific VO, etc. But in many cases, custom method works only with single VO instance - then it can be moved into VO Implementation class.

Here is the example - instead of letting grow Application Module Implementation class without any limit:


Try to move as much as possible of custom code related to single VO instance into VO Implementation class:


You can expose custom method from VO Implementation class to the client interface and make it available in Data Control:


Custom method from VO Implementation class is available in Data Control under VO instance:


Call Test Method button from ADF UI invokes custom method created in VO Implementation class and referenced through Data Control:


Here you can download sample application for this post - VOImplCustomMethodApp.zip.

4 comments:

Rohan Walia said...

Very nice advice Andrejus. I also noticed that AM Impl class is huge in our project.
We can use this advice in future and save AM Impl class to be so long.

Thanks
Rohan

Unknown said...

thanks Andrejus, but i have a question,

How can i return a value from custom method in view object class?

Anonymous said...

i have a textbox that i want its value to be set to a bind variable.
i already made setter for the bind variable in VO impl file, and exposed it to client, but when i drag it to the page it asks me to provide a value for the argument.
how can i reference the inputText.inputValue?

Akash said...

Hi Andrejus,

I have a query regarding the design of ViewObjects & ApplicationModule in Oracle ADF.
Just the way we have flexibility to create and access any ViewObject anywhere in our project by merely maintaining a Root application module. Sometimes, we dont need to have the root application module even. Without even importing any independent project's jar, we can create and maintain a ViewObject in the context.

Can you please suggest/highlight any other programming aspects across different Java based framework where we have a similar functionality where we could get access to any java bean from any independent directory without actually having to import the containing project's jar?