One of my friend demonstrated a ABAP webdynpro code to me. He used a assistance class to access the data in the ABAP table from an action / event handler method of a view.
I suggested that this may not align with best practices of webdynpro's intended MVC paradigm. My suggestion is that a event handler should call a method in the Component Controller and the method in the component controller should call the assistance class. This based on the general view : any class modelling the database table will be considered as a Model and a View may not access the Model directly without going through the controller.
But he did not agree with it. Hence I request webdynpro experts in the forum to express their opinion and enhance my knowledge about best practices for ABAP webdynpro.
Thanks in advance
Assistance class generally comes into play when a group of people are working on some object and some validation codes and some helper codes keeps on repeating, We can put the code in this class and can be shared by every developer in their component.( it may include some data base fetching statements )
Where there are Data Manipulation which are specific to one component, we create a custom controller which only deal with that particular change and call the appropriate class methods or function modules inside the Custom controller
> This based on the general view : any class modelling the database table will be considered as a Model and a View may not access the Model directly without going through the controller.
See to me the key there is that the View may not directly access the Model. The View (layout design) really can't directly access the Model in Web Dynpro. It is the View Controller that is doing so. Therefore in my mind it is still MVC to call a method of the assistance class from the View Controller. MVC doesn't specify the level of the controller that should be used.
That said it is a good practice to put many of your model calls (those that are reusable) in the component controller. That way you have consistency in the way that you interact with the model and code is more maintainable if it is easier to find. However if you have a call to the model that interacts with just one view or you have a small component that only has one view I personally don't feel that it is a violation to make calls from the assistance class from the view. For instance you might have some model logic that controls the visibility of elements on a particular view.