Arc migration with bad naming standards

I am dealing with a code base where naming standards are usually ignored. Thus, some classes have methods that return objects with a reference number of 1, even if the method name does not match NARC. Fantastic stuff.

I would like to convert the project to use automatic reference counting, but I'm a little nervous about the fact that the NARC naming standards were generally ignored. Does anyone know if ARC correctly relies on NARC naming standards?

Thanks,

Sean

+6
source share
2 answers

ARC relies on naming conventions to work correctly. However...

If you used ObjC objects, then it will usually "work" if you only have ARC code. For example, if you have a method like:

- (id)something { return [[Something alloc] init]; } 

This is incorrect (in code other than ARC), but ARC will balance it by adding an extra autorelease . In fact, the above is the correct ARC code, so this is normal.

My suggestion, if this is almost all of ObjC code, is to automatically convert to ARC and then run a static analyzer. The problem can be much less than what you fear if it is a fairly simple code that just has bad names.

If this is a very shortened Core Foundation code, things are a little more complicated. Then I would recommend that you first run the static analyzer and get the right to naming right before converting. Fortunately, naming conventions are something that a static parser is very good at.

+8
source

I had to convert several projects to ARC and so far have never encountered any problems directly due to naming conventions.

In fact, the transformation is really straightforward, so when I fully understand your state of mind regarding the code that you have to deal with, I would not worry too much.

Until now, I have never encountered any serious difficult situation during the conversion, since the code to be converted was primarily correct and somehow understandable.

In fact, using ARC, I believe that the problem is no problem, like any other language with built-in GC - on memory issues, of course!

In the worst case scenario, you can always run a static analyzer, but even this is rarely required at present with ARC.

Probably the most critical situation is discussed here: What leaks does automatic reference counting in Objective-C not prevent or minimize?

+3
source

Source: https://habr.com/ru/post/926141/


All Articles