alibaba/BeeHive

方法注册是在load中好呢还是使用BeeHiveService(servicename,impl)好呢?两者有何区别

Closed this issue · 15 comments

服务的注册在beehive中有两种方式(不讨论plist),一种是在

+(void)load {
}

另一种是用(使用__attribute形式)

BeeHiveService(servicename,impl)

这两种有何区别呢?

load是在执行期注册到容器中的,但是,比类的加载稍微早一点。__attribute其实是一种注解方式,是在编译阶段注册到容器中的。个人觉得,本质并无差别。可能,注解稍微效率高那么一点点吧。

@MemoryReload 只是两种写法的不同而已,对吗?我一同事说load注册有问题,说现在都没有人用load注册,所以我就问下是这样吗?

One good suggestion for you: reading the source code, if feeling curious about that. : )

@MemoryReload Actually I have read the source code at all.

So, I’m confused why you’re doing this.

Because I'm curious.I wonder if you ask question after you have read other open source framework.Maybe you don't.

I'm not meaning to be offensive. But I have to tell you that I think your question is a little bit meaningless since you've read the source code. The differences between two strategies are obvious. If you think the load strategy is error-prone, just test it and give your error reproduction as an issue. Sincerely sorry to bother you and happy Children's Day. : )

Just two options, no need to tell explicitly which one is more preferable...

@MemoryReload I know the difference.I have this question because my workmate came from AliBaba.And he says in ALiBaba not use load to register service.
Sincerely sorry to bother you and happy Children's Day. : )

@MountainHill Well, in my opinion, his words are not reasonable. As I know, There's no problem when using load strategy to register a service. But maybe my test is not robust enough. And after all, That's all up to you to make your own decision.

@MemoryReload I get it.Thank you very much.

@MemoryReload Please close this issue.

@MountainHill Maybe, it's your responsibility to do that. You're the issuer.

应该是考虑到App的启动时间问题吧, 大量用load会拉长启动时间吧

你们绝了,中文聊着聊着切英语交流,目的是什么呢