I know that there are a lot of patterns like MVC, MVP, MVVP etc, I don’t want to discuss which is better here (it’s prohibited by StackOverflow’s rules), I just want to find out Apple’s latest vision on that patterns, including Swift and protocols.
I want to understand what operations Apple uses itself (e.g. in their own apps) in ViewController, what in Model and how they are splitting code.
I have found only very old documents on Apple’s web about Cocoa MVC, is there any new documents with Swift examples?
Where I can to get modern Apple’s pattern vision application examples? I don’t want sample «dirty» code, I want to find out sample finished application with correct coding patterns.
I'd suggest to take a look at the latest WWDC videos, namely Protocol and Value Oriented Programming in UIKit Apps
What they show there is reminiscent of Model-View-ViewModel (MVVM) approach. Their controller models are basically immutable view models.
It is hard to give a definitive answer without being affiliated with Apple. However, one may argue that Apple still promotes MVC incorporating Protocol-Oriented Programming.
Related
I need to develop a client application for a site that host and show images.
The client should shows all new images and take a picture and send to website.
I'm a newbie to iOS programming so this question:
In an application alike this, there's the need to create a Model? I ask this question because I think I can do anything with Controllers but maybe I'm wrong.
While there is never a "need" to create a model, it's good form to do so, and it'll likely save you many headaches down the road. Ultimately, you're going to need to deal with images and websites and how they interact with each other and whatnot, so you might as well do it in models from the outset.
I'm as guilty as anyone for wanting to see immediate results and hack together something quickly, but I always regret it later on, and have to spend more time than I'd expected refactoring it into something usable.
The MVC pattern as used in Mac OS and iOS applications isn't something best explained in an answer box but here's a link to some simple documentation about the roles of Models, Views and Controllers
Some good basic introductions to start with, which also have relevant links to the next stage of documentation are:
Cocoa Core Competencies
Cocoa Application Competencies for iOS
Read these excellent articles first. You'll learn better and faster if you do some basic reading.
I have an iphone app which is a tabbar based application. What is the design pattern of my app. Sorry for asking a fundamental question, i am not aware of design pattern.
Tabbar doesn't imply any design pattern. It is just UI element that represent some data.
Your app can use several design patterns. For example for data representation it is probably MVC (model-view-controller) pattern.
Read this link. As you can see there are tons of patterns and they are almost always mixed in your app.
A design pattern is just a commonly found approach to commonly occurring problems in computer science. It's usually used in reference to object-oriented programming design patterns such as those described by the Gang of Four. We could not identify the specific design patterns you used without looking at your code as a whole.
I was trying to find an answer for my question today using google and StackOverflow search engines... but no luck :)
I was wondering what are the key features of every framework for end user, and how can you characterize every framework from the end-user point of view (I've looked into Framework Design Guidelines by K. Cwalina, but I've found only concepts and guidelines for framework architects), for me:
it should be extensible
should let build extensible and reusable components
and of course : Simple things should be simple, complex things should be possible. (http://en.wikiquote.org/wiki/Alan_Kay)
I think there is much more out there.
Please share your knowledge.
Here are two good quotes from Ralph Johnson and Brian Foote
A framework is a reusable, ``semi-complete'' application that can be specialized to produce custom applications
One important characteristic of a framework is that the methods defined by the user to tailor the framework will often be called from within the framework itself, rather than from the user's application code. The framework often plays the role of the main program in coordinating and sequencing application activity. This inversion of control gives frameworks the power to serve as extensible skeletons. The methods supplied by the user tailor the generic algorithms defined in the framework for a particular application.
There was a special issue of CACM that you might want to take a look at too.
Here's one more link The Hollywood Principal. "Don't call us, we'll call you." About how the framework inverts the typical control so the framework calls your code instead of you calling some library code.
It sounds like you just want to know what is the defining characteristic of a framework...?
From FOLDOC:
In object-oriented systems, a set of classes that embodies an abstract design for solutions to a number of related problems.
So basically, a class library ("set of classes") that's extensible ("embodies an abstract design"),
I'll attempt a definition based on my own understanding: A framework is a body of code that abstracts a subset of tasks common to some classes of application programs. The intent is to provide, once, proven and tested code so that application programming doesn't have to keep re-inventing code for the common tasks handled by the framework.
In real life, frameworks often spring into being when a programmer or team get carried away with generalizing and future-proofing what started out as a single application. There's an honorable intent to start code re-use, but it often turns out that such frameworks aren't designed with intent from the beginning, don't have consistent design reflecting this intent, and are actually lousy code that ends up not being re-used at all. Most architects who feel qualified to create frameworks, aren't.
The difference between libraries and frameworks: You call libraries. Frameworks call you.
Answering your question covering the depth it deserves is beyond the scope of this forum. All you should do is read this book though its focused on .Net frmaework specifically and written by the designers of the .Net framework, I'm sure the wisdom and information that this book provides would be sufficient to answer your question and satisfy your curiosities on the subject.
Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries (2nd Edition)
alt text http://www.lybrary.com/images/0321605012.jpg
A Framework is for me a other name for a Library (like Boost and many others) that is not about only one Topic (there are Librarys about Math, Networking, whatever out there, but these are no Frameworks) and it is of course Extensible and you can combine the Features of it to do your Job.
I am developing an app, which is a huge project. I need to create an architecture for the app, so that I can reuse the code for another client (app will be template I will change UI only).
Thinking to apply singleton pattern, but there are some very good design pattern available like MVC, Factory, etc. How can I find out which is the best design patten I should implement in iPhone app? Or is there any code/tutorial available which explain with examples.
The iPhone is completely geared toward MVC, so that one's a no-brainer. Don't try to use another pattern to organize your app - it'll just become a hacked up mess. As far as other patterns go, Singleton is always a good one. If you make singleton objects that manage common behaviors (networking, for example), you can reuse them in other projects pretty easily.
Custom views are also easy to re-use. If you create a custom UIView subclass for part of your UI and define Objective-C protocols for it's data source and delegate interactions (the points where it is tied into your controller and model), you should be able to take them with you to future projects.
Also consider using Core Data to store the "Model" part of your MVC app. Core Data is an ORM that is built into the iPhone platform. It allows you to store everything in an SQLLite database while working with Objective-C objects in your code. It's really handy if you're creating lots of apps with the same data or with the same UI but different data. (aka all those "fans of XYZ" apps!)
That's such a vague question that the only possible answer is "a good one."
You already have a choice of templates when you start a new iPhone app in Xcode. Those suggest architectures...
Also, if you want a good overview of the design patterns underlying Cocoa, I would suggest picking up the book Cocoa Design Patterns by Erik Buck and Donald Yacktman.
Does anyone know of one? If it doesn't exist, anyone interested in collaborating to create it?
The delegate pattern is a design pattern that is pretty central to making the most of a number of UIKit classes. Apple's developer documentation pages (example) would be good web resources that collect information about related methods.
EDIT: Here's a page on Cocoa implementations of the observer pattern. Here's a book on Cocoa implementations of design patterns. With respect to iPhone development, KVO Cocoa bindings haven't yet been implemented.
Update:
Also see: http://www.cocoacontrols.com/
Best site so far is here, and http://www.iphoneexamples.com/
Others are iosdevelopertips.com, iphonedevsdk.com, iphone.zcentric.com, and of course the official Apple Dev forums.
I've come across many (mostly barcamp) communities who begin such efforts but haven't had the time to follow through. I would agree such a site would be useful because there are many challenges cocoa touch presents which aren't present with OS X (memory, performance, no background processes, etc.).
I can only come to the conclusion that everyone is under their employer/client NDAs and/or everyone is too busy to create such a site!