开发者

Objective-C and UML Modelling

We all know Objective-C method headers carry more information than standard Java method he开发者_Python百科aders....

This poses an issue when modelling using UML...Some method names are uncontrollably quite long...what is the best way to model these methods clearly in a UML class diagram?

Can you condense the method names, or write some Java style header for them?

I'm doing a report for a software system and I am stuck...


I think in some cases Objective-C headers carry less overall information, but they can show the interfaces more clearly.

For example - Using the modern Objective-C runtimes (for Mac OS and iOS) you don't need to declare private iVars, or private methods in the headers - they can be shifted to a category in the implementation file. You can even redeclare properties as readwrite in the implementation where they are declared as readonly in the header file.

This means that there is a lot more going on in a class than is shown in the header files, but the public interfaces are clearly defined separately from private implementation - which is a good thing in a UML diagram.

As for long method names - that's part of the convention of Objective-C. You can love it or loathe it (I personally love it). But in terms of writing them methods don't show their parameters. For example: suppose you have a method declared as:

- (NSString *)resultStringWithOptions:(NSDictionary *)options withCharacterSet(NSCharacterSet *)charSet error:(NSError **)error:

The actual name of this method is:

resultStringWithOptions:withCharacterSet:error:

Which is shorter.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜