I still can't figure it out >.<

05/14/2012 19:31 bone-you#16
Quote:
Originally Posted by IAmHawtness View Post
If you're talking about a "IsValidMonster" property on the Entity class, I highly disagree. Why would that logic belong to the Entity class? It has absolutely no place there IMO.

Sorry if I misunderstood you
He's just saying to not check for false, but to check for true instead. Problem with checking for false is that anything not true will be considered false. For example, if there were 3 types of items being checked, player, npc, mob, checking if it's not a player will return true for mobs (what you want) and npcs (what you still don't want) while checking if it's a mob will return only true on mobs, and false on players and npcs. It's more of being precise in what you want. That is, if I'm correct on what I'm assuming he means.
05/14/2012 19:39 pro4never#17
Quote:
Originally Posted by IAmHawtness View Post
If you're talking about a "IsValidMonster" property on the Entity class, I highly disagree. Why would that logic belong to the Entity class? It has absolutely no place there IMO.

Sorry if I misunderstood you
Sorry, I was referring to negative logic in general rather than this actual code snippet.


!condition1 and !condition2 and !condition3 type statements are not exactly good form and can really serve to confuse you when looking for issues.

<edit> Yes, exactly what bone is saying but also from a coding style standpoint.

When running conditions you should be checking for what you DO want rather then ruling out everything you DON'T want. When you write all your checks limiting out what you don't want, your code is difficult to skim through and, more seriously, is no longer very expandable as you need to go back and add more negative conditions for every new possibility you add.
05/14/2012 20:26 IAmHawtness#18
Quote:
Originally Posted by bone-you View Post
He's just saying to not check for false, but to check for true instead. Problem with checking for false is that anything not true will be considered false. For example, if there were 3 types of items being checked, player, npc, mob, checking if it's not a player will return true for mobs (what you want) and npcs (what you still don't want) while checking if it's a mob will return only true on mobs, and false on players and npcs. It's more of being precise in what you want. That is, if I'm correct on what I'm assuming he means.
Quote:
Originally Posted by pro4never View Post
Sorry, I was referring to negative logic in general rather than this actual code snippet.


!condition1 and !condition2 and !condition3 type statements are not exactly good form and can really serve to confuse you when looking for issues.

<edit> Yes, exactly what bone is saying but also from a coding style standpoint.

When running conditions you should be checking for what you DO want rather then ruling out everything you DON'T want. When you write all your checks limiting out what you don't want, your code is difficult to skim through and, more seriously, is no longer very expandable as you need to go back and add more negative conditions for every new possibility you add.
Oh, makes sense now, didn't catch that part :p. I generally try to avoid the "if not" statements, but I feel that sometimes it's just easier to code and makes more sense using the not operator