Reputation
7,093
Top tag
Next privilege 10,000 Rep.
Access moderator tools
Badges
2 22 42
Newest
 Good Answer
Impact
~476k people reached

Apr
18
awarded  Good Answer
Apr
18
revised How to write correct loops?
added 185 characters in body
Apr
18
comment How to write correct loops?
@CandiedOrange: By duplicating the code I mean literally array[j+1] = array[j]; assert(array[j+1] == array[j]);. In this case, the value seems very very low (it's a copy/paste). If you duplicate the meaning but expressed in another fashion, then it becomes more valuable.
Apr
18
awarded  Nice Answer
Apr
17
revised How to write correct loops?
added 280 characters in body
Apr
17
comment How to write correct loops?
@Jules: Indeed!
Apr
17
comment How to write correct loops?
@psmears: Good point, I informally rewrote the loop header to make it obvious that it terminated but some terminology is always helpful.
Apr
17
revised How to write correct loops?
added 176 characters in body
Apr
17
comment How to write correct loops?
@CodeYogi: With... tests. The thing is, it can be impractical to express everything in assertions: if the assertion merely repeats the code, then it does not bring anything new (repetition does not help with quality). This is why here I did not assert in the loop that 0 <= j <= rightIndex or array[j] <= value, it would just repeat the code. On the other hand, is_sorted brings a new guarantee, thus it's valuable. Afterwards, that's what tests are for. If you call insert([0, 1, 2], 2, 3) to your function and the output isn't [0, 1, 2, 3] then you've found a bug.
Apr
17
answered How to write correct loops?
Apr
8
comment What is “Soft Coding”, really?
@OrangeDog: You are assuming, here, that the software's configuration provides you with the necessary hooks for the check you need to make. Note how in the OP each and every if is based on a different variable! If the variable you need is not accessible from the configuration, you need to modify the software anyway.
Apr
6
comment How can I promote the use of the Builder pattern in my team?
@rath: It's a big data holder of Strings and other primitives. => then you have other problems, hope no-one cares if the e-mail field accidental gets assigned with the guy's post address...
Apr
5
awarded  Nice Answer
Apr
3
comment Business logic: Database vs code
Interesting, in the applications I worked on scaling was achieved by delegating more to the client, in order to save CPU on the database server (then again, we use Oracle so the license cost is based on the number of CPUs...)
Apr
2
comment Business logic: Database vs code
Thanks for expanding the arguments, I have seen performance oft be cited notably. It's important to realize that performance with data access is often linked to (1) the amount of data accessed and (2) the amount of data transferred. In the OLTP world, at least, I've rarely needed more than a well-crafted SQL query (sometimes with a few with a temporary table) to achieve my goals in an efficient way.
Mar
11
comment Why have private fields, isn't protected enough?
Or put simply: protected is for methods, not for data members.
Mar
9
comment How do you transition a program from in-development to release?
@NikkyD: I present you the Idol with Feet of Clay and the concept of Technical Debt. The former means that you can build sound software on shaky foundations, the latter is about the "interested" (added cost) experienced by features that you try to tack on when the structure is not sound.
Mar
1
answered How to pick sequential item IDs and avoiding a clash
Feb
21
comment Why are there so many string classes in the face of std::string?
@PravasiMeet: in a std::string, you can store the pile of poo character U+1F4A9 in 4 bytes: 0xF0 0x9F 0x92 0xA9. You can then obtain a substring: 0xF0 0x9F 0x92; this, unfortunately, is no longer valid UTF-8 because the Code Point is incomplete. When a string implementation allows splitting/truncating in the middle of a code point, it's close to being useless for manipulating text (unless you can ensure that the text in question is solely composed of ASCII or whatever locale-specific you use which is byte-only).
Feb
16
comment Is functional programming faster in multithreading because I write things differently or because things are compiled differently?
Mutable state is the "root of all evil" in the context of parallel processing => if you have not looked at Rust yet, I advise that you peek at it. It manages to allow mutability very efficiently by realizing that the true issue is mutable mixed with aliasing: if you only have aliasing or only have mutability, there is no issue.