cancel
Showing results for 
Search instead for 
Did you mean: 

WDA Best Practice for Coding

IanStubbings
Active Participant
0 Kudos

Hi

Are there any best practice guidelines for WDA?

I have seen the naming conventions in the official book which I use but are there any actual coding standards such as whether to use the global controller to hold methods and then call these from the relevant onaction methods.

i.e.

METHOD onactionsave .

lv_subrc = wd_comp_controller->check_input( ).

check lv_subrc = 0.

wd_comp_controller->save( ).

ENDMETHOD.

Just wondered...

Also data declarations were traditionally done at the top of a method. Is this still the case in WDA or is it more normal to declare variables etc as they are required - like in Java?

Cheers

Ian

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member215843
Active Participant
0 Kudos

Hi Ian,

There will be some guidelines in the new documentation, which is currently not yet available.

Here some very short tipps:

- Use an assistance class for each component, which should hold the current data and where you can place central methods. Placing methods in external classes is better than putting them into the component controller, because there is less overhead and more functionality (e.g. optional parameters and exceptions).

- Hold your current data in the assistance class and only put them into the context if needed (e.g. via supply functions).

- Call your business logic from the assistance class during event handling. Then you have the opportunity to do navigation or not depending on the output of the business logic.

- You could use any other class for this purpose, but the assistance class is easier, because it is instantiated by the framework and you can access it via wd_assist-> instead of wd_this->my_class-> .

- Do not create a model component, because this is just overhead and no advantage. In earlier states of the WD project, we thought, a model component would be a good idea, but we changed our minds

- Use context mapping, where it is needed, e.g. if you use the same context in different views.

- It is quite well to call the assistance class from the views.

- Be careful, if you store any references to component parts in your assistance class. Some references may change during runtime, especially those of context nodes placed in a deep hierarchy.

Hope this helps, and more tipps will follow in the documentation or weblogs.

Ciao, Regina

IanStubbings
Active Participant
0 Kudos

Thanks Regina, that is very useful.

I am using an assistance class already for some business logic and will therefore move all other component controller code to this.

I look forward to the official documentation - any idea on timescale for this. Is it imminent or a few months away?

Any take on the data declaration placings?

Ian

SergioFerrari
Active Contributor
0 Kudos

Hi Regina,

could you comment the application LORD_MAINTAIN_COMP ?

Does it respect the guidelines? if not could you indicate the most important topics ?

Kind regards,

Sergio

former_member215843
Active Participant
0 Kudos

Hi Sergio,

No, I will <b>not</b> comment any real components!

Regina

SergioFerrari
Active Contributor
0 Kudos

I'm sorry,

I noted that it's a complex WDA but I thought it was just an example.

Thanks,

Sergio