I have a class which represents exam,it can start/reset/pause exam, so the methods look like:
- (void)startExam;
- (void)resetExam;
- (void)pauseExam;
But as far as I know, if the method name ends with some noun, it should have argument for that noun, something like:
- (void)startExam:(Exam *)exam;
But in this case, the class is named ‘Exam’, so when the class is used, people would know that the object is an Exam, so it seems the better way of naming is:
@interface Exam : NSObject
- (void)start;
- (void)reset;
- (void)pause;
@end
so I can use is as:
Exam *exam = [[[Exam alloc] init] autoreleased];
[exam start];
which looks better than:
[exam startExam];
or
[exam examStart];
But this does look TOO generic, and I feel risky as NSObject(or whatever super class) may have methods of the same name added in the future, for example, Java Object has notify, notifyAll, wait, and subclass should not overwrite these for other purposes. Is this also true in Objective C?
So what is the best naming convention in this case?
Thanks!
start/pause/reset belong to the class
Exam. So I would go for:When I am using an object of the Class
ExamI just read it in my head:For me makes more sense than this:
As for the one that has an input parameter:
PS: But I could see myself doing what Dirk suggested.