Docsity

Object-Oriented & Event-Driven Programming: A Guide with Code, Assignments of Programming Languages

Toggle sidebar
bg1
ASSIGNMENT 2 FRONT SHEET
Qualification
BTEC Level 5 HND Diploma in Computing
Unit number and title
Unit 1: Programming
Submission date
Date Received 1st submission
Re-submission Date
Date Received 2nd submission
Student Name
Hồ Ngọc KhĂĄnh
Student ID
GCS200074
Class
GCD0901
Assessor name
HoĂ ng Như VÄ©nh
Student declaration
I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that
making a false declaration is a form of malpractice.
Student’s signature
Khanh
Grading grid
P2
P3
P4
P5
M2
M3
M4
D2
D3
D4
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d

Partial preview of the text

Download Object-Oriented & Event-Driven Programming: A Guide with Code and more Assignments Programming Languages in PDF only on Docsity!

ASSIGNMENT 2 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing Unit number and title Unit 1: Programming Submission date Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Hồ Ngọc KhĂĄnh Student ID GCS Class GCD0901 Assessor name HoĂ ng Như VÄ©nh Student declaration I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that making a false declaration is a form of malpractice. Student’s signature Khanh Grading grid P2 P3 P4 P5 M2 M3 M4 D2 D3 D

 Summative Feedback:  Resubmission Feedback:

Grade: Assessor Signature: Date: Lecturer Signature:

  • I. INTRODUCTION
      1. About the problem
      1. About the application
      1. About the requirements
  • II. PROGRAMMING PARADIGMS
      1. Procedural Programming
      1. OOP (Object-Oriented Programming)
      1. Event-Driven Programming
      1. Problem Application’s Paradigm
  • III. IDE (INTEGRATED DEVELOPMENT ENVIRONMENT)
      1. Definition
      1. Features
      1. Debugging Process
      1. Debugging During Implementation
      1. With IDE and Without IDE
  • IV. DESIGN AND IMPLEMENTATION
      1. Source Code...........................................................................................................................................................
      1. Flowchart
      1. Coding Standards...................................................................................................................................................
      1. Benefits of Coding Standards
  • Figure 1: CORE DEFINITION OF PROCEDURAL PROGRAMMING (TUANNGUYEN.TECH) TABLE OF FIGURES AND TABLES
  • Figure 2: MAIN AND SUB FUNCTIONS
  • Figure 3: SUB FUNCTIONS
  • Figure 4: OBJECT-ORIENTED PROGRAMMING (LYNDA.COM)
  • Figure 5: BASIC OOP CONCEPTS (GEEKSFORGEEKS.ORG)
  • Figure 6: MAIN FUNCTION
  • Figure 7: CLASS: DATA
  • Figure 8: EVENT-DRIVEN PROGRAMMING ALONG WITH OOP (TECHNOLOGYUK.COM)
  • Figure 9: DESIGN FORM
  • Figure 10: CODE FORM
  • Figure 11: COMPILER OF VISUAL STUDIO COMMUNITY
  • Figure 12: DEBUGGER IN VISUAL STUDIO COMMUNITY
  • Figure 13: CODE COMPLETION
  • Figure 14: VISUAL STUDIO SUPPORTS MULTIPLE PROGRAMMING LANGUAGE
  • Figure 15: DEBUGGING DURING IMPLEMENTATION
  • Figure 16: SCREENSHOT OF DEBUGGING
  • Figure 17: CLASS: PROGRAM
  • Figure 18: CLASS: FLIGHTTICKET
  • Figure 19: CLASS: PLANE....................................................................................................................................................
  • Figure 20: CLASS: SCREEN..................................................................................................................................................
  • Figure 21: CLASS: REQUEST
  • Figure 22: APPLICATION HEADER
  • Figure 23: APPLICATION MENU
  • Figure 24: SEARCH MENU..................................................................................................................................................
  • Figure 25: FLOWCHART OF MAIN FUNCTION
  • Figure 26: SCREENSHOT NO.1
  • Figure 27: SCREENSHOT NO.2 AND
  • Figure 28: SCREENSHOT NO.4
  • Figure 29: SCREENSHOT NO.5
  • Figure 30: SCREENSHOT NO.6
  • Figure 31: SCREENSHOT NO.7
  • Table 1: THE DIFFERENCE OF USING IDE AND WITHOUT USING IDE

I. INTRODUCTION

1. About the problem

In the first report, I have already mentioned about a business problem of taking customer’s orders and built a small application with menu-based program to meet the requirements. Besides, in this report, I planned on creating an application which will manage the flight tickets from a specific airport. This problem might be intimidating because the problem involves plentiful elements going with hard requests. However, I still managed to create a full application.

2. About the application

The application has 5 classes in total, one of them is the main program and the rest are supporting for the main program. It will have eight options including:

  1. Add new ticket
  2. Update ticket’s information
  3. Remove ticket
  4. Search ticket by passenger’s name
  5. Search ticket by flight date
  6. Search ticket by destination
  7. Print all tickets available
  8. Exit application

3. About the requirements

  • Demonstrate the definition of Procedural Programming, Object-Oriented Programming, Event- Driven Programming and Integrated Development Environment with theories and images.
  • Breakdown the management application and analysis the problem might occur during the process of programming.
  • Design diagrams to demonstrate how the program will execute.
  • Design a C# based program to solve the problem but still contains the CRUD actions, coding standards and naming standards.

ADVANTAGES:

  • The coding is quick and straightforward.
  • The codes can be reused in certain parts of the program.
  • The programming model uses less machine memory.
  • The flow of codes written in the software paradigm for procedural planning is easier to monitor.
  • For general programming, the programming paradigm is better considered. DISADVANTAGES:
  • Concentrate instead of data on tasks.
  • In a broad program, the connection of global data is difficult to define.
  • In the case of repair and improvement, the use of global data is error-prone and may be a barrier.
  • Global data alteration involves changes to certain features.
  • It is also difficult to maintain and upgrade the code of the software due to global data.
  • The paradigm of procedural planning does not very well model the real-world problem as functions are action-oriented and do not really fit the elements of the problem. Clearly, procedural programming promises a great deal, one of which is simple to understand and execute. New programmers will begin their journey through the methodical writing of code. This helps them to understand how those programs function. Owing to its limitations, however, actual programs in the world do not use procedural programming. Therefore, students must study different paradigms to be introduced to challenges in real life. To demonstrate the definition with code, I made a small program of finding the largest and the smallest number in the array typed from the keyboard. Below is the review of it Figure 2 : MAIN AND SUB FUNCTIONS

Figure 3 : SUB FUNCTIONS

2. OOP (Object-Oriented Programming) DEFINITION: Object-oriented programming (OOP) is a method of computer programming or software design in which programmers specify the data type of a data structure as well as the operations or functions that can be performed on the data structure. Figure 4 : OBJECT-ORIENTED PROGRAMMING (LYNDA.COM) OOP CONCEPTS: - Class: A class of objects. The class describes all of the shared properties of the objects that belong to it. - Object: a self-contained body made up of both data and processes for manipulating the data. - Encapsulation involves treating a set of associated processes, properties and other representatives as a single entity. - Inheritance is the ability to receive “inherit” methods and properties from an existing class.

  • Speed: Object-oriented programs are partly because of their scale slower than other programs. More machine resources often are required in other Object-oriented programs, thus slowing down the software. Below is a small example of using class and object: Figure 6 : MAIN FUNCTION Figure 7 : CLASS: DATA

3. Event-Driven Programming DEFINITION: Event-driven programming is a model of programming in which an event determines the flow of program execution - for example, a user action such as a mouse click or a key button or an operating system notification or other program code. Figure 8 : EVENT-DRIVEN PROGRAMMING ALONG WITH OOP (TECHNOLOGYUK.COM) KEY FEATURES: - Service Oriented: is a core aspect of event-driven programming used to produce services' programming. - Time Driven: In case of programming with motivation, time is influenced by the code that works on a triggering cycle. Motivated time can be regarded as a particular code working at a particular time. - Event Handlers: are a category of function or process that performs a particular event. - Trigger Functions: Event-driven coding uses trigger functions to trigger code when a specific event occurs. Trigger functions decide what code to perform when an event occurs. - Events: Events include mouse, computer keyboard and user interface, which events have to be triggered in this program in order to happen. - Simplicity of Programming and Ease of Development: Since it is rather aesthetic, event-driven programming is easy and much simpler to program than other types of programming. Event- driven architecture also allows users to easily insert pre-written programming scripts into current applications. - Compare Event Driven Programming with Object-oriented Programming (OOP): Event-driven coding is a computer programming framework that uses the occurrence of events to search for the program's control source, while objects-oriented encoding (OOP) treats datafields as entities that can only be accessed by pre-defined methods and it generated over four main rules, which are Encapsulation, Data Abstraction, Polymorphism, and Inheritance.

4. Problem Application’s Paradigm

For the problem of creating an application earlier in the introduction, I decided to choose Object- oriented Programming as the Programming paradigm. It allows me to create new objects to assist me to build the program easily. Since the Event Driven Programming is genuinely new for me, I don’t have any experience of building a full application hence I found it hard to work with it since it definitely takes more efforts and time to build a whole application. I also didn’t choose Procedural Programming as my application’s paradigm since it will be a pain to maintain the quality or double-check the whole program at once.

III. IDE (INTEGRATED DEVELOPMENT ENVIRONMENT)

1. Definition

Integrated Development Environment is a software application that offers robust software creation facilities to computer programmers. An integrated development environment (IDE) usually includes a source code editor, construct automation tools, and a debugger. Intelligent code completion is available in the majority of current IDEs. Some IDEs have either a compiler or an interpreter, or both.

2. Features

  • Compiler: Compilers are modules that convert programming language into a format that computers can understand. To ensure the consistency of the computer code, it is evaluated. Figure 11 : COMPILER OF VISUAL STUDIO COMMUNITY
  • Debugger: Programmers and software engineers will typically inspect and find errors in different segments of code. They frequently use simulations of real-world environments to measure features and efficiency. Figure 12 : DEBUGGER IN VISUAL STUDIO COMMUNITY
  • Code completion: Code completion features help programmers by defining and adding basic code components intelligently. These features save developers time and reduce the risk of glitches and typos. Figure 13 : CODE COMPLETION
  • Programming language support: IDEs are usually limited to a single programming language, but some do support several languages. Ruby, Python, and Java tools are a few examples.

4. Debugging During Implementation Since debugging tools are really that powerful and useful. With the help form them, I can easily find bugs and glitches without having to observe carefully for every line of code. Also, with object-orientetd programming, the helpfulness of the debugger really stood out in some situation. Figure 15 : DEBUGGING DURING IMPLEMENTATION In short, debugging tools of Visual Studio Community has helped me a lot during the programming process and the implementation. It shows the real time value of some variables, it executes by tapping F10 to check on every line of code.

Figure 16 : SCREENSHOT OF DEBUGGING

5. With IDE and Without IDE WITH IDE WITHOUT IDE ADV

ANTAGES

− Can quickly navigate to type forward without having to care about libraries or namespaces − Helpful code automatic completion − Show errors right where the spot we’re typing − Show tips of how to solve the errors or typos − Helpful debugging tools − The format of showing compiler and file reader is user-friendly − We can be independent from the auto completion and debugging tools DISADVANTAGES − IDEs are complicated tools, so to master and use all of their tools takes time and patience − We can be dependent on them because of how helpful they are − Coding process might be more challenging and time-consuming − Takes more time to format Table 1 : THE DIFFERENCE OF USING IDE AND WITHOUT USING IDE

Console.ReadLine(); break; case Request.SearchTicket: Screen.DisplaySearchMenu(); byte searchRequest = Byte.Parse(Console.ReadLine()); switch (searchRequest) { case Request.SearchName: var searchName = Screen.EnterPassengerName(); plane.SearchTicket(searchName); Console.ReadLine(); break; case Request.SearchDate: var searchDate = Screen.EnterFlightDate(); plane.SearchFlightDate(searchDate); Console.ReadLine(); break; case Request.SearchDestination: var searchDestination = Screen.EnterDestination(); plane.SearchFlightDestination(searchDestination); Console.ReadLine(); break; default: Screen.DisplayInvalidOption(); break; } break; case Request.PrintTickets: plane.PrintListOfTicket(); Console.ReadLine(); break; case Request.Exit: return; break; default: Screen.DisplayInvalidOption(); break; } } while (order != 6 ); Console.ReadLine(); } } Figure 17 : CLASS: PROGRAM

class FlightTicket { public string FullName; public string Gender; public byte Age; public string FlightDate; public string Destination; public FlightTicket(string fullName, string gender, byte age, string flightDate, string dest ination) { FullName = fullName; Gender = gender; Age = age; FlightDate = flightDate; Destination = destination; } public string DisplayTicket() { string result = "==================================\n" + $"FULL NAME: {FullName} \n" + $"GENDER: {Gender} \n" + $"AGE: {Age} \n" + $"FLIGHT DATE: {FlightDate} \n" + $"DESTINATION: {Destination}\n" + "==================================\n"; return result; } Figure 18 : CLASS: FLIGHTTICKET class Plane { public string PlaneCode; public List Tickets; public Plane(string name) { PlaneCode = name; Tickets = new List(); } public void AddTicket(FlightTicket passenger) { Tickets.Add(passenger); } public void SearchTicket(string fullName) {