Hey experienced programmers!
Id like to ask you something about clean code :)
Id like to keep my code clean and make it nice, so thats my questions:
1)Where should I put #imports? My principles: (and i dont think that they are good)
- #import Frameworks should be always in .h
- #import .h files should be always in .m
- .h files should have only @class, not imports (excluding frameworks like UIKit, etc)
Delegates should be in .m
@interface ViewController() <UIAlertViewDelegate> @end
2)Where should I put my instance variables?
- Private and Protected variables must be in .m
- Public must be in .h
3)Where should I put my methods?
- Public in .h
- Private in .m (And yeah I know that my "Private methods" are not really private, just hidden)
(btw thats pretty obvious)
4)What about #defines?
- Global - always in .h
- Used only in that class - always in .m
5)Where should I put NSNotification global identifiers and how to organize them
- #define NSNotificationDataSourceDidLoadData @"NSNotificationDataSourceDidLoadData" in .h file in the class that will send this notification
But ....
- Apple has a lot of private things in .h file
- In most cases my .h files are just.. EMPTY :)
A year ago I had another situation - everything was in .h, but I think it is bad also
What to do? What principles are you using? Thank you!
Thats a questions about coding style, not about "how to make it compilable"