论文标题
面向上下文的行为编程
Context-Oriented Behavioral Programming
论文作者
论文摘要
现代系统要求程序员开发动态适应不同上下文的代码,从而导致新的面向上下文的编程语言的演变。这些语言引入了新的软件工程挑战,例如:如何维护和保持代码库的关注点?如何建模不断变化的行为?如何验证系统行为?还有更多。 本文介绍了面向上下文的行为编程(COBP) - 一种用于开发上下文感知系统的新型范式,以上下文依赖性行为的自然和增量规范为中心。顾名思义,我们将行为编程(BP)(基于方案的建模范式)与上下文成语结合在一起,这些成语明确指定了何时相关的方案以及他们需要哪些信息。核心想法是将行为模型与代表上下文的数据模型联系起来,从而通过更新和选择查询在模型之间建立直观的连接。将行为编程与面向上下文的编程相结合带来了两个世界中最好的,可以解决在分离中使用每种方法时出现的问题。 我们首先为COBP提供抽象的语义,为将推理算法应用于上下文感知的行为程序奠定基础。然后,我们用系统的正式规格来体现语义,包括康威人生游戏的变体。最后,我们提出了基于JavaScript的实现范式的实现,并提供了使用此工具开发的现实生活环境感知系统(一种在机器人技术中,另一种是物联网中)的案例研究。在整个示例和案例研究中,我们提供了应对上述挑战的设计模式和方法。
Modern systems require programmers to develop code that dynamically adapts to different contexts, leading to the evolution of new context-oriented programming languages. These languages introduce new software-engineering challenges, such as: how to maintain and keep the separation of concerns of the codebase? how to model the changing behaviors? how to verify the system behavior? and more. This paper introduces Context-Oriented Behavioral Programming(COBP) - a novel paradigm for developing context-aware systems, centered on natural and incremental specification of context-dependent behaviors. As the name suggests, we combine behavioral-programming(BP) - a scenario-based modeling paradigm - with context idioms that explicitly specify when scenarios are relevant and what information they need. The core idea is to connect the behavioral model with a data model that represents the context, allowing an intuitive connection between the models via update and select queries. Combining behavioral-programming with context-oriented programming brings the best of the two worlds, solving issues that arise when using each of the approaches in separation. We begin with providing abstract semantics for COBP, laying the foundations for applying reasoning algorithms to context-aware behavioral programs. We then exemplify the semantics with formal specifications of systems, including a variant of Conway's Game of Life. Finally, we present a JavaScript-based implementation of the paradigm and provide two case studies of real-life context-aware systems (one in robotics and another in IoT) that were developed using this tool. Throughout the examples and case studies, we provide design patterns and a methodology for coping with the above challenges.