if and if not do it anyway
-
// ask for property
final boolean bKVSatzInklSonderbeitragProperty = getModulContext().isKVSatzInklSonderbeitrag();
// get same property from another point in code
final boolean bKVSatzInklSonderbeitrag = m_oKV_SatzInklSonderbeitrag.isTrue();// try to figure out this!
if(!(bKVSatzInklSonderbeitragProperty && bKVSatzInklSonderbeitrag
|| !bKVSatzInklSonderbeitragProperty && !bKVSatzInklSonderbeitrag)) {
if(bKVSatzInklSonderbeitragProperty) {
m_oKVSatzNeu.setDouble(m_oKVSatzNeu.getDouble() + 0.9);
}
else {
m_oKVSatzNeu.setDouble(m_oKVSatzNeu.getDouble() - 0.9);
}
}
return m_oKVSatzNeu;I never finish anyth...
-
// ask for property
final boolean bKVSatzInklSonderbeitragProperty = getModulContext().isKVSatzInklSonderbeitrag();
// get same property from another point in code
final boolean bKVSatzInklSonderbeitrag = m_oKV_SatzInklSonderbeitrag.isTrue();// try to figure out this!
if(!(bKVSatzInklSonderbeitragProperty && bKVSatzInklSonderbeitrag
|| !bKVSatzInklSonderbeitragProperty && !bKVSatzInklSonderbeitrag)) {
if(bKVSatzInklSonderbeitragProperty) {
m_oKVSatzNeu.setDouble(m_oKVSatzNeu.getDouble() + 0.9);
}
else {
m_oKVSatzNeu.setDouble(m_oKVSatzNeu.getDouble() - 0.9);
}
}
return m_oKVSatzNeu;I never finish anyth...
i like more: if( bKVSatzInklSonderbeitragProperty != bKVSatzInklSonderbeitrag ) { double dSatz = m_oKVSatzNeu.getDouble(); if(bKVSatzInklSonderbeitragProperty) { dSatz += 0.9; } else { dSatz -= 0.9; } m_oKVSatzNeu.setDouble( dSatz ); } it can only happen here :(( :(( :((
Press F1 for help or google it. Greetings from Germany
-
// ask for property
final boolean bKVSatzInklSonderbeitragProperty = getModulContext().isKVSatzInklSonderbeitrag();
// get same property from another point in code
final boolean bKVSatzInklSonderbeitrag = m_oKV_SatzInklSonderbeitrag.isTrue();// try to figure out this!
if(!(bKVSatzInklSonderbeitragProperty && bKVSatzInklSonderbeitrag
|| !bKVSatzInklSonderbeitragProperty && !bKVSatzInklSonderbeitrag)) {
if(bKVSatzInklSonderbeitragProperty) {
m_oKVSatzNeu.setDouble(m_oKVSatzNeu.getDouble() + 0.9);
}
else {
m_oKVSatzNeu.setDouble(m_oKVSatzNeu.getDouble() - 0.9);
}
}
return m_oKVSatzNeu;I never finish anyth...
I think he's trying to do an exclusive or. If I'm interpreting that right, it boils down to:
NOT (both true OR both false)
-
I think he's trying to do an exclusive or. If I'm interpreting that right, it boils down to:
NOT (both true OR both false)
-
yes, think so too. unfortunatly he managed to compare one boolean with itself, which makes it nonfunctional.
I never finish anyth...
-
yes, think so too. unfortunatly he managed to compare one boolean with itself, which makes it nonfunctional.
I never finish anyth...
TorstenH. wrote:
yes, think so too. unfortunatly he managed to compare one boolean with itself, which makes it nonfunctional.
It looks like he's comparing two similarly-named but different properties (bKVSatzInklSonderbeitragProperty and bKVSatzInklSonderbeitrag). The code is redundant in that it would be more efficient to say:
if (a && !b)
action1();
else if (b && !a)
action2();than to say
if (!!(a) != !!(b))
{
if (a)
action1();
else
action2();
}which is what the latter effectively does. On the other hand, the latter formulation would allow code to be executed before or after action1/action2 any time either was executed (e.g. if action1 or action2 set a visual property for a control, one could use common code to force a refresh).
-
i like more: if( bKVSatzInklSonderbeitragProperty != bKVSatzInklSonderbeitrag ) { double dSatz = m_oKVSatzNeu.getDouble(); if(bKVSatzInklSonderbeitragProperty) { dSatz += 0.9; } else { dSatz -= 0.9; } m_oKVSatzNeu.setDouble( dSatz ); } it can only happen here :(( :(( :((
Press F1 for help or google it. Greetings from Germany
Or even:
if (bKVSatzInklSonderbeitragProperty ^ bKVSatzInklSonderbeitrag)
{
double dSatz = m_oKVSatzNeu.getDouble();
dSatz += 0.9; // teez my smart optimization
if (bKVSatzInklSonderbeitrag)
dSatz -= 1.8;m_oKVSatzNeu.setDouble( dSatz );
}
else
throw ArgumentException("Ha ha, see how smart my validation code is, eh?");Greetings - Jacek
-
TorstenH. wrote:
yes, think so too. unfortunatly he managed to compare one boolean with itself, which makes it nonfunctional.
It looks like he's comparing two similarly-named but different properties (bKVSatzInklSonderbeitragProperty and bKVSatzInklSonderbeitrag). The code is redundant in that it would be more efficient to say:
if (a && !b)
action1();
else if (b && !a)
action2();than to say
if (!!(a) != !!(b))
{
if (a)
action1();
else
action2();
}which is what the latter effectively does. On the other hand, the latter formulation would allow code to be executed before or after action1/action2 any time either was executed (e.g. if action1 or action2 set a visual property for a control, one could use common code to force a refresh).
nop, it was the exact same boolean, read from an property-file. He just needed to name it different due to some strange java code convention :^) :omg: so in this case it comes to:
if(!(bConditiontrue && bConditiontrue || bConditionfalse && bConditionfalse)) {
if(bConditiontrue) {
doSomething();
}
else {
doOpposite();
}
}or simpler:
if (bConditiontrue) dosomething();
I never finish anyth...
-
nop, it was the exact same boolean, read from an property-file. He just needed to name it different due to some strange java code convention :^) :omg: so in this case it comes to:
if(!(bConditiontrue && bConditiontrue || bConditionfalse && bConditionfalse)) {
if(bConditiontrue) {
doSomething();
}
else {
doOpposite();
}
}or simpler:
if (bConditiontrue) dosomething();
I never finish anyth...
nop, it was the exact same boolean, read from an property-file.
One of them seems to have been accessed via getModulContext(), and the other one not, so I don't see that it's obvious from the code snippet posted that they would always return the same thing (both with the code as it is, and with adaptations that might occur to various other parts of the code).
-
// ask for property
final boolean bKVSatzInklSonderbeitragProperty = getModulContext().isKVSatzInklSonderbeitrag();
// get same property from another point in code
final boolean bKVSatzInklSonderbeitrag = m_oKV_SatzInklSonderbeitrag.isTrue();// try to figure out this!
if(!(bKVSatzInklSonderbeitragProperty && bKVSatzInklSonderbeitrag
|| !bKVSatzInklSonderbeitragProperty && !bKVSatzInklSonderbeitrag)) {
if(bKVSatzInklSonderbeitragProperty) {
m_oKVSatzNeu.setDouble(m_oKVSatzNeu.getDouble() + 0.9);
}
else {
m_oKVSatzNeu.setDouble(m_oKVSatzNeu.getDouble() - 0.9);
}
}
return m_oKVSatzNeu;I never finish anyth...
I tell people and tell people and tell people to use parens and not assume people know operator precedence. People tell me I'm stupid. I choose to believe they mean for saying use parens. Walk through it and change the values in the debugger and make a state table. I also go with the XOR interpretation.
Opacity, the new Transparency.