敏捷是cmm的替代品

    科技2025-03-14  19

    敏捷是cmm的替代品

    Fuel is not an alternative for Retrofit because both the libraries offer a different experience for developers. Retrofit is currently the market standard so let us look into Fuel.

    Fuel不是Retrofit的替代方案,因为这两个库为开发人员提供了不同的体验。 改造是目前的市场标准,因此让我们研究一下Fuel。

    什么是燃油? ⛽ (What is Fuel ? ⛽)

    The easiest HTTP networking library for Kotlin/Android by Kittinun Vantasin

    Kittinun Vantasin提出的Kotlin / Android最简单的HTTP网络库

    Offers maven and jitpack installation

    提供Maven和jitpack安装 Has a wide range of extension modules for every possible tool

    具有各种扩展模块,适用于每种可能的工具

    Uses httpUrlConnection (No Okhttp support; yet)

    使用httpUrlConnection (尚无Okhttp支持;尚未)

    Kotlin- first library

    Kotlin第一图书馆

    Fuel在市场中是🆕图书馆吗? (Is Fuel a 🆕 Library in the market ?)

    I had a quick look at the release tags in Github and the first tag 0.6 was dated 11 Aug 2015. Its been around for quite some time now. With the domination of Retrofit and Volley, it’s quite a struggle for Fuel to stand out

    我快速浏览了Github中的release标签,第一个标签0.6发布于2015年8月11日。它已经存在了一段时间。 在Retrofit和Volley的统治下,Fuel脱颖而出颇为艰难

    Retofit tag 0.6.0RC1 — 31 Aug 2013

    Retofit标签0.6.0RC1 — 2013年8月31日

    让我们谈谈燃料 (Lets talk Fuel)

    Fuel is built to be kotlin-esque. Fuel tries to fill in a different role which is to be the easiest or the most kotlin-esque to the project that already Kotlin as the main language.

    燃料采用Kotlin风格制造。 Fuel试图以另一种角色扮演角色,这对于已经以Kotlin为主要语言的项目来说,是最简单或最kotlin风格的。

    “We used to care on how the usage on the Java would be that that is no longer because we know entirely that if the Java users want to depend on the networking library, there are much better choices than us out there to use (and we don’t try to compete that)” — Vantasin

    “我们过去一直在关注 Java的使用方式,这不再是因为我们完全知道,如果Java用户希望依赖网络库,那么有比我们更好的选择可供使用(而且我们不要尝试与之竞争)” —万塔辛

    Fuel aims to be on the easy-to-use side but not on the fast side. They believe that Fuel will not win a race of performance but at the same time, it will not be a bottleneck in the application.

    Fuel的目标是易于使用,而不是快速。 他们认为Fuel不会赢得性能竞赛,但与此同时,它不会成为应用程序的瓶颈。

    发出请求 (Making Requests)

    Fuel provides a String extension to make a request. In addition and as an alternative, we can use the Fuel class that has a method for each HTTP verb.

    Fuel提供了String扩展来发出请求。 另外,作为替代方案,我们可以使用Fuel类,该类具有用于每个HTTP动词的方法。

    Fuel supports all HTTP verbs except for PATCH. It’s obvious as Fuel’s HttpClient is a wrapper over HttpUrlConnection which doesn’t support PATCH.

    Fuel支持除PATCH之外的所有HTTP动词。 很明显,因为Fuel的HttpClient是HttpUrlConnection的包装,该包装不支持PATCH。

    核心软件包中的扩展和功能 (The extensions and functions in the core package)

    Fuel supported functions and extensions 燃油支持的功能和扩展

    组态 (Configuration)

    FuelManager.instance is the singleton object used by Fuel to manage global configuration. This makes it possible to configure a base path, headers, common params and interceptors.

    FuelManager.instance是Fuel用于管理全局配置的单例对象。 这样就可以配置基本路径,标头,公共参数和拦截器。

    代码复杂度 (Code Complexity)

    Retrofit is easy to understand but Fuel is simpler. Check out their documentation for a better understanding.

    改造很容易理解,但是加油更简单。 查看他们的文档以获得更好的理解。

    燃油比翻新更好吗? (Is Fuel better than Retrofit ?)

    Definition by the creators:Retrofit: A type-safe HTTP client for Android and Java.Fuel: The easiest HTTP networking library for Kotlin/Android.By definition, Fuel is Kotlin first and they offer a different experience.

    创建者的定义:改进:适用于Android和Java的类型安全的HTTP客户端。 Fuel: Kotlin / Android最简单的HTTP网络库。根据定义,Fuel首先是Kotlin,它们提供了不同的体验。

    Making an apple to apple comparison between Retrofit and Fuel is out of the question. Fuel clearly states that they don’t wish to compete with any of the other libraries out there.

    毫无疑问,Retrofit和Fuel之间很难进行比较。 Fuel清楚地表明,他们不希望与那里的任何其他图书馆竞争。

    We don’t have to compare something which does not want to be compared. I would say comparing Fuel with Retrofit is like comparing a Polaroid camera with a Professional camera. They both give us different experiences, even though both are used for photography.

    我们不必比较那些不想被比较的东西。 我想说,将Fuel与Retrofit进行比较就像将Polaroid相机与Professional相机进行比较。 即使两者都用于摄影,它们都给我们带来不同的体验。

    Similarly, Fuel and Retrofit have different objectives. Fuel clearly mentions that it does not benchmark any stats for comparisons. They are clear in their objectives.

    同样,加油和改装具有不同的目标。 Fuel明确提到,它没有将任何统计数据作为基准进行比较。 他们的目标很明确。

    值得一提 (Worthy Mention)

    The Result from kittinunf is a functional style data structure that represents data that contains result of Success or Failure but not both. It represents the result of an action that can be success (with result) or error.

    kittinunf的结果是一种功能样式数据结构,该数据结构表示包含成功或失败但不同时包含两者的数据。 它表示可以是成功(有结果)或错误的操作的结果。

    Working with result is easy. You could fold, destructure as because it is just a data class or do a simple when checking whether it is Success or Failure.

    处理结果很容易。 您可以将其折叠 , 解构 ,因为它只是一个数据类,或者when检查它是成功还是失败 when都可以做一个简单的事情。

    TL; DR (TL;DR)

    Fuel networking library is not a game-changer and not a competitor to Retrofit. Fuel believes that it can do the best on the goal that they aim and provide something different in the market for developers to use. It’s up to us to try it out and evaluate what works best for our use case.

    Fuel网络库不是改变游戏规则的人 , 也不是Retrofit的竞争对手 。 Fuel认为,在他们的目标上,它可以做到最好,并为开发人员提供市场上一些与众不同的东西。 由我们来尝试并评估哪种方法最适合我们的用例。

    Personal Note: ✍️I started using Fuel in a small project to check what it has to offer. It was easy to get started. It was almost zero learning curve for someone who loves Kotlin and Functional programming.

    个人说明: ✍️ 我开始在一个小项目中使用Fuel来检查它所提供的功能。 很容易上手。 对于热爱Kotlin和函数式编程的人来说,这几乎是零学习曲线。

    翻译自: https://medium.com/swlh/is-fuel-an-alternative-for-retrofit-f81bd4505a87

    敏捷是cmm的替代品

    相关资源:asp.net知识库
    Processed: 0.010, SQL: 8