4 ms·
I’m probably not as good a programmer as you are, but isn’t using OOP great for making certain types of programs? Think about making a chess game or something.
by reidjs 8y ago
I’m probably not as good a programmer as you are, but isn’t using OOP great for making certain types of programs? Think about making a chess game or something.
- dpc_pw 8y agoGUI programming is used as an example every time someone is praising OOP. And it seems the only time where there is some merit behind using OOP. Chess game would be a good example of what to never do with OOP. If you start with `class Pawn inherits from Piece`, then you going to find yourself in deep shit, really fast. Low performance, high complexity. If you use an 8 by 8 array of integers that mark the pieces, than your code will be just bunch of simple algorithms, that can work really well and fast. It might be a good exercise: write simple chess engine in OOP vs data-centric style, and compare.
- FreeFull 8y agoEven better, a chess board has 64 squares, so you can use a single 64-bit integer to store, say, the position of all white pawns, and repeat this for all the kinds of pieces. Then, you have a compact and fast data representation for your chess engine.
- dpc_pw 8y agoThe important part is - the way you represent the data matters a lot, and almost any representation will make more sense than bunch of "objects" scattered around.