Question about view/controller/nib class design

Assume you need to make an application with, let's say, 15 different views in total. There are two extreme design choices you can use to implement the app:
1) Every single view has its own view controller and a nib file. Thus you end up with 15 controller classes and 15 nib files (and possibly a bunch of view classes if any of your views needs to be somehow specialized).
2) You have only one controller which manages all the views, and one nib file from which they are loaded.
AFAIK Apple and many books recommend going purely with option #1. However, going with this often results in needless complexity, large amounts of classes (and nib files) to be managed and complicated class dependencies, especially if some of the views (and thus their controllers) interact with each other or share something (something which would be greatly simplified if all these related views were handled by one single controller class).
Option #2 also usually ends up being very complex. The major problem is that the single controller will often end up being enormous, handling tons of different (and usually unrelated) things (which is just outright bad design). This is seldom a good design, unless your application consists of only a few views which are closely related to each other (and thus it makes sense for one single controller class to handle them).
(Option #2 also breaks the strictest interpretation of the MVC pattern, but that's not really something I'm concerned about. I'm concerned about simple design, not about following a programming pattern to the letter.)
A design somewhere in between the two extremes often seems to be the best approach. However, since I don't have decades of Cocoa programming experience, I would like to hear some opinions about this subject matter from people with more experience on that subject. (I do have object-oriented programming experience, but I have only relatively recently started programming for the iPhone and thus Cocoa and its design patterns are relatively new to me, so I'm still learning.)

Somehow I get the feeling that my question was slightly misunderstood.
I was not asking "which one of these two designs do you think is better, option #1 or option #2?" I already said in my original post that option #2 is bad design (unless your application consists of just one or two views). That's not the issue.
The issue is that from my own experience trying to adhere very strictly to the "every single view must have its own view controller and nib file" often results in needless complexity. Of course this is not always the case, but sometimes you end up having controller classes which perform very similar, if not even the exact same actions, resulting in code repetition. (An OO'ish solution to this problem would be to have a common base class for these view controllers where the common functionality has been grouped, but this often just adds to the overall complexity of the class hierarchy rather than alleviating it.)
As an example, let's assume that you have a set of help screens (for example one help screen for each major feature of the app) and a view where you can select which help view to show. Every one of these views has, for example, a button to immediately exit the help system. If you had one single controller class managing these views, this becomes simpler: The controller can switch between any of the views and the buttons of each view (most of them doing the same things) can call back actions on this controller (eg. to return to the help selection or to exit the help screen completely). These help screens don't necessarily have any functionality of their own, so it's questionable what do they would need view controllers of their own. These view controllers would basically be empty because there's nothing special for them to do.
View controllers might make it easy to use the navigation controller class, but the navigation controller is suitable mainly for utility apps but often not for things like games. (And if you need animated transitions between views, that can be implemented using the UIView animation features.)
I also have hard time seeing the advantages of adhering strictly to the MVC pattern. The MVC pattern is useful in things like web servers, where MVC adds flexibility. The controller acts as a mediator between the database and the user interface, and it does so in such an abstract way that either one can be easily changed (eg. the "view", which normally outputs HTML, could be easily changed to a different "view" which outputs a PDF or even plain text, all this without having to touch the controller or the model at all). However, I'm not seeing the advantages of the MVC pattern in an iPhone app. It provides a type of class design, but why is it better than some other class design? It's not like the input and output formats of the app need to be changed on the fly (which is one advantage of a well-designed program using the MVC pattern).

Similar Messages

  • A question about non-static inner class...

    hello everybody. i have a question about the non-static inner class. following is a block of codes:
    i can declare and have a handle of a non-static inner class, like this : Inner0.HaveValue hv = inn.getHandle( 100 );
    but why cannot i create an object of that non-static inner class by calling its constructor? like this : Inner0.HaveValue hv = Inner0.HaveValue( 100 );
    is it true that "you can never CREATE an object of a non-static inner class( an object of Inner0.HaveValue ) without an object of the outer class( an object of Inner0 )"??
    does the object "hv" in this program belong to the object of its outer class( that is : "inn" )? if "inn" is destroyed by the gc, can "hv" continue to exist?
    thanks a lot. I am a foreigner and my english is not very pure. I hope that i have expressed my idea clearly.
    // -------------- the codes -------------------
    import java.util.*;
    public class Inner0 {
    // definition of an inner class HaveValue...
    private class HaveValue {
    private int itsVal;
    public int getValue() {
    return itsVal;
    public HaveValue( int i ) {
    itsVal = i;
    // create an object of the inner class by calling this function ...
    public HaveValue getHandle( int i ) {
    return new HaveValue( i );
    public static void main( String[] args ) {
    Inner0 inn = new Inner0();
    Inner0.HaveValue hv = inn.getHandle( 100 );
    System.out.println( "i can create an inner class object." );
    System.out.println( "i can also get its value : " + hv.getValue() );
    return;
    // -------------- end of the codes --------------

    when you want to create an object of a non-static inner class, you have to have a reference of the enclosing class.
    You can create an instance of the inner class as:
    outer.inner oi = new outer().new inner();

  • Question about XSL Mapper in BPEL designer

    Hi,
    I have a question regarding the XSL mapper within JDeveloper BPEL Designer.
    Scenario:
    Consider
    1. Source xsd with 3 attributes
    2. Target xsd with 5 attributes
    An XSL mapping is defined for 3 source attributes to the corresponding target attributes.
    The attributes remaining on the target side (2 attributes) are NOT mapped.
    Now test the mapper using the in-built test tool
    (by right clicking on the xsl editor screen).
    The mapper generates a test-xml on the source side and its corresponding transformed xml on the target side.
    Now,
    If i click on "Validate" in the source side, it says "XML is Valid"
    If i click on "Validate" in the target side, it says "XML is NOT Valid" (because the 2 un-mapped attributes are not apprearing the target xml)
    My question is
    Is it an expected behaviour that if an attribute is not mapped, an empty tag <attribute/> is not generated for this attribute in the target xml. If so, wouldn't the target xml be invalid with respect to the target xsd.
    Thanks
    Antony

    I believe by default xml validation is set to false for a BPEL Domain. I am not sure whether setting this to true will cause your process to error out after the transformation or if it only validates inbound and outbound messages.

  • I have A question about Adobe creative Suite 3 Design Premium, and what it comes with..

    My boyfriend works for a office furniture company building and tearing down office furniture. Today one of the people who worked at the company he was tearing down told him he could take any of the programs there as they had no use for them. So he took the Adobe Creative Suite 3 Design Premium as well as mac OSX Leopard, thinking I would like to use them. But I have a PC.
    My question is what comes with the Adobe Creative Suite 3 Design Premium? Since I can not use it, I thought I could sell it, but do not want to do so if I do not have everything it comes with or needs. What I have is three disc's, in the case. There is the application, the content, and the video workshop. There is no booklet or anything with it. If anyone could answer my question, I would really appreciate it. I dont want to sell it to someone and get in any trouble for it not having what its supposed to.
    Thank you for your time and help.

    Firstly, the CS3 Design Prem comes with Photoshop Extended CS3, Illustrator CS3, InDesign CS3, Dreamweaver CS3, Acrobat Pro 8 as well as Bridge and and Vesion Cue.
    Secondly, has the packaging been opened? If so, it could still be installed on a PC or rather Macintosh somewhere. If so, this makes it a trickier proposition with regards to installing it yourself or selling it on.
    Don't quote me on this, but if the software is fresh and unopened or has been deactivated, you could upgrade to Design Prem CS4 Mac and then crossgrade to Design Prem Windows. Don't know if it's possible to crossgrade and upgrade in one fell swoop from Mac to Win. I suspect not - but will be happy to be proven wrong.
    Hope this helps.
    Ian

  • Hello question about blown out layout and designer

    hello im a web designer....my format is to slice my layout in fireworks....then I bring things into dreamweaver and then place flash files into placed blank spots...........my problem is I notice things get out of line and blown out.....how can i fix this?
    example:---http://sites4sight.com/Zdara/Lounge.html...this is fine in safari and IE?

    Try posting at the Web Development / Standards Evangelism forum at MozillaZine. The helpers over there are more knowledgeable about web page development issues with Firefox. <br />
    http://forums.mozillazine.org/viewforum.php?f=25 <br />
    You'll need to register and login to be able to post in that forum.

  • Question about Wireless Controller and LAG.

    I have a Wireless Controller 4400.
    When I configure the controller with LAG, I have to connect the controller to a L3 switch?
    If I connect the controller to a L2 switch the LAG works?
    Some one can tell me something about this?
    Thanks in advance,
    Rui

    Copper? so you are using rj-45 Gb SFPs on the controller. If that is the case, what is the speed of the switchports on the 2960?
    I use the rj-45 Gb SFPs on our 4402s and they work fine connected to Gb rj-45 ports on the switches.
    Also, check out the following:
    http://www.cisco.com/en/US/docs/wireless/controller/4.2/configuration/guide/c42mint.html#wp1116136
    "Using the CLI to Verify Link Aggregation Settings
    To verify your LAG settings, enter this command:
    show lag summary
    Information similar to the following appears:
    LAG Enabled
    Configuring Neighbor Devices to Support LAG
    The controller's neighbor devices must also be properly configured to support LAG.
    •Each neighbor port to which the controller is connected should be configured as follows:
    interface GigabitEthernet
    switchport
    channel-group mode on
    no shutdown
    •The port channel on the neighbor switch should be configured as follows:
    interface port-channel
    switchport
    switchport trunk encapsulation dot1q
    switchport trunk native vlan
    switchport trunk allowed vlan
    switchport mode trunk
    no shutdown

  • Question about 82801ER Controller

    I have ICHR but do not show 82801ER controller in Device Manager.  Is this because I do not have RAID enabled in BIOS.  I have 2 SATA drives but do not use RAID - am trying to figure out why my random access on these drives is just 23ms.  Thought it might be missing controller??!!
    Thanks,
    Peter

    You can't miss out ICH5 Anyway it won't show out as 82801ER, just 82801E.
    I don't know about the exact figure of random access being 23ms. Is it fast or is it slow?

  • Question about single user licence for design premium cs6

    Heya, I just purchased the student version of design premium cs6 and I am wondering what the rules are in the case that my computer hard drive fails.
    Would I be able to use it on another computer or do I have to buy a new set of software?
    Are there any things I should know about installing like backing up the software files somewhere? If so, I would appreciate if anyone could tell me how to do that.
    Also I would like to know if I can use my serial number for a mac version of the software or if I have to buy a whole new set.
    Many thanks in advance

    You have 2 activations and those can be reset when a computer no longer is accessible, otherwise one simply would use Help-->Deactivate and the like to manage activations. Serial numbers are platform specific, so you cannot use the same license on Mac and Windows.
    Mylenium

  • Question about viewing .swf in email

    My client wants to send an .swf by email. lat year the file was 975kb and when they clicked the play button the animation played immediately Yay! This year the .swf animation is 2.4 - 3 mb and I am worried the client will have to wait for it to load.
    I thought of uploading the movie to Youtube but the client wants the large area of white to surround the animation. (the animation is a funky shape on a whie background).
    What other options do I have?
    Is a 2.4 to 3 mb .swf too large to send by email for quick viewing?

    Whichever way you deliver it, it will take time to deliver and/or load.  Why not just publish an html page with a white background and place it on a server.  Send the client a link to it.

  • Question about calculation example with Query Designer

    Hi guys,
    I have to calculate within columns and rows and I am not familiar with the settings in Query Designer that could be done to achieve the results.
    For example:
    Payments----
    Delay -
    Weighted Delay
    1000USD--10 days--
    10000
    2000USD--20 days--
    40000
    3000USD--xxx--
    50000 (this is the sum row)
    The column marked with the xxx is calculated with the sum of weighted delay divided by the sum of payments (50000 / 3000).
    Has anybody an idea how the sum row can be calculated separately?
    Thank you for suggestions!
    Edited by: saplaz on Jul 13, 2010 8:47 AM
    Edited by: saplaz on Jul 13, 2010 9:08 AM

    Hi,
    Assuming you have the Payments Infoobject in the rows and WD Infoobject in the columns; Delay as a formula object.
    > Payments----
    Delay -
    Weighted Delay
    > 1000USD--10 days--
    10000
    > 2000USD--20 days--
    40000
    > 3000USD--xxx--
    50000 (this is the sum row)
    > The column marked with the xxx is calculated with the sum of weighted delay divided by the sum of payments (50000 / 3000).
    You may try this workaround of using
    NODIM( SUMCT(WEIGH_DELAY) / SUMCT(PAYMENTS) )
    on a formula variable. (In this case, the assumption is you have not static type-restricted the rows/cols) If you find any hinderances in the default approach, you may check this out as a formula & insert this at the cell editor level.
    If not, use a simple formula variable; here define the replacement path as 0(N) for your Payments. (N being the # of digits)
    Use a simple calculation:
    SUMGT(WD)/FV
    But you may not get an result o/p in the last row, as the values are not linked (sans relation with Payments). as it will return a X for the delay in the Result row.
    Pls. let me know know if this works or some sample o/p if the initial assumption was wrong.
    Thanks,
    Arun Bala

  • Question about viewing folders

    Guys,
    I was wondering how to view a folder in list view and make all the other windows open the same way. I recently came from Windows and I know there was a setting that would "apply to all folders". Does OS X have something like that? Also, if I have a folder that has pictures in it, is there a way to view it so it shows the thumbsnails of it instead of importing all them into iPhoto? Thanks everyone!

    Yarzy,
    For a detailed discussion of how to deal with setting List view, please see this thread.
    As far as seeing thumbnails, I prefer to use Column View. Column View will show thumbnails for any image files, it will display a preview of PDF documents, and it will even allow you to play audio and video directly in the Finder window; very cool!
    Also, it is very easy to simply drag-select several image files at once in column view. Having done so, you can Control-Click (or right-click) on your selection and choose "Slideshow" from the contextual menu. This is one of the coolest capabilities of OS X, to view a full-screen slideshow from the Finder, with the option to "tile" all the pictures, or to add a single pic to your iPhoto library with the click of your mouse.
    Give these options a try, and let us know how you like them.
    Scott

  • Question About Bex wad portfolio chart design

    hi,
    user wants to compare sales and cost value and see where the department is. ie user want to see sales as Xaxis and cost as Yaxis and department has bubbles in portfolio graph . but when i use this graph i am unable to assign the values to axis and graph i am not able dispalyed correctly . can anyone help me out for this example how to use this graph .
    Department       Sales    /    Retail Value /    Cost Value
    BUILDING         1,658     /       100         /      200
    DECORATIVE       9,101    /         171     /          888             
    ELECTRICAL       7,663     /        3,025   /          946
    anyone who has successfully designed portfolio chart pls give me your solution ,thanks very much.points will be rewarded.
    Best regards,
    Jason
    Edited by: jason su on Aug 12, 2008 5:58 PM

    Hello,
    Goto start menu -> Run -> give '%temp%' and execute. This will show the temp folder here, then find the folder BW and delete this folder complately. Now open BEx analyzer for the first time after this & connect with system, so that the right texts are entered to the temp file in the desktop.
    After this the issue should be fixed.
    Best Regards,
    Michael

  • Questions about these two IO classes....

    1)
    OutputStreamWriter
    An OutputStreamWriter is a bridge from character streams to byte streams: Characters written to it are encoded into bytes using a specified charset.
    i dont understand. Converting characters into bytes is understandable, but what does it mean by "using specified charset"?? I mean, isn't that the other way around?? ie, you convert bytes into characters using a specified charset??
    2)
    BufferedWriter, BufferedWhatEver...
    What does that makes code cleaner, when OutputStreamWriter and PrintWriter have basically same methods as they do??
    3)
    For top efficiency, consider wrapping an OutputStreamWriter within a BufferedWriter so as to avoid frequent converter invocations. For example:
    Writer out
    = new BufferedWriter(new OutputStreamWriter(System.out));
    What does it mean by "to avoid frequent converter invocations"?
    thanks for any responses.

    so, what is "buffering" then?
    I dont understand the explanation... lower code
    invocation??
    maybe in a plainer sentence will help??
    so sorry for not understand it.The following is not necessarily accurate in every technical detail, but it's close enough to demonstrate the principles.
    Let's say I'm going to write 10 bytes. I can do this: stream.write(b0);
    stream.write(b1);
    stream.write(b9);Each of those will cause stream to acces whatever native code it uses which will cause an I/O operation to happen at the hardware level--it will write a byte to the disk controller. It will do this once for every byte.
    Doing that physical I/O carries an overhead. The time taken to actually get the one byte written may be vastly overshadowed by the time taken to access the controller.
    You wouldn't want to establish a connection to a web server, read a byte, close the connection, establish antoher connection, read a byte, et.c. ... right?
    Now, instead, if I put the bytes in an array and call something like bufStream.write(arr, fromByteZero, tenBytes); then I make one call to the stream, it makes one call to the disk controller, pays the overhead cost only once, and writes all ten bytes.
    So instead of 10*overhead + 10*byte_write_time I pay 1*overhead + 10*byte_write_time

  • Some questions about view options for single folders

    hi,
    I'm trying to customize the finder a little, but I'm running into some troubles. It seems that finder is not capable of saving view options for single folders, is it? What I mean is: For example I want my standard view to be "column view, sorted by name". But one specific folder I want to open in "list view, sorted by date modified". I can't get finder to do it.
    In View Options, there is a checkbox "Always open in XXX view". But it only seems to work if I cmd-click that folder so it opens in a new finder window, but not if I stay in the same window, which is really annoying.
    With file-sorting, it seems as soon as I chose "sort files by date modified" finder does this for ALL folders, not only the one I'm currently in (regardless of whether I use View -> Arrange By or View -> View Options -> Arrange By)
    Ideas? I can't believe that those basic features are actually lacking in finder.
    thanks!

    well, I think I see what the problem is.
    I usually use column view. In column view it is enough to single-click on a folder to open it. When you do that, a new column with that folder opens. When I double-click on a folder on the other hand, it behaves the way I want it to be (opens in the view I set for it). So it seems like I will have double-click every folder in order to behave it the way I want (annoying as well, but I guess there is no other solution).
    Btw, if I create a new folder on my desktop and change it's default view it works, because clicking on a folder on the desktop is pretty much the same as opening it in a new window.
    Thanks for your help though. If you have any idea if you can make the folders behave the right way by single-clicking than please let me know
    edit: ok, seems I was wrong. it worked for the desktop-folder, but doesn't seem to work for any other folder (it DOES work when cmd-double-clicking it though). strange.
    Message was edited by: nachdenki

  • Question about methods in a class that implements Runnable

    I have a class that contains methods that are called by other classes. I wanted it to run in its own thread (to free up the SWT GUI thread because it appeared to be blocking the GUI thread). So, I had it implement Runnable, made a run method that just waits for the thread to be stopped:
    while (StopTheThread == false)
    try
    Thread.sleep(10);
    catch (InterruptedException e)
    //System.out.println("here");
    (the thread is started in the class constructor)
    I assumed that the other methods in this class would be running in the thread and would thus not block when called, but it appears the SWT GUI thread is still blocked. Is my assumption wrong?

    powerdroid wrote:
    Oh, excellent. Thank you for this explanation. So, if the run method calls any other method in the class, those are run in the new thread, but any time a method is called from another class, it runs on the calling class' thread. Correct?Yes.
    This will work fine, in that I can have the run method do all the necessary calling of the other methods, but how can I get return values back to the original (to know the results of the process run in the new thread)?Easy: use higher-level classes than thread. Specifically those found in java.util.concurrent:
    public class MyCallable implements Callable<Foo> {
      public Foo call() {
        return SomeClass.doExpensiveCalculation();
    ExecutorService executor = Executors.newFixedThreadPool();
    Future<Foo> future = executor.submit(new MyCallable());
    // do some other stuff
    Foo result = future.get(); // get will wait until MyCallable is finished or return the value immediately when it is already done.

Maybe you are looking for

  • I use Time Machine to back up my iMac.  How can I copy some iPhoto events from my external hard drive to my MacBook?

    I back up my iMac on my external hard drive.  When trying to copy the iPhoto Library onto my MacBook, I get the message "Cannot use TM backup as main library".  I don't even see an option to choose certain Events to copy.  Is there any way I can choo

  • Wrong commitments value for a wbs element

    H Experts I have a WBS element and entered a PO commitment with subsequent partial GR and IRs. But my cooitment report does not get reduced with subsequent IRs and it got updated with first IR only. Please suggest what would be the reason for wrong c

  • Descrepency in BOM Report

    Dear All Please clarify the following discrepancy I found in BOM report in one of my Customer database:   Schenario - 1       Parent Item A  --  Qty 1 kg             Child Item B  --  Qty 1.2 kg        Parent Item B  --  Qty 1 kg               Child

  • Web dynpro - Download desktop file

    Hi guys, How to download desktop file data into application server in the Web dynpro application? Thanks.

  • My PSD CS6 have problem when show blue tone colour

    (Example from extract picture) When I use my photoshop CS6 I have problem of blue tone colour look like Gamut warning but when i save to jpg. or other export file it normally.