Reputation
28,606
Next tag badge:
226/100 score
16/20 answers
Badges
6 54 99
Newest
 Nice Answer
Impact
~334k people reached

1d
comment Is it a common pattern in Python to have instance variables assigned in a constructor start with an underscore?
See PEP 8: one leading underscore marks a field as private by convention, though it does not actually hide the field.
1d
comment Why do so many languages restrict string literals to a single source line?
Forget a closing quote, then see what happens in various languages. Where will the error message locate the problem? Try to indent a multiline string to match the indentation of your source code. Would the indent be visible inside the resulting string? Or does the long string break your indentation because each line must start in column 1? Also, in C multiple literals are not much of an issue because adjacent string literals are concatenated by the compiler: "a" "b" in the source code is compiled as "ab", which makes it easy to have a large string that is distributed over multiple lines.
1d
comment Preferable design of scope guard in C++
@DDrmmr consider scoping. Expressing this with try-catch would be extremely tedious: { maybeThrow(); Resource r; scope_guard resourceGuard([&](){ r.frobnicate(); }); maybeThrow(); }. I believe that abstractions have to be convenient, or they won't be used.
1d
answered Including both “careful” and “dangerous” versions of a function in a library/module
2d
reviewed Reject Why did BASIC use line numbers?
2d
comment When mapping from a database, do OOP objects (entities) need to store the database values in attributes?
I think the focus on stateless objects is the important point here. The core feature of OOP is polymorphism/dynamic dispatch. The usual implementation technique is a hidden field in each object that contains pointers to methods, i.e. the methods are the data. However, Objects frequently have no user defined fields, which is common when we only need polymorphism, nothing else. This often happens in various design patterns such as strategies, abstract factories, visitors, …. Without polymorphism, stateless objects are just a convenient collection of static functions.
Feb
9
comment Importing namespaces inside another namespace
You can use using for type aliases in class scope, and therefore make the alias private. The using namespace … is rarely wise and should be avoided. Applying these two rules avoids imported types in your namespace, and still keeps your code fairly easy to read and write.
Feb
8
comment Splitting coding progress into meaningful commits without too much overhead
I use git add -p a lot which lets me interactively select the parts of the files I want to commit. If the clean up is sufficiently separate, this is easy to do. If separation is more difficult, I commit the state on a temporary branch, then manually add the changes to my actual branch until there's no diff to the temporary branch. This requires a lot more work, but allows me to check that each commit works on its own.
Feb
8
answered Respectable design pattern for making node modules flexible/testable?
Feb
5
revised What are the reasons for why a Java/Linux stack fails to be “real time”?
added note about the Java standard library having to support real time as well.
Feb
3
comment Measuring sound frequency
We don't do library recommendations here, but I can give you a pointer: determining a frequency is hard, because there might be multiple notes playing together, and the rich sound of a musical instrument stems from a blending of various sounds and frequencies. You would therefore have to run a spectral analysis over the signal to find all present frequencies, and then select the main frequencies.
Feb
2
comment The best practice for writing of examples
Questions asking for best practices tend to be very broad, and get very opinion-based answers. See Why is asking a question on “best practice” a bad thing? and How to ask a “best practice” question. E.g. there could be two contradictory answers “examples should be executable so that they can be copied” and “examples need not be executable because they are illustration”. This is why I've written about my opinions at some other place.
Feb
1
awarded  Nice Answer
Jan
30
reviewed Close How are non-folder files called?
Jan
30
answered How to guarantee web script execution sequence/order or not parallels queues
Jan
30
reviewed Leave Open What's the point of running unit tests on a CI server?
Jan
30
reviewed Leave Open Can “return this” pattern be optimized to no cost performance?
Jan
30
answered What are the reasons for why a Java/Linux stack fails to be “real time”?
Jan
29
comment Preferable design of scope guard in C++
@Deduplicator yes, just assume this scope_guard takes a std::function which does the type erasure for us. Otherwise, we could write auto rollbackGuard = make_scope_guard(...) to avoid an explicit template parameter, but those are unnecessary details. The important part is that disarming a guard (and names for guard objects) can be useful.
Jan
29
answered Preferable design of scope guard in C++