language agnostic - Most readable way to write simple conditional check -


More than one conditional test such as shown below What would be the most read / best way to write?

Two possibilities that I could think of (this is Java but language does not really matter here):

Option 1:

  Boolean C1 = PasswordField.GetPassword (). Length & gt; 0; Boolean C2 =! StationIDTextField.getText (). Trim (). IsEmpty (); Boolean C3 =! UsernameTextFieldGettext () Trim (). IsEmpty (); If (C1 & amp; C; and End C3) {okButton.setEnabled (true); }  

Option 2:

  if (passwordField.getPassword). Length & gt; 0 & amp; Amp; Amp; Amp; Amp; Amp; Amp; Amp; Amp; Amp; Amp; Amp; StationIdCustomFilter.getText () Trim (). IsEmpty () & amp;! UsernameTextFieldGate Text () .trim () IsEmpty () {okButton.setEnabled (true);}  

I do not like about option 2, that is, the line is wrapped and then indentation becomes a pain. I do not like about the 1 option that he makes variables for some and is looking at two places.

> So what do you think? Any Other option?

  if (password passwords) and the heststation () & amp; Amp; & Amp; Amp;; And HasUserName ()) okButton.setEnabled (true); Bool password () {return passwordField.getPassword (). Length & gt; 0;}  

etc.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -