Proceedings Template - WORDwseas.us/e-library/conferences/2005salzburg/papers/492 …  · Web...

14
The Design of Algorithm Translation Package Using UML

Transcript of Proceedings Template - WORDwseas.us/e-library/conferences/2005salzburg/papers/492 …  · Web...

Page 1: Proceedings Template - WORDwseas.us/e-library/conferences/2005salzburg/papers/492 …  · Web viewIn practice, however algorithm design is commonly ignored by programmers. Most novice

The Design of Algorithm Translation Package Using UML

Page 2: Proceedings Template - WORDwseas.us/e-library/conferences/2005salzburg/papers/492 …  · Web viewIn practice, however algorithm design is commonly ignored by programmers. Most novice

NORAIDA HAJI ALI, MASITA @ MASILA ABDUL JALIL AND MUSTAFA MAT DERIS Department of Computer Science

Faculty of Science and TechnologyUniversity College of Science and Technology Malaysia (KUSTEM)

21030 Kuala Terengganu, TerengganuMALAYSIA

Page 3: Proceedings Template - WORDwseas.us/e-library/conferences/2005salzburg/papers/492 …  · Web viewIn practice, however algorithm design is commonly ignored by programmers. Most novice

Abstract:- The aim of this project is to develop software called Algorithm Translation Package. The main purpose of this package is to automatically convert users’ edited algorithm code in Malay Language into C source code. This package also reduces the users’ time consumption to translate the algorithm code into C source code manually. Besides, user also have the opportunity to learn the C programming language through the package output because the C source code is generated automatically from the algorithm code. Moreover, details of each step taken to solve the problem, which is designed by the user, can also be included in the source code. This paper will also look at the project design. Generally, this package is designed using the Object-Oriented Software Development Life Cycle. Concept compilers like syntax analysis, semantic analysis and lexical analysis are also applied in order to detect any errors associated with the algorithm coding. The package features a user friendly and easy to understand interface. This Algorithm Translation Package has many advantages and is expected to benefit the C Language programmers especially students that are new to C programming.

Keywords:-Unified Modeling Language, Object Oriented Software Development Life Cycle, Use Case Diagram, Activity Diagram.

1 Introduction

In all industrialized countries and increasingly in developing countries, a computer system is economically critical. Computers have become the most important things and common tools in all areas of life.

Generally, a computer by itself cannot perform a task without a software or program. Programs are the instructions that tell the computer how to process data into the form we want [7]. However, writing a program does not simply means to write a list of instructions, rather all aspects related to problems to be solved need to be considered beforehand. Only then, program development and management can be more meaningful [10].

As shown in Fig. 1, the first step in program development is to clearly define the problem and then to design an algorithm to solve it [7, 13]. Algorithm here can be defined as a step-by-step procedure that clearly explains a systematic ways of solving a problem within a definite time frame. At each step, the action to be executed must be uniquely identified by the instruction and data obtained at that particular time [13].

Fig. 1 Program Development FlowIn practice, however algorithm design is

commonly ignored by programmers. Most novice programmers jump straight into writing the program without first looking at and building the algorithm [3, 8].

This approach proves to consume more development time when it comes to debugging errors, editing and maintenance. These problems may be avoided if more focus could be given to the algorithm development [7, 10]. Once the algorithm has been designed, it will then be translated into the actual coding based on the syntax of the chosen programming language.

The Algorithm Translation Package (ATP) that has been developed therefore aims to assist programmers, particularly students taking C programming in designing the algorithm. Once it is designed, the ATP will automatically translate it into the corresponding C source code, hence greatly reduces users’ development time. In addition, the generated source code from this package can be readily compiled and executed.

It is hoped that ATP could improve user’s programming skills while at the same time focusing

Problem definition

Algorithm design

Edit source code file

Compile source file

Connect object file

Test and debug

Page 4: Proceedings Template - WORDwseas.us/e-library/conferences/2005salzburg/papers/492 …  · Web viewIn practice, however algorithm design is commonly ignored by programmers. Most novice

more on the design of an efficient algorithm. Indirectly, the package could cultivate the right program development steps to programmers to be. In addition, through the output of this package, students may found it much easier to learn the C language.

2 Problem Solution

Algorithm is a detail step-by-step description to solve a problem or perform a task in a finite time [4]. It can also be described as a flow to solve a problem. Generally, there are five types of algorithm components, which are data structures, data manipulation instructions, conditional expressions, control structures and the modules [10].

Fig. 2 shows a processing model of a data algorithm. Each algorithm will receive an input. Once the input has been processed with its specific steps and commands, the output will be generated. For example, adding two values in mathematics. In this example, these two values are the inputs and the algorithm will simply refer to the steps involved in adding these two values. Then the output is the sum of these two values.

Fig. 2 Processing Model for Data Algorithm

There are another two popular ways to express the algorithm, namely through the use of flow charts or by using the code. In this package, the algorithm code is used to express the algorithm.

Conventionally, to translate an algorithm into program codes in a specific programming language, users may face some of the following difficulties:

i. The media used to make a draft algorithm may not be suitable to code the program.

ii. Inconsistent and unsystematic algorithm.iii. Poor understanding on the programming

language syntax itself.

Therefore, to overcome these problems, the Algorithm Translation Package (ATP) has been developed. This system or package has the following characteristics:i. This package will translate the algorithm into

source code in C language automatically to save time.

ii. A standard algorithm code will be defined in this package, so that it is consistent and systematic.

iii. To let users perform an algorithm code editing and use a computer as a media to do the draft.

Besides, this package also provides user-friendly interfaces to aid users in understanding the package and to cut down the learning time. The system adopted the UML as its design technique.

Before this paper describes further about the design, listed below are the scopes of the ATP:i. Only algorithm codes in Malay language are

recognized.ii. The algorithm codes used must follow the

standard, which is defined in this package.iii. The algorithm codes must already in the

detailed phases to produce the correct output.iv. The algorithm codes will only include simple

function such as variable declaration, four data types, variable operation, input function, output function, selection structure and looping structure.

3 System Design - The Object-Oriented Model

The Unified Modeling Language (UML) is a general-purpose visual modeling language that is used to specify, visualize, construct and document the artifact of a software system [11]. The UML

Input Data

Algorithm

Output

Page 5: Proceedings Template - WORDwseas.us/e-library/conferences/2005salzburg/papers/492 …  · Web viewIn practice, however algorithm design is commonly ignored by programmers. Most novice

language constructs allow users to model the static structure and dynamic behavior of a system [12].

This section discusses further the UML diagrams of the designed package which include the Use Case Diagram, Class Diagram, Activity Diagram, Sequence Diagram and the Statechart Diagram.

3.1 Use Case DiagramIn UML, a use case model is a diagram that depicts the use cases and actors for a system. The user cases also help us to capture the functional requirements of a system [11]. There are two actors that interact with the system namely the user and the computer as illustrated in Fig. 3 (please refer to Appendix A).

In order to detect any errors associated with the codes, once the user has written the algorithm codes, the codes will be checked by the three analyzers; syntax analyzer, lexical and semantic analyzer [1, 2, 6]. If no error is detected, the codes will then be translated into C source codes that are readily compiled and executed.

3.2 Activity DiagramThe activity Model (see Fig. 4 in Appendix B) on the other hand is a graphic diagram in Unified Modeling Language (UML). It is used to represent the flow for each event in the Use Case Model.

3.3 Class Diagram

Fig. 5 (Appendix C) shows the different classes of the package and their respective members.

3.4 Sequence DiagramA Sequence Diagram is used to show interactions between objects that are needed to execute the use case. For this package, the sequence diagram is shown Fig. 6 (Appendix D). Five objects are involved namely the user, algorithm code, editor, translator and the C source code.

3.5 Statechart DiagramThis diagram is used to determine how objects of a class react when an event occurs. Fig. 7 in

Appendix E shows the statechart diagram of this package.

4 Discussion and Conclusion

As a conclusion, this Algorithm Translation Package could facilitate users in performing direct translation of written algorithms into C source code, which is expected to reduce users’ development times. Users can use this package to program, compile and build small software.

The system offers several features to be utilized by users such as the followings:-i. To make it easier for users to write programs

and save time.ii. Provide toolbars and menu system, which allow

users to select the corresponding command easily and faster.

iii. Highlight syntax errors while the code is being edited to enable users to immediately debug the code and make a correction.

iv. Enable users to compile and make the executable file at a click of a button.

v. User-friendly interface.

This system also has several constraints. However, these constraints do not affect much of the system functions. Some of these constraints are:-i. Only those who understand Malay language can

use the system since it is developed using Malay language only.

ii. The use of different language styles in designing the algorithm led to the requirement to define a standard in this package to be followed.

Several functions can be added to enhance this package and widen the scope in the future. Among them include:i. Animation could make the system more

attractive and lively [8].ii. The use of flow chart to represent the

algorithm.iii. Add more supported translatable algorithm

codes to support the C library.

Page 6: Proceedings Template - WORDwseas.us/e-library/conferences/2005salzburg/papers/492 …  · Web viewIn practice, however algorithm design is commonly ignored by programmers. Most novice

iv. Add more output of selectable source codes from the translation algorithm such as Pascal, C++, Java, Basic etc.

It is hoped that through this package users will learn the C programming language as well as to improve their skills in problem solving with the aid of a more efficient and useful algorithm.

References:[1] Appel, Andrew W., 1997. Modern Compiler

Implementation in C, Cambridge University Press.

[2] Bennett, J.P., 2000. Introduction to Compiling Techniques. McGraw-Hill International.

[3] Booth, Shirley. A study of learning to program from an experiential perspective. Computers in Human Behavior. Volume 9. Issues 2-3. Summer-Autumn 1993. Pages 185-202.

[4] Darnell, Peter A., Margolis, Philip E., 1991. C: A Software Engineering Approach. Springer-Verlag New York, Inc.

[5] Dietel, H.M. and Deitel, P.J., 1994. C: How to Program, 2nd Edition. Prentice-Hall International, Inc.

[6] Fraser, Christoper W., Hanson, D. R., 1995. A Retargetable C Compiler: Design and Implementation. The Benjamin/Cummings Publishing Company, Inc.

[7] Hoffer, Jefrey A., George, Joey F. & Valacich, Joseph S., 1999. Modern Systems Analysis and Design. Addison Wesley.

[8] Lahtinen, S. –P., Sutinen, E. and Tarhio, J. Automated Animation of Algorithms with Eliot. Journal of Visual Languages & Computing. Volume 9. Issue 3. June 1998. Pages 337-349.

[9] Pea, R. D. and Midian Kurland, D. On the cognitive effects of learning computer programming. New Ideas in Psychology. Volume 2. Issue 2. 1984. Pages 137-168.

[10] Reed, Thomas A., 1988. An Introduction to Algorithm Design and Structured Programming. Prentice-Hall International (UK) Ltd

[11] Richter, C., 1999. Designing Flexible Object-Oriented Systems with UML, Macmillan Technical Publishing.

[12] Schach, Stephen R., 2000. Object-Oriented and Classical Software Engineering, McGraw-Hill Higher Education.

[13] Shackelford, Russell L., 1998. Introduction to Computing and Algorithms. Addison-Wesley Publishing Company.

[14] Song, J. S., Hahn, S. H., Tak, K. Y. and Kim, J. H. An intelligent tutoring system for introductory C language course. Computers & Education. Volume 28. Issue 2. February 1997. Pages 93-102.

APPENDIX A

Algorithm Code Analysis

Write Algorithm

codes

UserComputer

Syntax Analysis Lexical

AnalysisSemantic Analysis

Algorithm Code Translation

C Code

Generated

Page 7: Proceedings Template - WORDwseas.us/e-library/conferences/2005salzburg/papers/492 …  · Web viewIn practice, however algorithm design is commonly ignored by programmers. Most novice

Fig. 3 The Use Case Diagram

Page 8: Proceedings Template - WORDwseas.us/e-library/conferences/2005salzburg/papers/492 …  · Web viewIn practice, however algorithm design is commonly ignored by programmers. Most novice

APPENDIX B

Fig. 4 The Use Case Diagram

Choose Template

Manually

Write Algorithm Code

Translate to C Code

Statement Analysis

Syntax Analysis

Semantic Analysis

Generate to C Code

No Error

No Error

No Error

Modify Errors

Algorithm Code Design

Page 9: Proceedings Template - WORDwseas.us/e-library/conferences/2005salzburg/papers/492 …  · Web viewIn practice, however algorithm design is commonly ignored by programmers. Most novice

APPENDIX C

Fig. 5 The Class Diagram

-Caption-Label-Enabled-Height-Width-Top-Left

Button-Label-Caption-Enabled

Menu

1

1..*1..*1..*1..*1..*

1

1

11

1..*

0..*

Write

1 0..*

1..*

0..*

Use

1..11..1

1

Algorithm Code

+Sensitive()+Tooltip()+AutoComplete()+View()

User-Name-Email-Address-Organization

Editor

-Code-Top-Left-Width-Height

Algorithm Code

-Syntax-Variable-DataType-Operator-Expression-Repetition_Control-Selection_Control-Input-Output

Translator

-Translate_Complete

+SyntaxAnalysis()+SemanticAnalysis()+LexicalAnalysis()

Help System

-Title-Topic-Explanation

+Display_Topic()+Search()

Dialogue

-Label-Title-Texts-Type

Help

-Enabled

+Content()+UserGuide()+ErrorReport()+Suggestion+AboutPPA()

File

-FileName-FileLocation-Enabled

+NewFile()+OpenFile()+CloseFile()+Save()+SaveAs()+SaveAll()+PrinterSetup()+Print()+SendDoc()+Exit()

Edit

-Content-Enabled

+Undo()+Redo()+Copy()+Cut()+Paste()+Find()+FindNext()+ReplaceText()+GoTo()

Toolbar

-Label-Caption-Picture-Height-Width-Top-Left-Enabled

Display

-Enabled

+Toolbar()+BarStatus()+TemplateCode()+DialogueMessage()

Window

-Enabled

+Cascade()+TileHorizontal()+TileVertical()+CloseAll()+WindowList()

Code

-Enabled-Mode

+Format()+Translate()+Compile()+Execute()+BuildEXE()

1..1 1..1 1..11..1

Page 10: Proceedings Template - WORDwseas.us/e-library/conferences/2005salzburg/papers/492 …  · Web viewIn practice, however algorithm design is commonly ignored by programmers. Most novice

APPENDIX D

Fig. 6 The Sequence Diagram

Page 11: Proceedings Template - WORDwseas.us/e-library/conferences/2005salzburg/papers/492 …  · Web viewIn practice, however algorithm design is commonly ignored by programmers. Most novice

APPENDIX E

Fig. 7 The Statechart Diagram