objective c - iphone: is this a correct design: 2 views with 1 class? -


i' new iphone developer coming flash stuff.

let me tell problem: i'm doing puzzle game , have tab bar controller 4 tabs. use 1 tab sign , other login, works different uses lot of same code (displaying images, playing sounds, settings stuff, audio things, animations things, , on).

the point 2 views have almost same ui elements, i.e. differences them 2 labels.

when using flash easy, reused elements: if in login window hid 2 additional sign labels. 1 class controlled everything. easy , fast.

here have created 2 views: sign , login (one each one)
1 class: "singuploginviewcontroller.m" controls (please note: 1 class, 2 instances)

question
works concern if it's correct design? other way separating "singuploginviewcontroller.m" in "singupviewcontroller.m" , "loginviewcontroller.m".
, other way sharing same instance.

thanks help

nothing wrong that. it's avoid code duplication.

an alternative create base class implements logic common both views , create 2 subclasses, 1 each views, implements things differentiates other view.

both ways fine. base class way more "clean" theoretic point of view, if differences aren't big pragmatic one-class-for-both-views isn't bad either.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -