Most Popular

1500 questions
142
votes
8 answers

Recursion or while loops

I was reading about some development interview practices, specifically about the technical questions and tests asked at interviews and I've stumbled quite a few times over sayings of the genre "Ok you solved the problem with a while loop, now can…
141
votes
8 answers

What is a "side effect?"

I haven’t clearly understood the concept of side effect. What is side effect in programming? Is it programming language dependent? Is there such a thing as external and internal side effects? Please give some example of causes that create side…
Amir Rezaei
  • 11,018
141
votes
21 answers

How do you maintain focus when a particular aspect of programming takes 10+ seconds to complete?

I have a very difficult time focusing on what I'm doing (programming-wise) when something (compilation, startup time, etc.) takes more than just a few seconds. Anecdotally it seems that threshold is about 10 seconds (and I recall reading about…
Jer
  • 2,576
141
votes
4 answers

Creating database connections - Do it once or for each query?

At the moment I create a database connection when my web page is first loaded. I then process the page and run any queries against that conection. Is this the best way to do it or should I be creating a database connection each time I run a…
webnoob
  • 2,149
  • 3
  • 19
  • 20
141
votes
5 answers

Why should I prefer composition over inheritance?

I always read that composition is to be preferred over inheritance. A blog post on unlike kinds, for example, advocates using composition over inheritance, but I can't see how polymorphism is achieved. But I have a feeling that when people say…
MustafaM
  • 2,008
141
votes
13 answers

What is the difference between requirements and specifications?

I've been tasked with developing requirements and specifications for a project our group is starting. I realized that I don't know the difference; a Google search just confused me more -- it seems some people say that specifications are…
user39685
140
votes
10 answers

On developing deep programming knowledge

Occasionally I see questions about edge cases and other weirdness on Stack Overflow that are easily answered by the likes of Jon Skeet and Eric Lippert, demonstrating a deep knowledge of the language and its many intricacies, like this one: You…
Robert Harvey
  • 199,517
140
votes
3 answers

What's the phone number equivalent of example.org?

RFC 2606 standard reserves the domain names example.org, example.net and example.com for the purpose of being used as examples in documentation. What is an equivalent for a phone number (including country code) that can be used as an example, e.g.…
Florian
  • 1,129
  • 2
  • 8
  • 7
140
votes
7 answers

Why doesn't Java 8 include immutable collections?

The Java team has done a ton of great work removing barriers to functional programming in Java 8. In particular, the changes to the java.util Collections do a great job of chaining transformations into very fast streamed operations. Considering…
GlenPeterson
  • 14,920
140
votes
18 answers

Is there an excuse for short variable names?

This has become a large frustration with the codebase I'm currently working in; many of our variable names are short and undescriptive. I'm the only developer left on the project, and there isn't documentation as to what most of them do, so I have…
KChaloux
  • 5,803
  • 4
  • 35
  • 34
140
votes
5 answers

Two HTML elements with same id attribute: How bad is it really?

Just browsing the google maps source code. In their header, they have 2 divs with id="search" one contains the other, and also has jstrack="1" attribute. There is a form separating them like so:
140
votes
16 answers

How can I tactfully suggest improvements to others' badly designed code during review?

I'm a great believer in clean code and code craftsmanship, though I'm currently at a job where this isn't regarded as a top priority. I sometimes find myself in a situation where a peer's code is riddled with messy design and very little concern for…
Yony
  • 1,657
139
votes
11 answers

How does an event listener work?

During one of my lectures today about Unity, we discussed updating our player position by checking every frame if the user has a button pushed down. Someone said this was inefficient and we should use an event listener instead. My question is,…
Gary Holiday
  • 1,181
139
votes
13 answers

Are design patterns frowned upon?

I had a discussion with one of our senior developers who's been in the business for 20 years. He's pretty well known in Ontario for a blog he writes. The strange thing is what he told me: he said that there is a piece of code that is a nightmare to…
Igneous01
  • 2,343
138
votes
17 answers

How do I know how reusable my methods should be?

I am minding my own business at home and my wife comes to me and says Honey.. Can you print all the Day Light Savings around the world for 2018 in the console? I need to check something. And I am super happy because that was what I had been…
Koray Tugay
  • 1,585
  • 3
  • 12
  • 18