简体   繁体   English

要使用REST API,要实现哪种设计模式?

[英]What design pattern to implement in order to use a REST API?

I'm starting a new project that will require use an external REST API that basically returns JSON and XML files. 我正在开始一个新项目,需要使用基本上返回JSON和XML文件的外部REST API。 It's similar to the StackExchange API and I see every wrapper that has be done for that API has a different approach; 它与StackExchange API类似,我看到为该API完成的每个包装器都有不同的方法; for instance, stackoverflow-java-sdk uses the Adapter Pattern . 例如, stackoverflow-java-sdk使用适配器模式

So, in order to make sure every new API feature will be included easyly... what would be the best design pattern? 因此,为了确保每个新的API功能都能轻松包含在内......最好的设计模式是什么?

The Bridge pattern can be used to encapsulate two interfaces so they can vary independently. Bridge模式可用于封装两个接口,因此它们可以独立变化。 Sounds like what you're interested in. 听起来像你感兴趣的东西。

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

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