Question

I'm trying to write a basic solitaire app for Android, just for practice, but I want to use the best design I can. I've written code in Java, but nothing for Android yet. For the GUI, I figure I can either use the MVC model entirely and make view classes that are very similar to classes I've already written, or I can make some of those classes into view classes to avoid duplicating code and possibly improve performance. The plan I have that doesn't use MVC completely is to make the Card class, which just saves the rank and suit of the card as well as whether it's facing up or not and is mostly for data, into a subclass of the Android View class, just adding methods for drawing and other necessities. Either way, I'm going to make a custom view class for cards.

So, my question is whether it's worth the duplicate code and virtually identical data in order to use MVC. I'm also open to ideas for an alternative design; I just want to learn. Thanks in advance!

Was it helpful?

Solution

Just to answer your question:

So, my question is whether it's worth the duplicate code and virtually identical data in order to use MVC

It's all up to you, Google's Documentation recommends avoid object creation exactly like this kind if possible, so If you consider the benefits of having the MVC implementation worth you should go for it, but take on count that programming for mobile devices involve constraints in memory and performance, if the design starts impacting the performance of your application even when the code is "scalable, extendible, etc..." it might not be the way to go, in case of mobile designs I always go for a good programming advice I took from a Book "Make code usable before making it reusable" but always avoid to do a disaster, there's no hard rules in software, you could implement a light version of MVC that meets the balance between having readable code and good throughput code.

Hope it Helps!

Regards!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top