2,416 reputation
2617
bio website github.com/CodesInChaos
location Frankfurt, Germany
age
visits member for 3 years, 7 months
seen yesterday

Jul
4
comment How can I close my Open Source project and what is required from me in order to make it closed source?
I'd restrict the last paragraph to GPL, not open source in general. The conditions vary between licenses, for example AGPL requires you to provide the source code, even if you run it as a publicly accessible server without distribution the binary code.
Jul
4
comment Is it safe to generate client nonces using random number generator?
Random 32 bit numbers collide pretty often. If you want uniqueness, use at least 120 bits.
Jul
1
comment In Java, why use bit hacks when non-bitwise technique it is more readable?
@MichaelT Removing the if is obviously necessary to avoid side-channels. But even without an if, I wouldn't trust < to be constant time. Since the output of a comparison goes to the flag register not to a normal register of x86, I wouldn't be surprised if a compiler emitted a branch to turn the flag into 0 or 1. I've never seen < in code claiming to be constant time, always workarounds like subtract and shift.
Jul
1
comment In Java, why use bit hacks when non-bitwise technique it is more readable?
I'm not convinced that any code containing < is constant time. I've never seen it in crypto code claiming to be constant time. Typically alternatives like (x-y)>>31 are used.
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
26
comment On checking with == with value 1000 answer is coming different but giving the object value 5 answer is same. Can anyone explain the ambiguity
Using == to compare objects is fine, if you intend to get reference semantics. With integers that obviously not the case, but your first sentence is too general.
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
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
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.