Null checks in user validation
You can remove result = false;, as result is already false.

And to get rid of the nested statements, you could use early returns:

if (userName == null &amp;&amp; password == null) {
    return false;
}

if (userName.length &lt;= 0 &amp;&amp; password.length &lt;= 0) {
    State.xx.isSaved = false;
    return false;
}
State.xx.isSaved = true;
State.xx.userName = userName;
State.xx.password = password;
return true;


Is it correct that when username is null, isSaved = false should not be set? Because if not, then you could just combine the two if statements, either in my example, or in yours.