Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I remember that in our first programming class with Java, while explaining data types, the following occurred (kinda):

Professor: So, what data type would you choose if your program needs to store the user's gender?

Someone: How about a boolean? You know, true for male and false for female.

Professor: Sure, that may work, but some people may hesitate about that. There have been disputes about calling men "true" and women "false" in the past...

*laughter *

He ended up recommending us to consider chars (like 'm' and 'f') although booleans should be fine.

I tried searching a bit if there has been any kind of historical entry regarding a major dispute based on this programming practice with no luck.

I'm not asking what data type to use for gender nor if it is fine or not to use booleans. I'm asking if, historically, there has been a dispute regarding the usage of booleans to determine the gender in programming because of the apparently "wrong" (I'm not saying it is wrong - I don't care about that) behavior of calling a woman "false" as the professor seemed to suggest.

Searching around related questions, the results happen to be only about software efficiency.

share|improve this question
2  
As written, that looks more like a pun than a serious description of historical programming conflicts... –  Mason Wheeler Feb 14 '13 at 1:10
7  
One problem with using a boolean instead of some kind of enum for modeling real world phenomena - one might want to model transgender, XXY chromosomes, etc. I have seen transgender (2 types) in a real world database as a permissible gender value. I don't know if it was the result of a dispute. –  psr Feb 14 '13 at 1:18
7  
@PhillipBurch: you can still use a boolean. Just use "FileNotFound" for the third gender. –  kevin cline Feb 14 '13 at 1:44
2  
@YannisRizos: I find it unpleasant that, as a man, you would close a question that matters a lot to people who don't identify as either male or female, and that could matter to women as well, just because you don't care about it. Especially as it has been upvoted. –  Niphra Feb 14 '13 at 8:59
3  
@Niphra If you disagree with the closure, feel free to post a question about it on our Meta site. –  Yannis Rizos Feb 14 '13 at 9:04
show 11 more comments

closed as not a real question by Yannis Rizos Feb 14 '13 at 5:51

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

3 Answers

up vote 5 down vote accepted

This is more a cultural issue then technical, and represents a society's perspective on gender.

If you studied in an Islamic country or China, then I can understand why this would be an issue.

So the answer is no, I've never heard of such a silly issue in programming.

share|improve this answer
    
To add weight, I work with data from the NHS in England, this is national data covering the whole population. Gender is stored as an int, 1 for male or 2 for female which would raise the same sudo-ethical questions. Here an int is used over a Boolean because other values are used (e.g. unknown, transgender, etc.) but there's no hesitation about using a coding system where it improves efficiency. You wouldn't hesitate about coding other values, so why hesitate here? –  Matt Feb 14 '13 at 10:06
add comment

Never use a boolean just because there are only two values. Unless the meaning of true and false will be obvious, use an enumeration if available, and string constants or symbols or whatever if not. And all too often, there are initially two values and then later there are three. Or four.

share|improve this answer
1  
Very good advice, thank you, but doesn't address the question. –  Omega Feb 14 '13 at 2:01
1  
Which is are there historical facts about a dispute when using booleans for gender due to the apparently "wrong" moral behavior of calling a woman "false"? (I realize that the title doesn't include the moral part, but the contents of the question do focus on it) –  Omega Feb 14 '13 at 2:09
1  
There are actually been disputes when using booleans due to the fact people who don't identify as female or male felt ignored or rejected - they were forced to choose a gender (see google+). The use of true/false is less of an issue. –  Niphra Feb 14 '13 at 8:46
    
Considering that most programming languages use a full word to store a boolean anyway, and "gender" is decidedly not a true/false property (semantically), then you're absolutely right. Having a "false" gender isn't a social thing at all, it's just semantically incorrect and you're not even gaining a performance advantage. –  Scott Whitlock Feb 14 '13 at 15:11
add comment

Besides the reason given by Kevinn, using boolean in this case forces using variable and property names like isMale (or isFemale), instead of gender.

To me, a neutral name like "gender" is much better than "isblabla" as a property name.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.