Overly long methods like checkRook violate the well known principle that is formalized in Clean Code as follows:įUNCTIONS SHOULD DO ONE THING. Then you should have other methods for checking that your king is not in check and that it's not going to move over or onto a square that is in check. The only thing you need to check about rooks is that they haven't moved. s, seriously? The t is a list of two points, so apparently a move from Point A to Point B: this should be encapsulated into a new class, called, for example, Move.įurthermore, assuming the method checkRook checks something about the rooks in relation to the castling, I don't know how you managed to make the method so long. Actually, many of those are incomprehensible even when you see the definition. These cannot be read out of context, nor without scrolling back and forth, looking for the variable initializations. If (b.checkPosition(m) & m.x < s)Īgain, horrible naming.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |