Most Popular

1500 questions
68
votes
17 answers

How to write correct loops?

Most of time while writing loops I usually write wrong boundary conditions(eg: wrong outcome) or my assumptions about loop terminations are wrong(eg: infinitely running loop). Although I got my assumptions correct after some trial and error but I…
CodeYogi
  • 2,166
68
votes
3 answers

Declaring multiple licences in a GitHub project

For years, I've been a great fan of putting licences on things shared online to make it easier for others to determine if and how they can reuse said things. Before GitHub began to gently 'push' its users to include LICENSE files with their repos, I…
Kay
  • 946
68
votes
4 answers

Is it wasteful to create a new database table instead of using enum data type?

Suppose I have 4 types of services I offer (they are unlikely to change often): Testing Design Programming Other Suppose I have 60-80 of actual services that each fall into one of the above categories. For example, 'a service' can be "Test…
Dennis
  • 8,217
68
votes
8 answers

When NOT to use virtual destructors?

I believed I searched many times about virtual destructors, most mention the purpose of virtual destructors, and why you need virtual destructors. Also I think in most cases destructors need to be virtual. Then the question is: Why doesn't c++ set…
ggrr
  • 5,775
68
votes
13 answers

Is it reasonable to null guard every single dereferenced pointer?

At a new job, I've been getting flagged in code reviews for code like this: PowerManager::PowerManager(IMsgSender* msgSender) : msgSender_(msgSender) { } void PowerManager::SignalShutdown() { msgSender_->sendMsg("shutdown()"); } I'm told…
evadeflow
  • 1,222
68
votes
5 answers

When is it NOT good to use actors in akka/erlang?

I've been working with akka for 7-8 months now daily. When I started, I would be working on applications and notice that actors would be used basically anywhere once inside the actor system for communicating between most objects. So I did the same -…
JasonG
  • 1,129
68
votes
13 answers

Why is it a good idea for "lower" application layers not to be aware of "higher" ones?

In a typical (well-designed) MVC web app, the database is not aware of the model code, the model code is not aware of the controller code, and the controller code is not aware of the view code. (I imagine you could even start as far down as the…
Jason Swett
  • 1,880
68
votes
1 answer

Gerrit code review, or Github's fork and pull model?

I am starting a software project that will be team AND community developed. I was previously sold on gerrit, but now Github's fork and pull request model seem to almost provide more tools, ways to visualize commits, and ease of use. For someone who…
68
votes
16 answers

Best practice on if/return

I want to know what is considered better way of returning when I have if statement. Example 1: public bool MyFunction() { // Get some string for this example string myString = GetString(); if (myString == null) { return false; …
sed
  • 401
68
votes
12 answers

Is this a decent use-case for goto in C?

I really hesitate to ask this, because I don't want to "solicit debate, arguments, polling, or extended discussion" but I'm new to C and want to gain more insight into common patterns used in the language. I recently heard some distaste for the…
Robz
  • 1,633
68
votes
8 answers

How were some language communities (eg, Ruby and Python) able to prevent fragmentation while others (eg, Lisp or ML) were not?

The term "Lisp" (or "Lisp-like") is an umbrella for lots of different languages, such as Common Lisp, Scheme, and Arc. There is similar fragmentation in other language communities, like in ML. However, Ruby and Python have both managed to avoid this…
chrisaycock
  • 6,655
68
votes
5 answers

What is inversion of control, and when should I use it?

I am designing a new system and I want to know what inversion of control (IOC) is, and more importantly, when to use it. Does it have to be implemented with interfaces or can be done with classes?
68
votes
15 answers

How can I convince cowboy programmers to use source control?

I work on a small team of devs, 4 guys. They have all used source control. Most of them can't stand source control and instead choose not to use it. I strongly believe source control is a necessary part of professional development. Several issues…
68
votes
5 answers

As a sole developer (for now), how should I be using Git?

I have multiple projects on Git that I eventually want to bring others into. However, right now it's just me and I use Git and GitHub very simplistically: no branches and basically just using the commits as a backup to my local files. Sometimes I'll…
68
votes
16 answers

Why do languages such as C and C++ not have garbage collection, while Java does?

Well, I know that there are things like malloc/free for C, and new/using-a-destructor for memory management in C++, but I was wondering why there aren't "new updates" to these languages that allow the user to have the option to manually manage…
Dark Templar
  • 6,303
  • 16
  • 47
  • 47