A Comparison between a Context-oriented Programming C# Framework and the Strategy Pattern

Bibliographic Information

Other Title
  • C#のためのコンテキスト指向プログラミングとStrategyパターンの比較

Search this article

Description

本発表では,C#に基づいたコンテキスト指向プログラムとStrategyパターンとの比較を行う.コンテキスト指向プログラミング(Context-Oriented Programming: COP)は,コンテキストに依存した振る舞いをモジュール化し,実行時にコンテキストに応じて動的にそれらのモジュールを変更するためのプログラミング技術である.Strategyパターンはオブジェクト指向プログラミング言語のデザインパターンの1つである.Strategyパターンではアルゴリズムの集合を定義し,各アルゴリズムをカプセル化することで実行時にそれらのアルゴリズムをコンテキストに応じて動的に交換可能とする.これらの手法はいずれもプログラム実行時のイベントに応じてモジュールの切り替えを可能とする点で類似している.以上をふまえて同一要求のシステムをCOPとStrategyパターンで開発し比較を行う.評価内容として,記述量および,コンテキスト依存の振る舞い記述の差異をあげ,それらの原因について分析,比較検討を行い評価する.本評価のために,実行時にコンテキストに応じて振る舞いが切り替わるロボットシステムを開発する.ロボットのコンテキストとして屋内外やゴミの種類を想定している.実現に際し,これらのコンテキストを見立てた環境を構築する.ロボットが室内にいるときは吸引機で吸引動作を行い,室外にいるときはブラシを使い掃き動作を行うものとする.上述した屋内外のシステム切り替え等により,コンテキスト切り替え部分に関して比較検討を行う.

The presentation introduces a comparison between our Context-Oriented Programming C# framework (COP C#) and the Strategy pattern. Context-Oriented Programming (COP) treats context-dependent behavior that is modularized as layers and to change them at runtime. On the other hand, the Strategy pattern deals with the algorithm modules for encapsulating for context-dependent behavior. In spite of different type of those modules, both techniques handle the context-dependent behavior. To make clear the difference between the COP C# and the Strategy pattern, we develop two cleaner robot systems based on their two ways. The behavior of those robots reflects in the contexts that depends on the places and the garbage sorts. Our robot provides a service that uses the vacuum cleaner part in rooms. If the robot moves to the outside of the room, it changes the service that makes operate the brush part. Those mechanisms give us the advantages of the COP C# and the Strategy pattern.

Journal

Keywords

Details 詳細情報について

Report a problem

Back to top