12 ms·
This is the power of designing before you code. Nothing to do with data structures. Data structures are part of the design but you're focusing on the object o
by YZF 14y ago
This is the power of designing before you code. Nothing to do with data structures. Data structures are part of the design but you're focusing on the object oriented design aspect.
- mturmon 14y agoYou know, I put in a caveat anticipating this objection, but since you raised it, let me offer the following counterpoint: You could implement the approach I described in a language without any OO support, and still come out ahead. Just do it in plain C using function pointers for methods, and write your own dispatcher. Or, do it in assembly (I implemented this approach in PDP-11 assembly). If you do it this way, it really is all about the data structure -- the methods are subordinate to the data structure, acting just like other state. You could even change the methods after objects have been created -- for example, swap in the "evasive maneuver" move method once you fire on an alien ship, so that the alien goes from lazy drifting to taking evasive action.