0

I would have a class hierarchy like in photo.

Usually in this case it's usefull pattern Decorator in Java, but with MapActivity is not possible, how can i do?

Valid XHTML http://dl.dropbox.com/u/278026/View.png

1 Answer 1

2

You cannot "do". As you say, it is impossible in Java.

You can switch to composition instead of inheritance, and move the logic from AbstractMyActivity into something that a MapActivity can also hold onto.

Sign up to request clarification or add additional context in comments.

3 Comments

Composition is the way to go here, thumbs up!
Yes, but i cannot create a Composite class AbstractMapActivity where the component is MapActivity, because i cannot use MapView inside a class AbstractMapActivity that doesn't extends MapActivity
@Mark: I recommend that you start by learning what object oriented programming is: en.wikipedia.org/wiki/Object-oriented_programming Then, I recommend that you learn what composition is: en.wikipedia.org/wiki/Composite_Pattern Now, I will admit that composition is not ideal here. I wish Java had mixins like Ruby does. But you are clearly confusing composition with abstraction, which are not related.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.