【24h】

How Swift Developers Handle Errors

机译:Swift开发人员如何处理错误

获取原文

摘要

Swift is a new programming language developed by Apple as a replacement to Objective-C. It features a sophisticated error handling (EH) mechanism that provides the kind of separation of concerns afforded by exception handling mechanisms in other languages, while also including constructs to improve safety and maintainability. However, Swift also inherits a software development culture stemming from Objective-C being the de-facto standard programming language for Apple platforms for the last 15 years. It is, therefore, a priori unclear whether Swift developers embrace the novel EH mechanisms of the programming language or still rely on the old EH culture of Objective-C even working in Swift. In this paper, we study to what extent developers adhere to good practices exemplified by EH guidelines and tutorials, and what are the common bad EH practices particularly relevant to Swift code. Furthermore, we investigate whether perception of these practices differs between novices and experienced Swift developers. To answer these questions we employ a mixed-methods approach and combine 10 semi-structured interviews with Swift developers and quantitative analysis of 78,760 Swift 4 files extracted from 2,733 open-source GitHub repositories. Our findings indicate that there is ample opportunity to improve the way Swift developers use error handling mechanisms. For instance, some recommendations derived in this work are not well spread in the corpus of studied Swift projects. For example, generic catch handlers are common in Swift (even though it is not uncommon for them to share space with their counterparts: non empty catch handlers), custom, developerdefined error types are rare, and developers are mostly reactive when it comes to error handling, using Swift's constructs mostly to handle errors thrown by libraries, instead of throwing and handling application-specific errors.
机译:Swift是Apple开发的一种新的编程语言,用于替代Objective-C。它具有复杂的错误处理(EH)机制,该机制提供了其他语言中的异常处理机制所提供的关注点分离,同时还包括提高安全性和可维护性的结构。但是,Swift也继承了源于Objective-C的软件开发文化,在过去15年中,Objective-C是苹果平台的事实上的标准编程语言。因此,Swift开发人员是否接受编程语言的新颖EH机制,还是在Swift中工作仍依赖于Objective-C的旧EH文化,这是一个先验先验。在本文中,我们将研究开发人员在多大程度上遵守EH指南和教程所举例说明的良好实践,以及与Swift代码特别相关的常见不良EH实践是什么。此外,我们调查了新手和经验丰富的Swift开发人员对这些实践的看法是否有所不同。为了回答这些问题,我们采用了混合方法,并结合了10个与Swift开发人员的半结构化访谈以及对从2,733个开源GitHub存储库中提取的78,760个Swift 4文件的定量分析。我们的发现表明,有很多机会可以改善Swift开发人员使用错误处理机制的方式。例如,这项工作中提出的一些建议在研究的S​​wift项目中并未得到很好的推广。例如,通用的catch处理程序在Swift中很常见(即使与其他对象共享空间也很常见:非空catch处理程序),自定义,开发人员定义的错误类型很少见,而开发人员在出错时大多是被动的处理,使用Swift的结构主要是处理库抛出的错误,而不是抛出和处理特定于应用程序的错误。

著录项

相似文献

  • 外文文献
  • 中文文献
  • 专利
获取原文

客服邮箱:kefu@zhangqiaokeyan.com

京公网安备:11010802029741号 ICP备案号:京ICP备15016152号-6 六维联合信息科技 (北京) 有限公司©版权所有
  • 客服微信

  • 服务号