If you notice that you are copying what you wrote or encountering existing written code, consider creating an interface (object, set of functions, etc.) to solve these problems.
see DRY (do not repeat yourself). by the time of writing several applications there will be many duplicate functions. itβs better to write it once and write it down correctly.
Here are a few high-level recommendations:
Do not host application-specific functions in a common interface (use a subclass shared by two projects instead)
always keep your databases without hacks (unless you are faced with a problem in system libraries). if clients (for example, subclasses, callers) require a specific workaround or a specific check is required, then it is better to get them to handle it.
use statements to make sure they use the interface as intended, check each argument, precondition / postcondition, the state of your object, etc.
keep your objects / interfaces very small and maintainable, with the clear purpose of their intended use. Naturally, this will lead to an increase in the number of objects.
Avoid the urge to use single and static data there is almost always a better way, even if it is as simple as making clients instantiate your class.
Create libraries with these interfaces and logically separate them.
now that it has covered ...
I will start by using (potentially multiple) instances of the objects you need. there is nothing in the documentation that says: "You must not create multiple instances of the object."
if this is somehow inadequate in profiling, then consider using a shared object that sends messages to objects (in your application) that need updating.
Rationale: Most likely, the apple has already optimized the implementation, so you do not need to.
finally, I violated these recommendations in an application that required a ton of placement requests and displayed a ton of location information. the application used some static data behind the interface, which was stored by the location manager and location (among other things). so I ended up using static data with private (hidden) static data in order to reduce the amount of memory and CPU requirements in this case.
justin
source share