1,196 reputation
815
bio website
location
age
visits member for 3 years, 11 months
seen 2 days ago

Nov
27
comment Can we replace XML with JSON entirely?
@trVoldemort No, several p-tags would like <p>par1</p><p>par2</p> would look like [{"p": "par1}, {"p": "par2"}]. Actually, I'm only using a hash key to distinguish the tag from the body. Mimicking SXML would be probably clearer. While I might agree that XML may be better than JSON for markup, it's a real mess for anything else. Especially configuration and object serialization.
Nov
18
comment Why didn't == operator string value comparison make it to Java?
Let us continue this discussion in chat.
Nov
18
comment Why didn't == operator string value comparison make it to Java?
If there's no good solution for the primitive to object comparison, then I'd simply forbid it. It'd be a special rule, but one which could bite nobody. +++ Claiming that int to float is not lossy is one of big Java mistakes (rarely anybody runs into this, but if so, it's pretty hard to find). If they didn't want to special case 1 + 2.0f to return double, then they should simply forbid it; similarly for 16777217==16777216.0f. +++ Also lL + 2.0 should be forbidden, as there's no type to which both operands could converted to without real narrowing.
Nov
18
comment Why didn't == operator string value comparison make it to Java?
I think that my idea is consistent. Just keep it mind that in the better world, == has nothing to do with identityEquals. +++ "separate equality operators for value and reference equality" - but which ones? I'd consider both primitive == and equals as doing value comparison in the sense that equals looks at the value of the reference. +++ When == meant equals, then int==Integer SHOULD do autoboxing and compare the references using null-safe equals. +++ I'm afraid, my idea is not really mine, but just what Kotlin does.
Nov
17
comment Why didn't == operator string value comparison make it to Java?
I must be missing something, but IMHO == on objects should simply call (null-safe) equals and something else (e.g., === or System.identityEqual) should be used for the identity comparison. Mixing primitives and objects would be initially forbidden (there was no autoboxing before 1.5) and then some simple rule could be found (e.g. null-safe unbox, then cast, then compare).
Sep
15
comment Coding Guideline : Methods shouldn't contain more than 7 statements?
@Jaydee The linked question shows common but strange practice: Wrapping an exception and logging. On the next level you may do the same... this way a single exception appears multiple times in the log. It'd be better to declare the method throwing and you saved 3 lines. Write a helper method closing both ps and rs and save another one. Or write a method List<Row> readDb(String sql, Object... args) which does the whole job (works only for result sets fitting in memory, but fetching too much data usually implies that the work should be done in the DB anyway).
Sep
14
comment Is there any reason to override Equals for an Entity?
@sturdytree That's surely true, but imagine you've done some processing already and there are many instance of the entity sloating around... how would you get them all? The simplest case: imagine a single Set<YourEntrity>, how would you find and entity by id therein?
Sep
13
comment DDD: Can immutable objects also be entities?
@bckpwrld No, he surely means a Null Object.
Sep
13
comment Why is Global State so Evil?
Yes, that's what I did. And there's a variable declared as State state and that's why I call the class "State", too. A purely functional approach... I haven't really thought of it, sounds interesting.
Sep
13
comment Why is Global State so Evil?
@Giorgio Once I started a question here by "State: This is an immutable class...". This obviously means "a snapshot of the state" and the state variable changes by pointing to different instances. But isn't this obvious? When we say "the current state" we also mean a fixed thing, right?
Sep
3
comment Is using Git Stash as a workflow an antipattern?
@MichaelT My local branch allows everything. Unconditionally.
Sep
3
comment Is using Git Stash as a workflow an antipattern?
@MichaelT For me stash is a big no no, as I tend to forget it sometimes (forgetting it once is bad enough). Committing locally some broken code with a proper message is much better as there's nothing what could be forgotten.
Aug
29
comment Using Mockito.reset
@AndresF. I'm mocking RequestResponse since I want it to do exactly what told to. My strange test is a sequence of setup + handle-call + test, repeated three times, i.e., actually three tests in one. Separating them means a lot of code duplication and still I need to put the data in somehow...
Aug
29
comment Is there any danger in writing raw bytes to a file?
I'd suggest to keep it simple. 256 different versions will suffice and if not, additional versions can be devised as subversions of version 255. Similarly for metadata, it's enough to add them in a the version when they're actually needed. @Joe Image??? You're avoiding the potential format confusion by confusing everyone beforehand!
Aug
3
comment Why did memory-managed languages like Java, Javascript, and C# retain the `new` keyword?
@AndresF. Or even simpler with Person me being nil and Person me() invoking the default constructor. So you'd always need parentheses in order to invoke anything, and thus get rid of one C++ irregularity.
Jul
28
comment What's the easiest way to comply with open source licenses?
@RobertHarvey I wouldn't consider it acceptable to put meta-commentary in others' question. I also don't consider it acceptable to remove it from others' questions. I'd be OK to remove the first sentence (which I agree is misplaced there), but not so for the following as it also explains why the question is not more detailed.
Jun
18
comment Why was C# made with “new” and “virtual+override” keywords unlike Java?
I fully agree with you.
Jun
18
comment Why was C# made with “new” and “virtual+override” keywords unlike Java?
The performance point is completely obsolete by now. For a proof see my benchmark showing that accessing a field via a non-final but never overloaded method takes a single cycle.
Jun
17
comment What complexity do DI frameworks add?
The nice thing about Guice is that it can be fully configured in Java (there's no XML unless you get an add-on). For small projects (which is what I'masking about), "auto-wiring" actually suffices. I've updated my question; maybe all the fears come from bad (or too enterpricey DI frameworks)?
Jun
17
comment What prevents a race condition on a lock?
@gdhoward I can't believe it... this answer took me less than 5 minutes and it's the third highest voted out of my four hundreds answers (mainly SO). And also probably the shortest one.