0

I initially implemented a video capture application with all the camera and recording logic inside the activity. With my understanding of MVP design pattern, the view should not contain any logic other than the UI itself. So I was advised to hide the camera logic behind an interface. I don't really understand what was ment by hiding it in an interface. Does that mean I have to create an interface and have a separate class implement the features then hooking that up to the activity. Can anyone lead me to the correct understanding of that statement or provide any external help regarding this problem.

1 Answer 1

1

Here's a quick example to demonstrate what was described. You want to have all the camera related code within a separate class, and have an interface to describe the methods.

interface Recorder {
    void recordVideo();
    void takePicture();
}

class CameraRecorder implements Recorder {
    void recordVideo() { ... }
    void takePicture() { ... }
}

// Existing activity
class Activity {
    Recorder recorder;

    void main() {
        recorder.takePicture();
    }
}
Sign up to request clarification or add additional context in comments.

2 Comments

Oh perfect, so it is basically what I expected. Also a follow up question, which component is this logic part of regarding the MVP design?
@WilliamC I'm not an expert so I'm not entirely sure. It seems it could be a model but if there is a significant amount of logic it may be considered a controller.

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.