Most Popular

1500 questions
54
votes
4 answers

Why shouldn't a method throw multiple types of checked exceptions?

We use SonarQube to analyse our Java code and it has this rule (set to critical): Public methods should throw at most one checked exception Using checked exceptions forces method callers to deal with errors, either by propagating them or by…
sdoca
  • 669
  • 1
  • 5
  • 9
54
votes
3 answers

What is a lambda, and why would it be useful?

So far I heard about : Lambda calculus Lambda programming Lambda expressions Lambda functions Which all seems to be related to functional programming... Apparently it will be integrated into C++1x, so I might better understand it…
jokoon
  • 2,242
54
votes
9 answers

Is immutability very worthwhile when there is no concurrency?

It seems that thread-safety is always/often mentioned as the main benefit of using immutable types and especially collections. I have a situation where I would like to make sure that a method will not modify a dictionary of strings (which are…
Den
  • 4,847
  • 2
  • 33
  • 50
54
votes
6 answers

Choosing a functional programming language

I have read a lot of threads about functional programming languages lately (almost in the past year, in fact). I would really like to pick one and learn it thoroughly. Last [course] semester, I have been introduced to Scheme. I loved it. Loved the…
Joanis
  • 1,364
54
votes
3 answers

C++ strongly typed typedef

I've been trying to think of a way of declaring strongly typed typedefs, to catch a certain class of bugs in the compilation stage. It's often the case that I'll typedef an int into several types of ids, or a vector to position or velocity: typedef…
Kian
  • 643
54
votes
5 answers

Builder Pattern: When to fail?

When implementing the Builder Pattern, I often find myself confused with when to let building fail and I even manage to take different stands on the matter every few days. First some explanation: With failing early I mean that building an object…
skiwi
  • 1,138
54
votes
11 answers

Writing my problem solving approach on paper?

I'm a freshman Computer Science student and we just started doing some actual projects in Python. I have found I'm very efficient when I use the pen and paper method that my professor suggested in class. But when I can't write my problem down and…
ComicStix
  • 656
54
votes
3 answers

Why is an anemic domain model considered bad in C#/OOP, but very important in F#/FP?

In a blog post on F# for fun and profit, it says: In a functional design, it is very important to separate behavior from data. The data types are simple and "dumb". And then separately, you have a number of functions that act on those data…
Danny Tuppeny
  • 896
  • 6
  • 13
54
votes
6 answers

Is initializing a char[] with a string literal bad practice?

I was reading a thread titled "strlen vs sizeof" on CodeGuru, and one of the replies states that "it's anyways [sic] bad practice to initialie [sic] a char array with a string literal." Is this true, or is that just his (albeit an "elite member")…
Cole Tobin
  • 1,469
54
votes
3 answers

What is constructor injection?

I have been looking at the terms constructor injection and dependency injection while going through articles on (Service locator) design patterns. When I googled about constructor injection, I got unclear results, which prompted me to check in…
54
votes
14 answers

Why does DirectX use a left-handed coordinate system?

I considered posting on Stack Overflow, but the question strikes me as being far too subjective since I can't think of a reasonable technical explanation for Microsoft's choice in this matter. But this question has bugged me for so long and the…
greyfade
  • 11,133
54
votes
10 answers

Are flag variables an absolute evil?

Are flag variables evil? Are the following kind of variables profoundly immoral and is it wicked to use them? "boolean or integer variables that you assign a value in certain places then down below you check then in orther to do something or not,…
dukeofgaming
  • 13,973
54
votes
3 answers

Visual Studio 2012 - Express vs Professional

I'm having trouble finding a feature comparison between Visual Studio 2012 Express Edition and the professional edition. I'm using the trial Professional version at the moment, but it'll run out soon, so I need to make a decision whether to purchase…
Dan
  • 651
  • 1
  • 5
  • 8
54
votes
5 answers

Is "convention over configuration" not violating basic programming principles?

I was looking at the WPF MVVM framework Caliburn.Micro and read that a lot of standard things are based on naming conventions. For example, automatic binding of properties in the View to properties in the ViewModel. Although this seems to be…
Geerten
  • 1,135
  • 1
  • 8
  • 12
54
votes
3 answers

Where to put business logic in MVC design?

I have created a simple MVC Java application that adds records through data forms to a database. My app collects data, it also validates it and stores it. This is because the data is being sourced online from different users. the data is mostly…