分离大型客户端库/ SDK设计模式 [英] Separating large client library/sdk design pattern
本文介绍了分离大型客户端库/ SDK设计模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在实现一个具有大量操作的API sdk,并希望通过对某些操作进行分组将其拆分为更易于管理的类。
I am implementing a API sdk that has a huge number of operations and want to split it into more manageable classes by grouping certain operations.
我发现的一种常见方式就像这样:
One common way I found is something like this:
public class TwitterTemplate extends AbstractOAuth1ApiBinding implements Twitter {
private TimelineOperations timelineOperations;
private UserOperations userOperations;
private FriendOperations friendOperations;
private ListOperations listOperations;
private SearchOperations searchOperations;
private DirectMessageOperations directMessageOperations;
private BlockOperations blockOperations;
所以我为每个操作组创建一个类,并将每个组包含在一个包含类中
So I create an class for each group of operations and hold each group within a containing class
此模式是否有名称?
推荐答案
RESTful看起来是您的最佳选择,将您的操作拆分为资源操作,例如(Users ,朋友,消息,块),然后在资源上使用CRUD /查询应涵盖所有操作。
RESTful looks the best choice for you, Split your Operations into resource Operations such as (Users, Friends,Messages, Blocks), Then using CRUD/Query on the Resource should cover all the Operations.
这篇关于分离大型客户端库/ SDK设计模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文