在开始 Android 开发之前我应该​​学习哪些设计模式

发布于 2024-10-18 16:33:03 字数 194 浏览 1 评论 0原文

除了了解 Java 之外,在开始研究 Android SDK 之前我还应该学习哪些设计模式?

编辑:我问这个问题的原因是,在查看了 sdk 之后,我认为(不确定)它大量使用适配器模式,并且我是想知道我是否可以知道它正在使用哪些其他模式,并且它可以帮助我的学习过程。

谢谢。

Other than knowing Java, what Design Patterns I should learn before I start looking into Android SDK?

Edit: The reason why I am asking this question, because after looking at the sdk, I think, not sure about that, that it is heavily using adapter pattern and I was wondering if I can know what other Patterns it is using and it can help in my learning process.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

白首有我共你 2024-10-25 16:33:03

从 Java 桌面编程到 Android 编程的最大飞跃之一是使用 XML 来设计和控制界面布局。如果您想研究 Android 系统的编程,我肯定会花一些时间来熟悉 XML。我对具体的设计实践不太熟悉,但是模型-视图-控制器系统在iOS开发中非常强调,如果Android程序也是如此,我也不会感到惊讶。

当然,开发者网站也是寻找任何资源的好地方:http://developer.android .com/index.html

我在周末参加编码比赛时发现的这篇文章也可能有助于您走上正确的道路
http://answers.oreilly.com/topic/ 1133-如何在android中开始编程/

One of the biggest jumps from going to desktop programming in Java to android programming is the use of XML to style and control interface layouts. I'd definitely take time to get comfortable with XML if you want to look into programming for the Android system. I'm not too familiar with exact design practices, but the model-view-controller system is very emphasized in iOS development, and I would not be surprised if the same goes for Android programs.

Of course, the developers site would be a great place to look too for any resources: http://developer.android.com/index.html

This article I found over the weekend while at a coding competition may also help get you going in the right path
http://answers.oreilly.com/topic/1133-how-to-start-programming-in-android/

尘世孤行 2024-10-25 16:33:03

无需学习任何设计模式即可开始使用 Android SDK(了解观察者/监听器模式可能会帮助您熟悉 Android 中的事件处理)。

显然,了解它们将有助于您理解 Api 某些部分背后的意图。

There is no need to learn any design pattern to start using Android SDK (may be knowing about the Observer/Listener pattern will help you getting familiar with event handling in Android).

Obviously knowing about them will help you understand the intentions behind some parts of the Api.

睫毛溺水了 2024-10-25 16:33:03

在我看来,你可以先开始编写代码,当你发现你的代码很丑或者发现自己编写了多余的代码时,你可以寻找设计模式来让你的设计变得更好。

In my opinion you can start writing code first, and when you find your code ugly or find yourself writing redundant code, you can look for design patterns to make your design better.

水水月牙 2024-10-25 16:33:03

Android 等高级框架本身往往遵循一组设计模式。这几乎就像您正在学习工作中的模式一样。一个很好的例子是 OnXXXListener 接口的发布者/订阅者模型。如果您遵循框架所规定的指导,它就会真正降临到您身上(当然,在我看来)。例如,我创建了一个颜色选择器视图。我希望视图(活动)的使用者能够接收诸如“选择颜色”之类的通知。我只是查看了 SDK 类如何执行此操作,并遵循它们的指导(使用 onColorSelected 方法创建 OnColorSelectedListener 接口,通过我的颜色选择器视图中的 setOnColorSelectedListener 公开此功能,等等)。

从 .Net 背景转向 Android/Java,我确实看到了差异。 .Net 有许多不同的设计模式,它们为您的自定义类提供了非常好的指导。好消息是,.Net BCL 和 Android SDK 背后的工程师在实现一些非常常见的设计模式方面做得非常出色,因此有很多很好的示例可供遵循。

High level frameworks such as Android tend to follow a set of design patterns themselves. It's almost like you're learning the pattern(s) on the job. A great example is the publisher/subscriber model of the OnXXXListener interfaces. If you follow the lead that the framework sets forth, it really just comes to you (in my opinion, of course). For example, I created a color chooser View. I want consumers of the View (Activities) to be able to receive notifications like "color selected". I simply looked at how the SDK classes would do this, and follow their lead (created an OnColorSelectedListener interface with an onColorSelected method, expose this functionality through setOnColorSelectedListener in my color picker View, etc).

Coming from a .Net background to Android/Java, I really see the differences. .Net has a lot of different design patterns throughout which provide very good guidance for your custom classes. The good news is, the engineers behind the .Net BCL and the Android SDK did a great job of implementing some very common design patterns so there are great examples to follow.

回心转意 2024-10-25 16:33:03

意见?就开始黑客攻击吧。 开发人员指南可以为您提供指导。

Opinions? Just start hacking. The Developers Guide can help guide you along the way.

顾北清歌寒 2024-10-25 16:33:03

我不认为将应用程序算法(模型)与事件处理代码(ActivityClass)和表示代码(XML)分开会出错。关键思想是关注点分离和松散耦合。

日航

I do not see how you can go wrong separating out your application algorithms (model) from the event handling code (ActivityClass) and presentation code (XML). The key ideas would be separation of concerns and loose coupling.

JAL

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文