Choose Your Tools with Care

本文探讨了现代应用程序构建中使用现有工具的重要性,包括组件、库和框架,并讨论了选择合适工具集时应注意的问题,如架构匹配、配置复杂性及供应商锁定等。

Modern applications are very rarely built from scratch. They are assembled using existing tools — components, libraries, and frameworks — for a number of good reasons:

  • Applications grow in size, complexity, and sophistication, while the time available to develop them grows shorter. It makes better use of developers' time and intelligence if they can concentrate on writing more business-domain code and less infrastructure code.
  • Widely used components and frameworks are likely to have fewer bugs than the ones developed in-house.
  • There is a lot of high-quality software available on the web for free, which means lower development costs and greater likelihood of finding developers with the necessary interest and expertise.
  • Software production and maintenance is human-intensive work, so buying may be cheaper than building.

However, choosing the right mix of tools for your application can be a tricky business requiring some thought. In fact when making a choice, there are a few things you should keep in mind:

  • Different tools may rely on different assumptions about their context — e.g., surrounding infrastructure, control model, data model, communication protocols, etc. — which can lead to an architectural mismatch between the application and the tools. Such a mismatch leads to hacks and workarounds that will make the code more complex than necessary.
  • Different tools have different lifecycles, and upgrading one of them may become an extremely difficult and time-consuming task since the new functionality, design changes, or even bug fixes may cause incompatibilities with the other tools. The greater the number tools the worse the problem can become.
  • Some tools require quite a bit of configuration, often by means of one or more XML files, which can grow out of control very quickly. The application may end up looking as if it was all written in XML plus a few odd lines of code in some programming language. The configurational complexity will make the application difficult to maintain and to extend.
  • Vendor lock-in occurs when code that depends heavily on specific vendor products ends up being constrained by them on several counts: maintainability, performances, ability to evolve, price, etc.
  • If you plan to use free software, you may discover that it's not so free after all. You may need to buy commercial support, which is not necessarily going to be cheap.
  • Licensing terms matter, even for free software. For example, in some companies it is not acceptable to use software licensed under the GNU license terms because of its viral nature — i.e., software developed with it must be distributed along with its source code.

My personal strategy to mitigate these problems is to start small by using only the tools that are absolutely necessary. Usually the initial focus is on removing the need to engage in low-level infrastructure programming (and problems), e.g., by using some middleware instead of using raw sockets for distributed applications. And then add more if needed. I also tend to isolate the external tools from my business domain objects by means of interfaces and layering, so that I can change the tool if I have to with just a small amount of pain. A positive side effect of this approach is that I generally end up with a smaller application that uses fewer external tools than originally forecast.

By Giovanni Asproni


This work is licensed under a Creative Commons Attribution 3

### 使用 OHPM 和 Migrate Assistant 迁移项目的步骤 在使用 OHPM(One Harmony Package Manager)和 Migrate Assistant 工具进行项目迁移时,需要确保工程已经适配了 OHPM 包管理,并按照特定的流程完成迁移。以下是详细的说明: #### 1. 确保工程适配 OHPM 包管理 如果您的工程是 NPM 管理的 API 8/9 工程,则需要先完成 OHPM 包管理的适配[^1]。这意味着您需要将现有的依赖从 NPM 转换为 OHPM 格式。OHPM 是华为提供的包管理工具,专为 HarmonyOS NEXT 设计,能够更好地支持一体化工程的依赖管理。 适配 OHPM 的具体操作包括: - 更新 `package.json` 文件以符合 OHPM 的规范。 - 替换原有的 NPM 模块为对应的 OHPM 模块。 - 确保所有依赖项都已正确安装并兼容 HarmonyOS NEXT。 #### 2. 启动 Migrate Assistant 工具 完成 OHPM 的适配后,可以通过 DevEco Studio 中的菜单栏启动 Migrate Assistant 工具。具体路径为: ```plaintext Tools > Migrate Assistant ``` Migrate Assistant 是一个自动化工具,旨在帮助开发者将历史工程迁移到最新的 HarmonyOS NEXT 版本。它会自动检测项目中的不兼容项,并提供修复建议或直接执行迁移操作。 #### 3. 自动化迁移过程 在 Migrate Assistant 页面中,工具会扫描您的项目并列出需要迁移的内容。这些内容可能包括但不限于: - 代码中的 API 升级。 - 配置文件的调整。 - 第三方库的替换或更新。 对于 API 10 及以上的历史工程,手动迁移可能较为复杂,因此推荐使用 Migrate Assistant 来简化此过程[^1]。工具会生成一份迁移报告,详细记录了迁移前后的变化以及任何潜在的问题。 #### 4. 解决迁移中的问题 如果在迁移过程中遇到问题,例如 DevEco Studio NEXT Developer Beta3 打开 HarmonyOS NEXT Developer Preview2 应用时出现报错,可以借助 Migrate Assistant 自动升级到 NEXT Developer Beta3 版本[^3]。这通常涉及以下操作: - 确保 DevEco Studio 的版本是最新的。 - 检查项目配置是否与目标版本兼容。 - 使用 Migrate Assistant 提供的修复功能解决不兼容问题。 #### 5. 验证迁移结果 迁移完成后,务必验证项目的功能是否正常。可以通过以下方式测试: - 构建项目并检查是否存在编译错误。 - 运行单元测试以确保核心功能未受影响。 - 在目标设备上部署应用并进行全面的功能测试。 以下是一个简单的代码示例,展示如何通过命令行验证 OHPM 的安装情况: ```bash ohpm --version ``` --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值