Most Popular

1500 questions
84
votes
22 answers

Tabs versus spaces—what is the proper indentation character for everything, in every situation, ever?

The coding standards for the code hosted in drupal.org suggest to use two spaces to indent the code; other sites suggest to use tabs to indent the code. What is the proper indentation character for everything, and in every situation? Please explain…
apaderno
  • 4,004
84
votes
19 answers

Choosing between two programmers: experience vs. passion

I am in a position where I have to hire a programmer and have the option of 2 candidates, the first has experience but he doesn't have a passion for coding and he says so while the second doesn't have the experience but he has the passion, he did…
Duke
  • 303
84
votes
6 answers

Why does the type go after the variable name in modern programming languages?

Why is it that in nearly all modern programming languages (Go, Rust, Kotlin, Swift, Scala, Nim, even Python last version) types always come after the variable name in the variable declaration, and not before? Why x: int = 42 and not int x = 42? Is…
84
votes
4 answers

Should I use HTTP status codes to describe application level events

Several servers I have dealt with will return HTTP 200 for requests that the client ought to consider a failure, with something like 'success : false' in the body. This does not seem like a proper implementation of HTTP codes to me, particularly in…
84
votes
2 answers

Is localStorage under The Cookie Law?

I'd like to avoid having the cookies banner on my websites where possible. Could I store session id's in localStorage to bypass implementing the banner?
84
votes
3 answers

How do I move away from the “for-loop” school of thought?

This is a rather conceptual question, but I was hoping I could get some good advice on this. A lot of the programming I do is with (NumPy) arrays; I often have to match items in two or more arrays that are of different sizes and the first thing I go…
turnip
  • 1,667
84
votes
3 answers

"state" or "status"? When should a variable name contain the word "state", and when should a variable name instead contain the word "status"?

Reading code and discussions pertaining to code, I often see the words "state" and "status" used interchangeably, but the following tendencies seem to exist: When a variable holds a value intended to indicate that something is in a certain state,…
Will
  • 951
84
votes
15 answers

How much help should I give during technical interviews?

I'm asked to perform or sit in during many technical interviews. We ask logic questions and simple programming problems that the interviewee is expected to be able to solve on paper. (I would rather they have access to a keyboard, but that is a…
kojiro
  • 2,105
84
votes
13 answers

Why would it ever be possible for Java to be faster than C++?

Sometimes Java outperforms C++ in benchmarks. Of course, sometimes C++ outperforms. See the following…
84
votes
12 answers

Can we replace XML with JSON entirely?

I'm sure lots of developers are familiar with XML and JSON, and they've used both of them. Thus no point in explaining what they are, and what is their purpose, even in brief. If we try to map their concepts, we can say (correct me if I'm…
Saeed Neamati
  • 18,210
83
votes
27 answers

Why to let / not let developers test their own work

I want to gather some arguments as to why letting a developer testing his/her own work as the last step before the product goes into production is a bad idea, because unfortunately, my place of work sometimes does this (the last time this came up,…
pyvi
  • 632
83
votes
12 answers

What is the utility and advantage of getters & setters especially when they are merely used to read and assign values to properties of an object?

I’m still really new to learning to program. Just learning the syntax for a few programming languages at the moment. The courses I viewed for C# and Java touched only very briefly on getters & setters and it still didn’t make an awful lot of sense…
83
votes
4 answers

Programming and Ubiquitous Language (DDD) in a non-English domain

I know there are some questions already here that are closely related to this subject but none of them take Ubiquitous Language as the starting point so I think that justifies this question. For those who don't know: Ubiquitous Language is the…
83
votes
8 answers

How can a class have multiple methods without breaking the single responsibility principle

The Single responsibility principle is defined on wikipedia as The single responsibility principle is a computer programming principle that states that every module, class, or function should have responsibility over a single part of the…
Goose
  • 1,888
83
votes
8 answers

Why use trailing newlines instead of leading with printf?

I heard that you should avoid leading newlines when using printf. So that instead of printf("\nHello World!") you should use printf("Hello World!\n") In this particular example above it does not make sense, since the output would be different, but…
klutt
  • 1,428