社交媒体文件传输的最佳设计模式

发布于 2024-08-27 10:15:55 字数 340 浏览 2 评论 0原文

我们的系统希望我们的客户将他们的帐户与不同的社交媒体网站(例如 youtube、vimeo、facebook、myspace 等)链接。

我们希望为用户提供的好处之一是传输、更新和删除他们上传到我们网站的文件,并将它们传输到上述社交媒体网站。该文件可以是视频、图像或音频。

我们开始考虑使用策略模式,因为所有这些站点共享一个公共流程(身份验证、连接、使用 API 传输/编辑/删除文件),但我们很快意识到它可能无法像我想要的那样工作使用特定于每个服务的一些扩展功能(例如:将 YouTube 视频与频道关联,或将图像上传到 Facebook 上的特定相册,等等……)

我的问题是,什么是用于这种情况的最佳结构设计模式?

Our system would like our clients to link their accounts with different social media sites like youtube, vimeo, facebook, myspace and so on.

One of the benefits we would like to give to the user is to transfer, update and delete files they have uploaded to our sites and transfer them to the social media sites mentioned above. this files could be videos, images or audio.

We started thinking about using a strategy pattern, as all of these sites share a common process ( authentication, connection, use the API to transfer/edit/delete the file ), but we soon realized that it may not work as me may want to use some of the extended functionality that is specific to each service (eg: associate a youtube video with a channel, or upload images to a specific album on facebook, and much, much more...)

My question is, what would be the best Structural Design Patter to use for this scenario?

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

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

发布评论

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

评论(1

青春如此纠结 2024-09-03 10:15:55

实际上,我会将您尝试将用户连接到的服务分成几组,例如:

  • 视频服务
  • 照片服务
  • IM 服务等。

对于每个组,您可能有一个要实现的通用接口。当然,每个社交媒体网站可以有多个界面。此外,我还会向这些接口添加一个特殊的扩展点,以便您可以重用每个站点特定的内容。

例如,在标准形式中,您将使用此方法:

videoService.upload(chanel, playlist, file) 

如果站点支持无法放入通用接口的特殊内容,则使用扩展属性调用它:

if (videoService.getSiteName() == "YouTube") {
   videoService.upload(chanel, playlist, file, extendedProperties) 
}

I would actualy split services that you try to connect your users to into groups like:

  • Video services
  • Photo services
  • IM services etc.

For each group you may have a common interface that you will implement. Of course, each social media site can have several interfaces. Also I would add a special extention points to those interfaces that will allow you to reuse something that is specific for each site.

For example, in standard form you will use this method:

videoService.upload(chanel, playlist, file) 

If site supports something special that you can't put into common interface, then call it with extended properties:

if (videoService.getSiteName() == "YouTube") {
   videoService.upload(chanel, playlist, file, extendedProperties) 
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文