在Android中使用的API设计模式 [英] Design patterns used in Android apis

查看:140
本文介绍了在Android中使用的API设计模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们对设计模式类的类家庭作业。在我们必须解释任何API /框架的人使用设计模式。我在想,如果我可以使用Android的API做同样的。我知道,Android使用一些命令,观察者,模板方法模式等等,但是这将是巨大的,如果有人可以点我到起始参考文献左右。

We have a class home work for design pattern class. In that we have to explain anyone design pattern used in any api/framework. I was thinking if I could do the same using Android apis. I know that android uses some command, observer, template method patterns and many more but it would be great if someone could point me to the starting reference document or so.

感谢你这么多提前。

推荐答案

框架几乎可以肯定倾向于实施高层次的模式,如MVC或ORM模式。这些都不是盖在GOF的文本,但你会发现他们在其他花纹的书籍,如Martin Fowler的模式企业应用架构的。一些GOF模式是在框架甚至语言水平(实现如C#事件/代表为观察的一个例子图案),但大多GOF模式都留给了个别开发人员来实现根据需要,作为细节往往是应用或特定于域的。

Frameworks almost by definition tend to implement high-level patterns such as MVC or ORM patterns. These are not covered in the GOF text, although you will find them in other pattern books such as Martin Fowler's Patterns of Enterprise Application Architecture. Some GOF patterns are implemented at the framework or even language-level (like C# events/delegates as an example of the Observer pattern), but mostly GOF patterns are left to the individual developer to implement as needed, as the details tend to be application or domain-specific.

Android是相同的方式。它具有模型 - 视图 - 控制器的特殊风味内置的,但没有太多具体的GOF-模式。你可能会考虑活动生命周期回调(在onStart,onResume等)作为一种Observer模式,虽然只用一个专用的用户。

Android is the same way. It has a specific flavor of Model-View-Controller built in, but not too many GOF-specific patterns. You might consider the Activity lifecycle callbacks (onStart, onResume, etc.) as a kind of Observer pattern, although with only one dedicated subscriber.

另一个例子是 AsyncTask的,这可以被视为一个物种的命令模式。我将让你来进行连接。它毕竟是家庭作业。

Another example might be AsyncTask, which could be considered a species of the Command Pattern. I'll leave it to you to make the connection. It is homework after all.

这篇关于在Android中使用的API设计模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆