I am working on a sophisticated enterprise Java-encoded application that is driven by complex object compositions. For example: in a specific scenario, to execute an action, this is a thread:
login() -> Followed by defined sequence of 10 to 20 method calls in different classes -> Followed by a logout()
Within the framework of almost all actions, including login, logout and many method calls from 10 to 20, do not have return types. Any erroneous behavior is handled by the framework. Let's say in login
public void login(){ try{
Intermediate 10-20 actions are method calls for different objects at different levels of the hierarchy of the structure.
A random class would look like this:
class someobject{ def variable void action1(){ do something on variable } void action2(){ do something on variable } ... }
This variable often changes state, and these actions have a sequence defined only by the wireframe, which I find very annoying.
I would say: โPerhaps if there were suitable return types in general, or at least some of these methods, as in the case of the boolean in the case of login() , life would be much simpler. Due to this tight attachment to the series void return functions are hard for me to debug to understand the flow, and unit testing has become a nightmare for me.
So, now I get the impression that it is always better to write functions that return something, especially when there is a chain of actions. So is this a safe presumption? I would like to express my opinion on this matter. Correct me if I am wrong.
java return void return-value
Vamsi emani
source share