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

Apr
16
comment How would another popular language avoid having to use the factory pattern while managing similar complexity as in Java/Java EE?
The problem isn't the use of factories -- it's a perfectly fine pattern. It's the overuse of factories which is especially prevalent in the enterprisey java world.
Apr
7
comment Real time unit testing - or “how to mock now”
In many cases it's simpler to pass a value DateTime now to the code instead of a clock.
Apr
2
comment how are virtual methods slower in C#
Since the CPU doesn't execute IL, it doesn't matter what the IL uses, it matters what machine code the JIT produces. For virtual methods that's an indirect call, for non virtual methods it's a direct call or the callee even gets inlined into the caller.
Mar
31
comment Is there a Pattern or a Refactoring Method to pull data-loading out of existing Class
Usually an entity should not know how to load itself from the database. You also forgot to pass the database to your constructor/provider.
Mar
31
comment Why is CPU cache memory so fast?
You need to halve that number since you need a round-trip to retrieve memory. So it's just 5cm not 10cm per cycle of latency in vacuum.
Mar
21
comment Is better Show() + Hide() or SetVisible(bool visible)?
@ArlaudPierre Then I'd still need to use the awkward if(...)Show();else Hide(); pattern in outside code or write a SetVisible helper method.
Mar
7
comment How is the publish-subscribe pattern different from gotos?
It's closer to INTERCAL's "come from".
Feb
26
comment Suggest a best practice to create Constants class
Are your constants actually constants in the mathematical sense, or is this a form of configuration?
Feb
26
comment Suggest a best practice to create Constants class
I don't get your question. If a class has no instance members, you can mark it static. This is completely orthogonal to the presence or absence of a static constructor.
Feb
25
comment Was there ever a serious push for partial classes in java
While C# introduced it for code generating UI editors, they're not a good example IMO. They should use a declarative format instead of generating code.
Feb
25
comment An alternative to an array of functions?
Can somebody explain why those non working examples don't work? The answers focus on better solutions, but I don't understand why the original code does not work.
Feb
19
comment How do purely functional programming languages deal with fast changing data?
Many immutable data structures have O(log(n)) cost for operations. But there is no practical difference between O(log(n)) and O(1), constants (which the O notation neglects) are just as important as asymptotic logarithms.
Feb
17
comment Make a change that is ignored by future merges
That's why I said that you should isolate local configuration into a separate config file. All machine specific configuration should be put in that file.
Feb
17
comment Make a change that is ignored by future merges
Create a config file (for example called localconfig) which you include in your .gitignore file so you can't accidentally commit it. Don't mix local configuration with code.
Feb
17
comment Make a change that is ignored by future merges
Don't put it in the versioned code. Put it in a config file which gets ignored by git. A debug flag shouldn't be a property of a branch in the first place.
Feb
13
comment What is the benefit of having the assignment operator return a value?
The only useful case I can remember is while((x = getValue()) != null) {}. Replacements will be uglier since you'll need to either use break or repeat the x = getValue assignment.
Feb
12
comment Extension method naming convention
I don't think this kind of null check is common enough to warrant a helper method beyond the existing string.IsNullOrEmpty. In my experience most null checks take the form if(x==null)throw new ArgumentNullException("x").
Feb
12
comment Interfaces vs Base class
One important difference is that you can't add methods to a public interface, but you can add methods to a public abstract base class.
Feb
10
comment What is best software design in creating methods?
Since this class is essentially a policy, it probably deserves its own interface as well.
Feb
10
comment What is best software design in creating methods?
How does a static method manage to retrieve the promo code?