Is conditional return type ever a good idea?
So I have a method that’s something like this:
Naming methods that do the same thing but return different types
Let’s assume that I’m extending a graphical file chooser class (JFileChooser
).
When should one use “out” parameters?
In Objective-C, there are several methods like initWithContentsOfFile:encoding:error:
where one passes in a reference to an NSError
object for the error:
parameter. In this example, the value of the NSError
object passed in can change based on what goes on at runtime when the method is being called and whether the body of the method was executed in a certain way successfully. In a way I think of this NSError
object as sort of like a second return value from the method, and only differs from an object anObject
in the statement return anObject;
in that when this statement is called, execution leaves the method.
Wrapping Primitives to Enable Returning null — Bad Practice?
I am frequently tempted to wrap integers, etc, solely for the purpose of writing methods that can return null
. Negative 1 can work in many cases, but too often (especially in sound) it’s a valid return value.
php return values
I have a codeigniter app and in my model, I always return true or false for all functions, and if I have data that needs to be passed, I also set a property that contains my data.
use areFoo or isFoo?
I have never seen the use of “are” for boolean methods, but the use of “is” is very common.
use areFoo or isFoo?
I have never seen the use of “are” for boolean methods, but the use of “is” is very common.
use areFoo or isFoo?
I have never seen the use of “are” for boolean methods, but the use of “is” is very common.
Intersection of geometric entities
I was trying to design a small C++ geometric API for learning purposes, but came across a problem when dealing with intersections of geometric entities. For example, the intersection of a line and a sphere can have three different types: a couple of points, a point or nothing at all. I found several ways to deal with this problem, but I don’t know which of them seems to be the best:
Should I return Collection or ImmutableCollection from a method?
When writing an API in Java, returning an immutable collection of some sort, I’ve got the option of returning Collection
(or List
, Map
, etc) from the method, or guava’s ImmutableCollection
(or ImmutableList
, ImmutableMap
, etc):