一些功能性编程结构可以减少Debugability? [英] Do some Functional programming constructs reduce Debuggability?

查看:189
本文介绍了一些功能性编程结构可以减少Debugability?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我听说以下功能降低了可调试性(因为它们是匿名的,调试器无法很好地跟踪它)

I've heard that the following features reduce debuggability (because they are anonymous and debuggers cannot trace it well)


  1. 匿名类

  2. 内部类

  3. 关闭块/ Lambda函数

这是真的吗?

推荐答案

已经有一些很好的答案关于你已经提出的特定功能。

There are already some good answers regarding the particular features you have called out.

一般来说,我会说,一些FP功能以及更多FP风格的编程方面,至少与调试体验互动。例如,使用高阶函数,可以免费编程。当这样做时,这会减少标识符,这意味着例如。在调试器的本地窗口中可以轻松查看更少的东西。关闭通常是不透明的,直到你进入他们的身体。

In general, I would say that some FP features, as well as aspect of programming in a more FP style, do at least 'interact' with the debugging experience. For example, using higher-order functions, one can program in point-free style. When you do so, this leaves fewer identifiers, which means e.g. fewer things that can easily be inspected in the 'locals' window of a debugger. Closures are typically opaque until you step into their bodies.

FP还使用大量的反转控制结构(懒惰评估只是一个,地图或迭代而不是foreach是另一个),这改变了控制流程,并且可以影响单步的工作方式。

FP also uses lots of inversion-of-control constructs (lazy evaluation being just one, a 'map' or 'iter' rather than a 'foreach' being another), which changes the control flow and can impact how 'single-stepping' works.

随着FP变得越来越普遍,我期望调试工具将不断改进。我不清楚一些FP是否固有地更难调试,但是即使是这样,不要忘记关于FP的原因,使得您的代码不太可能首先需要调试。 :)

As FP becomes more common, I expect that the debugging tools will continue to improve. It is unclear to me whether some FP is 'inherently' harder to debug, but even if that is true, don't forget that much about FP makes your code less likely to need debugging in the first place. :)

这篇关于一些功能性编程结构可以减少Debugability?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆