[英]Static vs dynamic type-checking in a large SPA frontend?
If I want to use static type-checking, I need to choose some of the existing solutions like Flow or TypeScript.如果我想使用静态类型检查,我需要选择一些现有的解决方案,比如 Flow 或 TypeScript。 Then I need to align my code to the offered rules.然后我需要将我的代码与提供的规则对齐。 The advantage is I have instant error highlights in the IDE, fail quick and early, as well as these are powerful and mature tools.优点是我在 IDE 中有即时错误高亮显示,快速和早期失败,而且这些都是强大而成熟的工具。
If I want to do dynamic checking, I need to build my own tools that will run inside the app on each method call where I need to be sure it receives correct input parameters.如果我想进行动态检查,我需要构建我自己的工具,这些工具将在每个方法调用时在应用程序内运行,我需要确保它接收到正确的输入参数。 The advantage is that I have full control on my code and I don't have to follow the others' rules if I don't like them.优点是我可以完全控制我的代码,如果我不喜欢其他人的规则,我就不必遵守他们的规则。 The disadvantage is it can be time-consuming to develop and test it and slow in action, as well as I can make conceptual mistakes that will force me to spend time not on the logic of the app but on improving my home-grown schema-checker system.缺点是开发和测试它可能很耗时,而且动作缓慢,而且我可能会犯概念性错误,这将迫使我把时间花在改进我自己的架构上而不是应用程序的逻辑上——检查器系统。
Which approach should I use if I plan that the app will be developed by a team and have a long lifecycle?如果我计划该应用程序将由团队开发并且具有很长的生命周期,我应该使用哪种方法?
Which approach should I use if I plan that the app will be developed by a team and have a long lifecycle?如果我计划该应用程序将由团队开发并且具有很长的生命周期,我应该使用哪种方法?
A lot goes into creating tools.很多东西都涉及到创建工具。 I'm personally leveraging all the effort already put in by the TypeScript team into creating something that exposes its full power in the form of alm IDE.我个人正在利用 TypeScript 团队已经投入的所有努力来创建一些以alm IDE 的形式展现其全部功能的东西。
Where you draw the line between using whats there and creating something new is your choice.在使用现有内容和创造新事物之间划清界限是您的选择。 I just like the consolidation and went full in with TypeScript.我只是喜欢整合并完全使用 TypeScript。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.