ShowMeYourTiddles•
public Boolean IsFemale
{
    throw new ArgumentAboutGenderContinuumException();
}
20
billy_tables•

Exception up = new Exception("😳"); throw up;

16
shadetheartist•

This is forgivable from a beginner. Who wrote this code matters.

14
failedgamor•

"Professionals" wrote this code to be looked at by at least 6000+ students. Then again they do have to write the code in 5(?) languages so they have to keep the code consistent

7
5225225•

I think it's written in Pascal, then ported to each other language's syntax, making as few changes to the code as possible.

2
5225225•

I think it's written in Pascal, then ported to each other language's syntax, making as few changes to the code as possible.

1
RazarTuk•

Downvoted for actual shittiness, not fake shittiness

12
svopper•

New to programming. What's wrong with this block?

7
scorcher24•

/serious

public Boolean isFemale()
{
   return (Gender == Genders.Female)
}
16
JamEngulfer221•

Well, yeah, but this code is for people who potentially haven't done any programming before this course.

I know OP's post is inefficient, but it's really simple and makes sense. Your code is efficient, but uses syntax that people might get confused by if they were a novice.

4
scorcher24•

If you one get's confused by that, maybe programming isn't really up their alley. Sorry to be that harsh, but that is entry level stuff. Anyone who teaches or uses code in the OP needs to get a serious talking to.

10
JamEngulfer221•

If shortening expressions like that isn't specifically taught on the course then it shouldn't be in the exam.

Sorry to be harsh, but at the end of the day, adding a few lines to make the code clearer for people who might not get it as well isn't going to harm anyone.

4
Malgidus•

Agreed. OP's code is going to run just as well. It's probably identical after it's been compiled.

2
RazarTuk•

The comparison returns a boolean which you can return directly.

10
SusuKacangSoya•

Upper-beginner: Furthermore,

if (objet.isFemale())

isn't that much shorter than

if (objet.getGender() == Genders.FEMALE)

considering that going with the former forces you to write this whole isFemale() method in the first place, making you ultimately write more. Plus, if I wanted to add more Genders, I have to write a new isGender() method for each one of them.

I would do this only if I didn't have access to the Genders class, or wanted to max out readability.

I might be wrong, though.

5
Malgidus•

I would go one step further and drop the get/set functions for the gender member if they're going to be trivial get/set public functions.

if(object.gender == Genders.FEMALE)

2
yodacola•
Genders gender = getGender();
switch (gender) {
    case Genders.Female:
    ...
}

I thought this was the norm for enums.

Assuming genders looks something like Facebook's gender list.

6
apocalypsedg•

so that's what they mean they talk about switching genders

11