简体   繁体   English

在 Java (Android) 中实现“服务器”class 的最佳方式

[英]Best way to implement a “server” class in Java (Android)

I'm doing an application for Android.我正在为 Android 申请。 One of my classes is Sound which offers methods like playAlarm() and playSong(String name) .我的课程之一是 Sound,它提供了playAlarm()playSong(String name)等方法。 Whats the best way to implement that kind of class, as an object accessed with a singleton or as a static class with those static methods? Whats the best way to implement that kind of class, as an object accessed with a singleton or as a static class with those static methods? From the point of view of app perfomance in Android.从 Android 中的应用性能来看。

There is probably little difference in performance but using a singleton instead of static methods will make it easier to unit test.性能上可能几乎没有差异,但使用 singleton 而不是 static 方法将使单元测试更容易。

Barry巴里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM