Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 18

PROGRAM TITLE: Phone Management System

UNIT TITLE: Unit 1 Programming

ASSIGNMENT NUMBER: 1

ASSIGNMENT NAME: Programming Assignment 2022

SUBMISSION DATE: September 21th, 2022

DATE RECEIVED: September 11st, 2022

TUTORIAL LECTURER: Nguyen Phuong Hai

WORD COUNT: 1857

STUDENT NAME: Ta Van Phuc

STUDENT ID: BKC13161

MOBILE NUMBER: 0365330543


Summative Feedback:

Internal verification:

2
Table of Contents
I. Introduction................................................................................................................................4
II. Theory........................................................................................................................................4
1. Algorithm...............................................................................................................................4
1.1 Algorithm.........................................................................................................................4
1.2 Purpose of the algorithm:...............................................................................................4
1.3 The importance of the algorithm:..................................................................................4
1.4 Several representations of the algorithm.......................................................................4
1.5 Data structures and algorithms......................................................................................4
1.6 Take for example an algorithm.....................................................................................4
2. Programming directions.......................................................................................................5
2.1. Procedure-oriented programming................................................................................5
2.2.Object-oriented programming.......................................................................................5
2.3. Event-Oriented Programming.......................................................................................6
2.4. Object oriented programming.......................................................................................6
2.5. Direction programming comparison............................................................................6
3. IDE, Debug and some coding standards..............................................................................6
3.1 IDE & Text editor............................................................................................................6
3.2. Debug...............................................................................................................................7
3.3. Coding standards..........................................................................................................13
III. Practise...................................................................................................................................13
1. Problem, problem analysis (input, output, processing)...................................................13
1.1 Problem...........................................................................................................................13
1.2 Problem analysis............................................................................................................13
2. Draw flowcharts or write pseudocode...............................................................................14

3
I. Introduction
- In this document, I will cover findings from research into the characteristics of different
programming paradigms – procedural, object-orientated, and event-driven programming.

- The next part is an analysis of suitable IDE, Debug and some coding standards.

- Finally I will program an object-oriented phone management software in Java.

II. Theory

1. Algorithm

1.1 Algorithm
- In mathematics and computer science, an algorithm is a finite sequence of rigorous instructions,
typically used to solve a class of specific problems or to perform a computation. Algorithms are
used as specifications for performing calculations and data processing.

1.2 Purpose of the algorithm:


- The purpose of the algorithm is to find the results of solving the original data and problem.

1.3 The importance of the algorithm:


- Algorithms are an important, indispensable part when approaching problems related to the field
of programming.

- Good algorithms bring high efficiency, helping programs work efficiently with fast processing
speed, saving resources.

- Algorithms help programmers understand more deeply about applications and programs.

1.4 Several representations of the algorithm


- Use natural language.

- Use flow chart.

- Use pseudo-code.

1.5 Data structures and algorithms


- Algorithms are often created independently of programming languages, which means that an
algorithm can be implemented in many different programming languages.

1.6 Take for example an algorithm


calculate the absolute value of integer n.

4
2. Programming directions.

2.1. Procedural programming


- Concept: Is a programming paradigm, derived from imperative programming, based on the
concept of the procedure call. Procedures (a type of routine or subroutine) simply contain a
series of computational steps to be carried out. Any given procedure might be called at any point
during a program's execution, including by other procedures or itself.

- Characteristics of procedure-oriented programming:

+ Most functions allow system-wide data to be shared.

+ It also divides larger programs into smaller parts called functions.

+ It allows free movement of data around the system.

+ Data is converted by functions from one form to another.

2.2.Object-oriented programming
- Concept: Is a programming paradigm based on the concept of "objects", which can contain data
and code: data in the form of fields (often known as attributes or properties), and code, in the
form of procedures (often known as methods).

- Object-oriented programming characteristics:

+ Encapsulation

5
+ Inheritance

+ Polymorphism

+ Abstraction

2.3. Event-driven programming


- Concept: Is a programming paradigm in which the flow of the program is determined by events
such as user actions (mouse clicks, key presses), sensor outputs, or message passing from other
programs or threads. Event-driven programming is the dominant paradigm used in graphical user
interfaces and other applications (e.g., JavaScript web applications) that are centered on
performing certain actions in response to user input. This is also true of programming for device
drivers (e.g., P in USB device driver stacks).

- Features of event-driven programming:

+ Service orientation

+ By time

+ Event handler

+ Events

2.4. The relationship of programming directions.


- These three categories are thus not related strictly hierarchically, but in common usage they are
mostly nested within one another.

2.5. Direction programming comparison


- Some use cases of programming directions : To identify, clarify and organize system
requirements, etc.

- The use case is made up of a set of possible sequences of interactions between systems and
users in a particular environment and related to a particular goal. The method creates a document
that describes all the steps taken by a user to complete an activity.

3. IDE, Debug and some coding standards

3.1 IDE & Text editor


- The concept of IDE: is an environment that integrates many different tools to serve the needs of
manipulating the programmer's software.

- The concept of text editor: is a text editor.

- How the IDE assists in application development : The IDE is an integral part of the software
application development process. With the IDE and the tools it brings, it will make the
programming process more convenient, easy and less prone to errors.

- Advantages and disadvantages of IDE:

6
+ Advantages:

- Convenient for adjusting pre-code

- Highlight syntax in the code

- Autofill syntax defects

- Ability to detect errors for you

- Support code test run

Cons: The software is difficult to install and consumes the memory space of the computer.

3.2. Debug
- Concept: Debugging is the process of detecting and removing of existing and potential errors
(also called as 'bugs') in a software code that can cause it to behave unexpectedly or crash.

- The purpose of debug: to remove errors from the program but more importantly to help the
programmer better understand the execution of the program. A programmer who does not have
the ability to debug effectively is like being blind.

- The importance of debugging: is to eliminate errors from the program but also to help
programmers better understand the program, the software is running. Therefore, debugging is
also a ability to be used to assess the level of programmers.

- Example of a debugging process :

Imagine we have the following application:

The program is supposed to calculate the average of all values passed as command-line
arguments.

It compiles and runs without issues, however the result is not what one would expect. For
instance, when we pass as the input, the result is .1 2 36.0

7
First of all, you need to think about where the suspected error might be coming from. We can
assume the problem is not in the print statements. Most likely, unexpected results are coming
from our method. In order to find the cause, let's examine its behaviour at runtime.findAverage

- Set breakpoints

To examine how the program operates at runtime, we need to suspend its execution before the
suspected piece of code. This is done by setting breakpoints. Breakpoints indicate the lines of
code where the program will be suspended for you to examine its state.

 Click the gutter at the line where the method is called.findAverage

- Run the program in debug mode

Since we are going to pass arguments for running and debugging the program, make sure the
run/debug configuration has these arguments in place.

+ Click the Run icon in the gutter, then select Modify Run Configuration.

8
+ Enter arguments in the Program arguments field.

+Click the Run button near the main method. From the menu, select Debug.

- Analyze the program state

9
After the debugger session has started, the program runs normally until a breakpoint is hit. When
this happens, the line where the program paused gets highlighted and the Debug tool window
appears.

The highlighted line has not been executed yet. The program now waits for further instructions
from you. The suspended state lets you examine variables, which hold the state of the program.

As the findAverage method has not been called yet, all its local variables like result are not yet in
scope, however, we can examine the contents of the args array (args is in scope for the main
method). The contents of args are displayed inline where args is used:

10
You can also get information about all variables that are currently in scope in the Variables
panel.

Step through the program.

Now that we are comfortable with the Debug tool window, it's time to step into the findAverage
method and find out what is happening inside it.

+ To step into a method, click the Step Into button or press F7.

Another line gets highlighted in the editor because we advanced the execution point one step
forward.

+ Continue stepping with Step Over F8. Notice how it is different from Step Into – it also
advances the execution one step forward, but it doesn't visit any methods like Integer.parseInt()
along the way.

Let's keep stepping and see how the local variable result is declared and how it is changed with
each iteration of the loop.

11
Right now the variable s contains the value "3". It is going to be converted to an Integer and be
added to result, which currently has the value of 3.0. No errors so far. The sum is calculated
correctly.

+ Two more steps take us to the return statement and we see where the omission was. We forgot
to divide the sum by the number of values. This was the cause of incorrect method return.

+ Let's correct the error. return result / input.length;

- Stop and rerun the debugger session.

In order to check that the program works fine, let's stop the debugger session and rerun the
program.

+ Click the Stop button or press Ctrl+F2.

12
+ Click the Run button near the main method. From the menu, select Run.

+ Verify that the program works correctly now.

3.3. Coding standards


- Concept : A coding standard is a set of rules and agreements used when writing a source code
in a particular programming language.

- Some standards : set of rules, techniques, and best practices to create cleaner, more readable,
more efficient code with minimal errors.

- Coding standards help in the development of software programs that are less complex and
thereby reduce the errors. If programming standards in software engineering are followed, the
code is consistent and can be easily maintained.

13
III. Practise

1. Problem, problem analysis (input, output, processing)

1.1 Problem
BKC Company - one of the IT companies in Vietnam, was hired by HirePhone as a phone
management software. You are a newly hired fresher, and you are asked to learn about
algorithms, programming paradigms.

Next, you are asked by your manager to develop a phone management software that works
according to the specification and design of the management system. The software requires you
to manage the phones.

1.2 Problem analysis


- Input : Number of phones , IMEI, name, manufacturer, price, release date, RAM capacity,
ROM capacity, chip, screen size, phone size (length x width x thickness).

- Output : Details of each phone

- Processing : Import, Export, Sort, Filter, Add, Delete, Export to file.

2. Draw flowcharts or write pseudocode

DIEN THOAI :

14
Import

Export

15
Add

Remove

16
Filter

Sort

17
Main

Source : https://en.wikipedia.org/wiki/Event-driven_programming
https://en.wikipedia.org/wiki/Object-oriented_programming
https://en.wikipedia.org/wiki/Procedural_programming
https://dinhnghia.vn/thuat-toan-la-gi-tinh-chat-vai-tro-phan-loai.html
https://en.wikipedia.org/wiki/Algorithm

18

You might also like