Skip to main content

Posts

Showing posts with the label design

Determining source of method call at runtime

I'm wondering if there is a "better" way to do this: class Foo { final public function bar() { if (is_subclass_of(get_called_class(), __CLASS__)) { throw new Exception(); } } } class Bar extends Foo { public function baz() { parent::bar(); // shouldn't be allowed } } Essentially, I want certain methods in my parent class to prohibit child classes from calling them. This needs to be bullet-proof, which I doubt this is, so if you know how this could be circumvented, that's what I'm interested in knowing (along with how to prevent it, if possible). Edit: For everyone suggesting private methods, this is not an option, as I need the interface to remain public to be externally accessible. Sorry, I guess I assumed that would be obvious.

Designing animation for android application

What is the best way to design and embed an animation into an android app. (I'm not talking about transitions and activities in/out animations.) I can think of 2 ways of doing it: designing the animation with flash or something similar, export png-sequence with transparent bgs and creating an animation from the images in an xml file (How do I write this kind of xml?) creating a grid of images with all the frames of the animation that I've created and save it into one image. than using something like background-position in css in order to move the visible area of the image on each frame enter (By Java code, or by xml) which of this is better/most common? and how do I implement the solution (if there is a better solution - that would be great). and what programs do you usually use for this kind of task (the goal is to achieve something that works like the frog in cut the rope or the birds in angry birds for example) thanks!