cancel
Showing results for 
Search instead for 
Did you mean: 

Custom controller v Assistance Class

IanStubbings
Active Participant
0 Kudos

Hi

I have always used the assistance class to place all business logic. I understand that this replaces the custom controller that is generally used for theis purpose in WDJ. Therefore, is the custom controller used much in WDA or is it largely redundant?

Cheers

Ian

Accepted Solutions (1)

Accepted Solutions (1)

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi Ian,

It is not largely redundant as such, i can see two main reasons

1. Configuration Controller, entire FPM is based on this. you can control the configuration of the WDA using custom controller

2. Business Logic, which belong to only current WDA can be put in Custom Controller so that it is more readable, where as in Assistance class we can use it in other applications when working in a team

in both the cases you are following MVC

Abhi

IanStubbings
Active Participant
0 Kudos

Thanks for the reply Abhi.

I haven't used the FPM yet so will have to wait to try that out.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>

> Hi Ian,

>

> It is not largely redundant as such, i can see two main reasons

>

> 1. Configuration Controller, entire FPM is based on this. you can control the configuration of the WDA using custom controller

>

> 2. Business Logic, which belong to only current WDA can be put in Custom Controller so that it is more readable, where as in Assistance class we can use it in other applications when working in a team

>

> in both the cases you are following MVC

>

> Abhi

1. You are correct that configuration controllers are a useful feature of custom controllers; however FPM is not really based on this. Custom Controllers/Configuration Controllers in your components are not a requirement of FPM. In FPM your component implements a special Web Dynpro Component Interface. The configuration of the FPM is done using component configuration of a standard SAP component. Once again you can use Configuration Controllers in your FPM components like you would in any other component; but it is in no way a requirement to do so in order to use FPM.

2. Technically it is possible to place business logic in the custom controller, but my personal suggestion would be to not do so. The context and context bindings carry a performance penalty and should only be used data that is needed by the layouts. You end up creating custom controllers with logic that is locked into the component and only uses the attributes/methods. What you end up with is a less useful class. That is why I feel that using a normal ABAP class (possibly an Assistance Class) is the perfered way to go.

I would add a third use: the service call wizards. If you are going to use the wizards to generate calls to RFCs or other classes, it is often advisable to place this generated code into a custom controller (one of the wizard options). This is particularly useful if you are going to have more than one wizard call generated. I guess you could make a case that this is the "business logic" that was being refered to in Item 2 above. However I want would make the distinction that this is only the call to the business logic.

IanStubbings
Active Participant
0 Kudos

Thanks once again, Thomas. I was hoping you would reply to my post. I am striving to find the best way to code to a WDA component so I may develop them correctly and also coach others to do the same. Unfortunately the tutorials do not teach best practice so I invariably come across WDAs that have select statements in view controller code etc.

I guess one thrust of my question was whether I should use both the assistance class and a custom controller so I may call the custom controller method from the view controller and the custom controller would then in turn call the assistance class method. In this way my custom controller would only house back end access calls and the component controller would be less cluttered.

What do you think?

Regards

Ian

Former Member
0 Kudos

Ian,

I think the problem with defining the 'best' way is that it is really relative to your scenerio. There isn't going to be a catch-all solution at very granular levels; rather, there are guiding principals such as the MVC.

I have wrestled with this very same consideration and I am still not 100% clear

Thomas, or anyone else, feel free to comment here:

The way I use a custom controller is to organize very complex components into functional buckets. In the case of a custom controller, all of that functions appropriate back-end interaction and global data (context content, attributes) is encapsulated. Overlap between functions within the component, when appropriate, are captured in the component controller.

It makes sense to put multiple functions within a single component to take advantage of reuse and sometimes this can get quite involved; this is where custom controllers and the assistance class help.

I find the assistance class to be more useful in the situation where you have multiple components with common code. Calling the assistance class from the custom controller for the purpose of adhereing to the MVC makes sense to me if your business logic is captured in assistance class. Typically, I build service classes which I call from my controllers; be that a custom controller or the component controller.

Again, I don't think there is really any silver bullet and often, it's very tough (and often subject to personal taste) to establish what the absolute best method will be.

IanStubbings
Active Participant
0 Kudos

Many thanks for your input, Robert.

Until recently, I had been under the impression that the assistance class was THE place to put non screen logic, predominantly business logic but also setters and getters for example. Now I am thinking that perhaps I can break this down more into more 'functional buckets' like yourself.

However, the assistance class offers a lot of flexibility and also seeing it in the left hand pane of SE80 rather than having to hunt for it in SE24 is a big bonus. Also having multiple classes

My issue with the custom controller so far was than I wanted it to house my setters and getters, but I needed to set a variable from the component controller as well and hence I reverted back to the assistance class.

Is there any 'official' SAP documentation on the best practice WDA structuring?

Cheers

Ian

Edited by: Ian Stubbings on Feb 20, 2009 12:54 PM

IanStubbings
Active Participant
0 Kudos

Closing

Answers (1)

Answers (1)

Former Member
0 Kudos

hi ,

Basically we use custom controller and Assistance class in following cases in Web dynpro ABAP .

Assistance Class .

1) In MVC based implementation we try to seaprate UI and Business Logic i,e. Model Part .

Assistance class is class that can be used in your web dynpro ABAP component whenever and Whereever you would like to have Interaction with Database ,

In such cases you will call READ and WRITE Methods of Assistance class .

Now this Assistance classes are not specific to Web Dynpro ABAP Component ...They are generic that can be used at many place.

Another aspect , When We work in Team for large implementation ..some Guys do view i,e. UI part Some guys do BackEnd i.e. Model part ....Now is such case Assistance class become kind of central Repository for BackEnd Query ...UI dev. will just use its method .

Spliting of work can be done across team .

custom controller

1) You can make context with some custom methods and all which specific to your web dynpro ABAP component .It can be Reused at many places inside component ...In some special cased we use this.

Now you can understand we will make Model part in Custom Controller then It will not be available outside of component ...

Hope this clears your doubt...