Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Is it bad design for one function to call other functions?

$
0
0
This function detects if a gameobject has moved or has had its sprite changed. It then calls one of two functions (or none), to draw a piece of the games background over the gameobjects current location or previous location. Should functions like this be avoided? Is this good or bad design? Does it violate SRP? Also, how would something like this be unit tested? #clean up the display... def blit_background_over_dirty_rects(self): for gameobject, data in self.relevant_data.items(): if data['location'] != gameobject.rect.topleft: #gameobject moved... self._blit_background_over_gameobjects_previous_location(gameobject) elif data['sprite'] != gameobject.sprite_manager.current_sprite: #gameobjects sprite changed... self._blit_background_over_gameobjects_current_location(gameobject)

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>