Most Popular
1500 questions
86
votes
6 answers
Why is negative zero important?
I'm confused about why we care about different representations for positive and negative zero.
I vaguely recall reading claims that having a negative zero representation is extremely important in programming that involves complex numbers. I've never…
jpmc26
- 5,409
86
votes
7 answers
Designing a REST api by URI vs query string
Let's say I have three resources that are related like so:
Grandparent (collection) -> Parent (collection) -> and Child (collection)
The above depicts the relationship among these resources like so: Each grandparent can map to one or several…
HiChews123
- 1,113
86
votes
15 answers
I don't understand the arguments against operator overloading
I just read one of Joel's articles in which he says:
In general, I have to admit that I’m a little bit scared of language features that hide things. When you see the code
i = j * 5;
… in C you know, at least, that j is being multiplied by five and…
fredoverflow
- 6,874
86
votes
9 answers
Should you always pass the bare minimum data needed into a function in cases like this
Let's say I have a function IsAdmin that checks whether a user is an admin. Let's also say that the admin checking is done by matching user id, name and password against some sort of rule (not important).
In my head there are then two possible…
Anders Arpi
- 979
86
votes
11 answers
Why is String immutable in Java?
I couldn't understand the reason of it. I always use String class like other developers, but when I modify the value of it, new instance of String created.
What might be the reason of immutability for String class in Java?
I know there are some…
yfklon
- 1,772
86
votes
9 answers
Should Repositories return IQueryable?
I have been seeing a lot of projects that have repositories that return instances of IQueryable. This allows additional filters and sorting can be performed on the IQueryable by other code, which translates to different SQL being generated. I am…
Travis Parks
- 2,515
86
votes
7 answers
How can robots beat CAPTCHAs?
I have a website e-mail form. I use a custom CAPTCHA to prevent spam from robots. Despite this, I still get spam.
Why? How do robots beat the CAPTCHA? Do they use some kind of advanced OCR or just get the solution from where it is stored?
How…
totymedli
- 1,309
- 1
- 13
- 27
86
votes
3 answers
Is this an appropriate use of Mockito's reset method?
I have a private method in my test class that constructs a commonly used Bar object. The Bar constructor calls someMethod() method in my mocked object:
private @Mock Foo mockedObject; // My mocked object
...
private Bar getBar() {
Bar result =…
Duncan Jones
- 1,402
- 1
- 12
- 18
86
votes
23 answers
Is it a must for every programmer to learn regular expressions?
I am new to programming, and at an interview I got a question on regular expressions; needless to say I couldn't answer. So I was wondering whether I should learn regular expression? Is it a must for every programmer of all fields? Or it is a must…
user
- 2,200
86
votes
4 answers
Classes naming: singular or plural?
It is always difficult for me to choose between singular and plural forms for classes names:
CustomerRepository vs. CustomersRepository
CustomerService vs. CustomersService
CustomerController vs. CustomersController
And for composite names it is…
SiberianGuy
- 4,793
85
votes
10 answers
When to use / not use syntactic sugar
Currently I am working on a school project written in C#. Some teammates just started in C# and some are already familiar with C#. Today I had a discussion on whether to use syntactic sugar like this in our code:
private _someClass;
public SomeClass…
Gertjan Brouwer
- 1,021
85
votes
10 answers
Exceptions, error codes and discriminated unions
I've recently started a C# programming job, but I've got quite a bit of background in Haskell.
But I understand C# is an object-orientated language, I don't want to force a round peg into a square hole.
I read the article Exception Throwing from…
Clinton
- 1,073
85
votes
4 answers
What's the difference between "to" and "as" method name prefixes?
What's the difference between "to" and "as" method name prefixes like
toList(),
asList(),
etc...
When to use which when designing a method?
Daniel Hári
- 711
85
votes
11 answers
Shouldn't unit tests use my own methods?
Today I was watching a "JUnit basics" video and the author said that when testing a given method in your program, you shouldn't use other of your own methods in the process.
To be more specific, he was talking about testing some record-creation…
carlossierra
- 1,405
85
votes
11 answers
Would unit tests have helped Citigroup to avoid this expensive mistake?
I read about this snafu: Programming bug costs Citigroup $7m after legit transactions mistaken for test data for 15 years.
When the system was introduced in the mid-1990s, the program code filtered out any transactions that were given three-digit…
Matt Evans
- 1,015