iPhone development - best practise for reusable functions
1) iPhone development - when to create a class library and when not to? (is there a best practise guide to explain this?)
2) Do you need to t开发者_JAVA百科ake a different approach when you decide to create a class library vs developing a web app or desktop app. Since iPhone app has many views is it better to duplicate functions from one view to another rather than create function libraries for reusable functions? (ie web service functions, should this be duplicated?)
3) Traditionally in a web application, desktop application, when you need to reuse a function more than 2 times, you might consider creating a library, but not all the time it really depends on the situation, is this still true for iPhone development?
A good rule of thumb is to ask yourself: will I use this in another project?
In my opinion, reusing functionality within different views in the same application is not enough of a good case for creating a library.
It's important to notice the differente in reuse between different apps (in which case it's good to create a library) and reuse inside the project (you solve it with good OO design)
You could check this link for a list of open-source iPhone libraries. You'll get an idea on what a library should consist of.
- We create a class library when it is useful. Not all classes make sense in a library, and not all libraries need to be created for a particular purpose. General rule (for me) goes something like: If you've had to rip something out of another thing because it was useful, to put it in another thing, odds are good you want to, during the code removal from the first thing, make it reusable.
- It may be a good idea, it's again, hard to answer this particular point in the abstract.
- That's true for many classes of problem domains, including iPhone development.
精彩评论