Programming Paradigm Edited

download Programming Paradigm Edited

of 22

Transcript of Programming Paradigm Edited

By Asomah Eric

CONTENTSContents..................................................................................................................................1 Introduction.............................................................................................................................2 Comparative evaluation of suitable paradigm for the application...........................................3 Choice of Paradigm and Justification.......................................................................................5 Second best choice.................................................................................................................6 Algorithm design for the application.......................................................................................8 Designing an algorithm in pseudocode to represent some of the users activities..............11 Conclusion.............................................................................................................................15 References............................................................................................................................15 Appendices.........................................................................................................................16 Screen shots...................................................................................................................16 Appendix II.........................................................................................................................22 System Requirements.....................................................................................................22

1|Page

By Asomah Eric

INTRODUCTION The speeding need of the changing world with responds to information seemed partially solved with the advent of internet and the web technologies. This has now become more pressing than ever due the business needs, social needs and governmental needs. These needs have therefore called for complex systems to be developed and solve organizations, government and societal problems. FlyBe as an emerging Airline company to join the many existing once, has no choice but have to compete in this complex environment as describe above. Due to globalization, airline companies today are able to operate globally and hence the need to rely on some of these technologies to meet the demands of their global customers. This explains why every airline is having a website or a web application to mange their booking and the general operations of the airline. For FlyBe to enter into this market and compete effectively there is a need for the company to result to web technology which will help the new Airline Company to grow and mange its booking to reach both local and global market. As a software engineer, I have been called to develop an online reservation system for FlyBe. But there are various programming paradigms to look at before the best choice can be made to help solve FlyBes problem of the current competition ahead and make the company a player in this market.

2|Page

By Asomah Eric

COMPARATIVE

EVALUATION

OF

SUITABLE

PARADIGM

FOR

THE

APPLICATION There are different programmings paradigms that have been existing over the years, which are characterized by their time of origin or how they are programmed or what problem they are able to solve and or their approach to problem solving. Some of these paradigms can be summarize as below:

Imperative/ Algorithmic

Algorithmic

Object-Oriented

Functional Programming Algol Cobol PL/1 Ada C Modula-3 Lisp Haskell ML Miranda APL Lisp

Logic Programming Prolog Smalltalk Simula C++ Java Smalltalk C#

Table 1 Comparative evaluation of different paradigms (Adopted from: http://www.seas.gwu.edu/~bell/csci210/lectures/programming_paradigms.pdf, 19the July, 2011)

3|Page

By Asomah Eric

IMPERATIVE APPROACH With the Imperative approach, the codes are written to describe in exacting detail the steps that the computer must take to accomplish the goal. This is sometimes referred to as algorithmic programming (msdn, 2011). The various examples of the paradigm are as listed in the table1 such as C, Ada, COBOL etc.

DECLARATIVE APROACH The Declarative is divided into Functional and Logic paradigms. The functional paradigm is clearly created to support a pure functional approach to problem solving which broke away from declarative programming. In comparison with imperative paradigm, functional approach involves composing the problem as a set of functions to be executed. The input to each function and what each function returns are critically assigned (msdn, 2011). The logic program defines a set of relations. This definition of relations can therefore be used in various ways by the interpreter to solve different queries which is not so in other paradigms which make use of explicitly how the declarative message is used to solve the query (msdn, 2011). OBJECT-ORIENTED With the demands and the pressure for more complex technologies, hardware has been able to play its role in terms of re-usability, maintenance and cost. Whiles software has still remained in crises. The crises in the software are the sense of its high cost of maintenance as compare to its development as there is continues quest for complex and challenging systems to be built (Buyya, 2009). This resulted in the need to create more robust software that is reusable. The knowledge of this gave birth to the object oriented Paradigm, which treats data-fields as "objects" which is controlled through pre-defined methods.

4|Page

By Asomah Eric

Bellaachia (2011) argued that OO programming paradigm is not just a few new features added to a programming language, but it a new way of thinking about the process of decomposing problems and developing programming solutions. Agreeing to this, OOP offers the most divers ways of approaching a complex problem than the other paradigms. The OOP is known of using physical modules and data abstractions to approach to any project of any size (Buyya, 2009). The typical traits of an OO-P are Object-based features, Inheritance and Polymorphism. Considering all of the paradigms, the most suitable paradigm to solve FlyBes problem of developing online reservation system is the Object-Oriented paradigm.

CHOICE OF PARADIGM AND JUSTIFICATION The OO-P approach has been chosen for the FlyBe Online Reservation system because of the complexity of the application or the system. The OO-P as discussed above offers a great understanding of the various modules that needs to be created and breaks the code of complexity into simple easy ones. The other interim reasons for the OO-P paradigms as a choice is because it has improve tremendously on the structured programming paradigm, it has places emphasis on data rather than algorithms and it has satisfy procedural abstraction with data abstraction. Data and associated operations are unified through the grouping of objects with common attributes, operations, and semantics (Buyya, 2009). The choice of programming language within the OO-P domain for the FlyBe Online Reservation system is C#. The programming language has been chosen in expense of others because of its robustness, simplicity, modern and general purposeless. Since the system is going to be an online application or web application, it also motivated its selection. C# has been rated among the best Object-Oriented Programming which is good for web application development by taken advantage of the .Net framework (Obasanjo, 2007). It facilitates application development within the shortest possible time and hence helping developers to meet deadlines of projects. Scheduling or meeting5|Page

By Asomah Eric

project time lines are as important as any other activity in the project because the delay in the project may lead to increase in cost and quality. Since the time line for the FlyBe system is so short, it is therefore arguably important to select C# to facilitate the speed of development and cut down cost. Some of the main features of the C# programming language that led to its selection in this project are as follows: shorten development time by developers not to worry about memory management, type safety, building low level libraries, array bounds checking and many others, which gives more time for module logic construction (Obasanjo, 2007). The Common Language Runtime in C# is well designed and considered better than the JVM. The CLR makes sure that the execution of both managed and unmanaged codes are taken care of (Nguyen, 2011). The C# programming language is better to use in applications such as the one under development since, windows has the big market in the Personal Computing market, and hence many users are using windows OS and will interface well with the Online application for the airline (FlyBe). The language also offers good metadata, which allows class to be more expressive (Nguyen, 2011). This accounts for the reason why the language is easy to learn and many developers are grapping it. Nguyen (2011) argued that the SWF is faster than Swing in Java most of the time The C# makes use of GUI development environment like the Windows Forms which provides powerful support for Data Binding and facilitates population of web pages with data from the database environment. The inbuilt XML documentation tags are handier and make it easier for data streaming. The above factors, therefore led to the selection of the C# Object-Oriented Programming language for the FlyBe Online Reservation System (FORS).SECOND BEST CHOICE

The programming language other than the C# above would be Java. Both languages are chosen from the OO-P paradigm. C# is much more like Java in terms of syntax and the style of coding. There are few disparities between the languages.

6|Page

By Asomah Eric

Java package hello;

C# using System;

public class HelloWorld { public static void main(String[] args) { String name = "Java"; // Check argument if (args.length == 1) name = args[0]; System.out.println("Hello, " + name + "!"); } }

namespace Hello { public class HelloWorld { public static void Main(string[] args) { string name = "C#"; // Check argument if (args.Length == 1) name = args[0]; Console.WriteLine("Hello, " + name + "!"); } } }

Table 2 Comparing Java Syntax and structure with C#

The table above compares the syntax and structure of Java with that of C# using a simple helloworld program. Java is typically compiled to Java byte code, the code then runs in the Java Virtual Machine or JVM environment just like C#s Common Language Runtime (CLR). Both platforms support native compilation via Just In Time compilers (Obasanjo, 2007). Java is good for developing a large-scale web system, which poses a technical challenge of building queries for databases. This custom component requires expertise7|Page

By Asomah Eric

and a lot of time to build and test the new libraries. In an ideal environment, developers would be able to use pre-built, tested, and highly configurable components to integrate into their application development environment (Mahmoud, 2004). JavaServer Faces (JSF) is a server-side technology for developing web applications with rich user interfaces. The JSF principle is based on GUI (Graphical User Interface), which help developers to create custom interfaces to suit the application under development. The JSF technology provides a framework for building Java-based web applications that run on the server side, and render the user interface back to the client (Mahmoud, 2004). Java is having much more reputation as compare to other OO-Ps due to its ability to run robustly and also able to solve complex problem and more importantly for mobile applications. Java website may render very well on mobile devices as compare to other paradigms. This fact might be attributed to the fact that most mobile applications and software are built on java platforms. And the number of people who own mobile phones and PDAs are currently higher than any other devices. Java is as well good for the development of the FlyBe Online Reservation System, but due to time factor in terms of this project the best choice that should be recommended to solve the problem cheaper but yet efficient and time saving is C#.ALGORITHM DESIGN FOR THE APPLICATION

Informally,

an

algorithm

is

a

step-by-step

method

for

solving

a

problem or doing a task. An algorithm takes some values as input and processes them into output (Thomas H. Cormen, 2001). Basing on the three construct; sequence, decision (selection) and repetition, the algorithm of the FlyBe system were designed. To proceed with the algorithm, the various actors of the system are identified as every OO-P is best engineered by using Use Case. The actors of the system are: a. Customer b. Administrator8|Page

By Asomah Eric

The functions of a customer are: search for flight, make booking, and make payment, login to cancel flight. In the case of the administrator: the admin add flight, manage flight (Update, Delete) and manage users.

UML Activity DiagramFlyBe Airline SystemFlyBe ORS Receive Request

Using UML as an algorithm design, the following were achieved:Customer PC Customer []

Search for Keyword

Open Webpage No Start

Found ? Yes

Send to customer

Process Booking

Search for flight - from and to location

Update Account Info

Notify Customer

Figure 1 Activity Diagram for Customer (FORS) The above UML graphically represent the customers activities in the FlyBe Online reservation System. The UML activity diagram serves as a graphical algorithm for the system.

9|Page

By Asomah Eric

Figure 2 Admin Activity Diagram (FORS)

10 | P a g e

By Asomah Eric

The above activity Diagram represents the UML algorithms design. From the diagram, it Cleary shows the various refined activities engaged by the administrator of the FlyBe Online reservation systemDESIGNING AN ALGORITHM IN PSEUDOCODE TO REPRESENT SOME OF THE USERS ACTIVITIES

The use of English language-kind of description of an algorithm is known as Psedocode. Some of the psedocode used for the algorithm design of the system are as follows: Algorithm 1.0 Add Flight Algorithm: AdminAddFlight (ConnectionString, DB) Purpose: To add Flight Information Pre: Connect to Database Post: Insert Into database (Flight information) Return: True if all conditions are fulfilled { Else } Return False } Close Connection }

11 | P a g e

By Asomah Eric

Algorithm 2.0 Search Flight Algorithm: UserSearchFlight (ConnectionString, DB) Purpose: To display Flight Information Pre: Connect to Database Post: Select data from database (Flight information) Return: True if all conditions are fulfilled { Else } Return False } Close Connection }

Algorithm 3.0 Make Booking Algorithm: CustomerBookFlight (ConnectionString, DB) Purpose: To add Booking Information to database Pre: Connect to Database

12 | P a g e

By Asomah Eric

Post: Insert Into database (Booking information) Return: True if all conditions are fulfilled { Else } Return False } Close Connection }

Algorithm 4.0 CancelFlight Algorithm: CustomerCancelFlight (ConnectionString, DB) Purpose: To delete Flight Information From Booking Pre: Connect to Database Post: Delete from database (Booking information) Return: True if all conditions are fulfilled { Else }

13 | P a g e

By Asomah Eric

Return False } Close Connection }

Algorithm 5.0 RemoveFlight Algorithm: AdminRemoveFlight (ConnectionString, DB) Purpose: To delete Flight Information From database Pre: Connect to Database Post: Delete Flight details from database (RemoveInformation) Return: True if all conditions are fulfilled { Else } Return False } Close Connection }

14 | P a g e

By Asomah Eric

CONCLUSION

The development of FlyBe reservation system has led to the study of the various paradigms where looking at their strength and weaknesses in respect to the application under development. This piece has led me to understand the various programming languages and how they can be selected for task specifics. Rating the overall output of the work and quality, it can be said that it wasnt able to achieve the expectancy due to short semester and a medium scale product. In future this work can be improved and more features and functions could be added, since the application is tune to the OO-P environment.

REFERENCES

Buyya

(2009),

JavaBook-Preface,

[Online]

Available:

http://www.buyya

Abdelghani Bellaachia (2011), programming_paradigms, [Online] Available: http://www.seas.gwu.edu/~bell/csci210/lectures/programming_paradigms.pdf, [Accessed: 19th July, 2011]

.com/java/JavaBook-Preface.pdf [Accessed: 19th July,2011] msdn (2011), Functional Programming vs. Imperative Programming, [Online] Available at: http://msdn.microsoft.com/en-us/library/bb669144.aspx [Accessed: 19th July,2011]

Obasanjo, (2007), A comparison of microsoft's c# programming language to sun microsystems' java programming language [Online] Available at: http://www.25hoursaday.com/CsharpVsJava.html [Accessed: 20th July, 2011].

Nguyen

(2011),

Java

vs

C#,

[Online]

Available

at:

http://www.veridicus.com/tummy/programming/java_vs_csharp.asp 21st July, 2011].

[Accessed,

15 | P a g e

By Asomah Eric

Mahmoud (2004), Developing Web Applications with JavaServer Faces [Online] Available at: http://www.oracle.com/technetwork/articles/javase/javaserverfaces135231.html, [Accessed: 25th July, 2011]

Cown

(2011),

Java

and

C#

Comparison

[Online]

Available

at:

http://www.harding.edu/fmccown/java_csharp_comparison.html , [Accessed: 27th July, 2011]

Sun

Microsystems,

Inc

(2005),

[Online]

Available

at:

http://java.sun.com/developer/technicalArticles/WebServices/JWS_2/JWS_White _Paper.pdf [Accessed: 26th July, 2011].

Thomas H. Cormen, (2001), Introduction to algorithms, MIT electrical engineering and computer science series,

APPENDICES SCREEN SHOTS

16 | P a g e

By Asomah Eric From this page, the login as admin button was clicked to login. User name: admin Password: +++++++ Or ericaria as username and password eric~12

17 | P a g e

By Asomah Eric

18 | P a g e

By Asomah Eric

19 | P a g e

By Asomah Eric

20 | P a g e

By Asomah Eric

21 | P a g e

By Asomah Eric

APPENDIX II SYSTEM REQUIREMENTS

Visual Studio 2010 C#.Net 3.0

22 | P a g e