Sunday, January 11, 2015

Smart methods can make a developer look stupid.

So I'm playing through Code Combat (works a lot better generally using Python and in IE though it still has a lot of head-on-desk problems) and I reach a section where I'm supposed to blow up ogres but not villagers. Thing is I only have access to findnearestenemy() in order to identify them. Now it's a pretty explicit method name but I'm much more used to dealing with very simple functions. I'm expecting this to give me whatever the nearest actor is and make me decide whether it's something I want to attack or not. Indeed, a method that does that is generally more useful. So I'm bonking my head for 5 minutes or so because the example code which you're forced to use doesn't account for villagers.

Well apparently findnearestenemy() only returns hostiles. Duh. But. As a method that makes it painfully specific. I'd much rather have a method that gives me the nearest actor and lets me decide whether it's one I care about or not. Maybe that method comes later.

No comments: