2,443 reputation
2618
bio website github.com/CodesInChaos
location Frankfurt, Germany
age
visits member for 3 years, 11 months
seen 18 hours ago

Jul
1
comment Why And is needed when there is AndAlso
C# has both the short circuiting AndAlso in the form of && and the non short circuiting And in the form of &.
Jun
25
comment Approach to cover all the cases in Unit Tests
Visual studio (at least in the expensive editions) has code coverage functionality built in. Unfortunately it's pretty basic and lacks many important features.
Jun
24
comment C# server side application 100 GB dataset + Garbage Collection
How did you compute that 100 GB value? How many instances of DataClass will there be? Does DataClass contain any reference types?
Jun
23
revised Is there a downside to using AggressiveInlining on simple properties?
deleted 3 characters in body; edited title
Jun
23
comment Is there a downside to using AggressiveInlining on simple properties?
3) Inlining too much means the code becomes larger, and might not fit into caches anymore. Cache misses can be a significant performance hit. 4) I recommend not using the attribute until a benchmark showed that it improves performance.
Jun
23
comment Is there a downside to using AggressiveInlining on simple properties?
1) In my experience such primitive methods will be inlined without the attribute. I mainly found the attribute useful with non trivial methods that should still be inlined. 2) There is no guarantee that a method decorated with the attribute will be inlined either. It's merely a hint to the JITter.
Jun
23
comment Retrying a statement or call in a catch block - code smell or anti-pattern?
Performance wise exceptions are not that expensive. The main problem with unnecessary exceptions is that they make debugging more annoying.
Jun
23
comment is JS a gradually typed language?
JavaScript is dynamically typed. TypeScript is a gradually typed JavaScript dialect.
Jun
17
comment Constructors, Ignore Arguments
As an alternative you could consider some kind of builder of factory.
Jun
17
comment Constructors, Ignore Arguments
You can use optional parameters and overloads as with every other function. But only the last parameters can be optional, so only making type optional doesn't work. If both type and doors are optional, you could use named parameters to only specify doors but not type.
Jun
16
comment static or non-static, that is the question?
1) I'd make this a method of ReportCard. If you need this on the student, you should forward the call to ReportCard. 2) You should use a generic averaging method which takes a sequence of numbers and outputs a number. Such as Enumerable.LINQ 3) I wouldn't use float on the report card. Either go with decimal or with integers representing fixed point numbers.
Jun
16
comment static or non-static, that is the question?
Your function is called median but computes the arithmetic mean/average.
Jun
13
comment Why/how does Java use a controlled mechanism to pause threads for GC?
Perhaps they want to avoid suspension at arbitrary points in the code. With code the suspension can only happen at a few well defined points.
Jun
13
comment Why/how does Java use a controlled mechanism to pause threads for GC?
@delnan On windows there is SuspendThread
Jun
11
comment How to name a method that both performs a task and returns a boolean as a status?
This kind of exception handler is rarely a good idea. Only catch specific exceptions you're expecting, not all of them. And if possible avoid throwing it in the first place, eliminating the need to catch it.
Jun
11
revised Shortcomings of using dynamic types in C#
edited body
Jun
10
comment Snapchat clone: How do I secure pre-downloaded notifications so that they cannot be opened outside of the app?
You're trying to solve the DRM problem which can't be solved with software. You can only throw lots of obfuscation at it and pray.
Jun
10
comment What are the differences between a while loop and a for loop?
Which language are you talking about? In pascal your argument has some merit (hardcoding a large number as limit is ugly), but in C you can use arbitrary conditions with for. No difference between for(;xxx;) and while(xxx).
Jun
10
comment What are the differences between a while loop and a for loop?
Which languages are you talking about? C style? In pascal for loops are quite different from C for loops and in some other languages for also allows you to write for each loops.
Jun
7
comment Should you keep a copy of all the code you write?
Related article: Did Goldman Sachs Overstep in Criminally Charging Its Ex-Programmer?. This is also a good example that even if you win in the end, the legal battle itself can hurt a lot.