by nousermane · 3y ago · 0 comments
> using the conditional-value ("ternary") operator in any capacity
Looks like author of some code I had to comb through recently, maybe had that among guidelines. Said code was replete with:
if(function_that_returns_boolean()){
return true;
}else{
return false;
}
...and... if(foo()){
return true;
}else{
if(bar()){
return true;
}else{
return false;
}
}Why stop there?
switch (byte_value) {
case 0: return 0;
case 1: return 1;
...
case 255: return 255;
}Doing the same for not tiny boolean expression: way more
Just because you think it is cool cuz profs forced it on ya during college is not a argument
What most people object to is leaving the last level of if-then-else and returning true or false, when you could have returned simpleBooleanExpression and do away with 1 level of nesting.
If a And b Then
Return True
Else
Return False
End If
programs. Not sure why they were so scared of Return a And b. Apparently they got a new curriculum after I graduated; my teacher was very happy about it but I didn't get to see it myself.The 2021 final exam (which is the most recent I can find) [1] somehow creates XML records for a SQL database (section C, question 7), and hints at using "data validation" to avoid an SQL injection (section C, question 11.c), which is quite exciting. And the 3.5 gigabit wireless connection (section A, question 13) is definitely not using an ISP-supplied router.
[0] https://www.vcaa.vic.edu.au/Documents/exams/technology/2019/..., answers https://www.vcaa.vic.edu.au/Documents/exams/technology/2019/...
[1] https://www.vcaa.vic.edu.au/Documents/exams/appliedcomp/2021..., answers https://www.vcaa.vic.edu.au/Documents/exams/appliedcomp/2021...
case Big_Expression_Here is
when true => Do_Something;
when others => Do_Something_Else;
end case;
and I found myself wondering whether they realize what this is.