|
Epic! Especially the sb.Append('_');
|
|
|
|
|
final boolean bKVSatzInklSonderbeitragProperty = getModulContext().isKVSatzInklSonderbeitrag();
final boolean bKVSatzInklSonderbeitrag = m_oKV_SatzInklSonderbeitrag.isTrue();
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...
|
|
|
|
|
|
Or even:
if (bKVSatzInklSonderbeitragProperty ^ bKVSatzInklSonderbeitrag)
{
double dSatz = m_oKVSatzNeu.getDouble();
dSatz += 0.9;
if (bKVSatzInklSonderbeitrag)
dSatz -= 1.8;
m_oKVSatzNeu.setDouble( dSatz );
}
else
throw ArgumentException("Ha ha, see how smart my validation code is, eh?");
Greetings - Jacek
|
|
|
|
|
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...
|
|
|
|
|
I agree with KarstenK
it boils down to:
if(A!=B)
{
if(A)
{//do stuff}
else
{// do something else}
}
|
|
|
|
|
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
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).
|
|
|
|
|
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.
|
|
|
|
|
We have a webpage that contains a table with collapsible sections. Straightforwardly, the code behind the show/hide links took the approach of (1) searching for the tr elements that need to be toggled, and (2) changing the .style.display property to "" or "none" as appropriate.
Less straightforwardly, step #1 was implemented not with DOM methods, but by searching the innerHTML for a string starting with "<TR ID=DISPFILE_". In uppercase, so it wouldn't work on Firefox which normalizes the tag names to lowercase.
At least the original programmer was consistent: Step #2 was implement by a similar text search for "STYLE='display: none'".
|
|
|
|
|
Firstly, -10 points for using nulls on a green field development in my book.
Then I found these fields at the top of the class:
internal class BarHelper : FooHelper
{
decimal? _decimalNull = null;
short? _shortNull = null;
int? _intNull = null;
bool? _boolNull = null;
DateTime? _dateTimeNull = null;
}
What are these for I wondered? A find reference on _decimalNull yeilds:
_bazTableAdapter.InsertRow(
cashbackAmount != null ? cashbackAmount.ValueAsDecimal : _decimalNull,
cashbackAmount != null ? cashbackAmount.CurrencyAsShort : _shortNull,
billAmount != null ? billAmount.ValueAsDecimal : _decimalNull,
billAmount != null ? billAmount.CurrencyAsShort : _shortNull,
billAmount != null ? billAmount.ConversionRateAsDecimal : _decimalNull);
It's all just wrong (including the DataSets and Table adapters) and just makes me want to weep. Even just using cashbackAmount != null ? cashbackAmount.ValueAsDecimal : new Nullable<decimal>() would have been an improvement. On the plus side, as I'm being repeatedly told, we don't have time to do it properly.
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
Awesome code. Can I use it in my application or is it licensed?
Jeroen De Dauw
---
Forums ; Blog ; Wiki
---
70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
|
|
|
|
|
It'll cost you 20 IQ points per line, or 50 to put in a commercial product
|
|
|
|
|
You could write a generic helper class for that.
static class TypedNull
{
public static T GetNull<T>()
{
return null as T;
}
}
billAmount != null ? billAmount.CurrencyAsShort : TypedNull.GetNull<short?>()
10 PRINT Software is hard. - D Knuth
20 GOTO 10
modified on Wednesday, December 16, 2009 4:49 PM
|
|
|
|
|
not quite their code! How about:
public static decimal? AsDecimal(this Foo f)
{
if (f == null)
return null;
return f.DecimalValue;
}
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
you forgot the redundant else
|
|
|
|
|
Nullable types have their uses; this should not be one of them!
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
you're missing the point,
the post is not about Nullable types but Nullable people
|
|
|
|
|
public enum Category
{
MinorProduct = 1,
MajorProduct = 2,
NonStockProduct = 3
}
public void ProcessStock(StockItem item)
{
if (item.Category == MinorProduct &&
item.Category == MajorProduct &&
item.Category == NonStockProduct)
{
Throw new Exception("Invalid Stock Category");
}
}
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
I trust == is a typo for != . Yours or theirs?
..Peter
|
|
|
|
|
I think that's the horror actually :p
Jeroen De Dauw
---
Forums ; Blog ; Wiki
---
70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
|
|
|
|
|
That's not an horror, just a typical 6pm inattention error!
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
That's not an horror, just a typical 6pm inattention error!
That shoud be scary - I mean, to work for a company, where at 6 p.m. enum values can jump out of enum range.
They should also add
private void method(bool b)
{
if (currenttime>=6pm)
{
if (b!=true && b!=false)
{
throw new After6pmException();
}
}
}
|
|
|
|