Professional Documents
Culture Documents
Assignment TaVanPhuc D03K13
Assignment TaVanPhuc D03K13
ASSIGNMENT NUMBER: 1
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.
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.
- 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.
- Use pseudo-code.
4
2. Programming directions.
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).
+ Encapsulation
5
+ Inheritance
+ Polymorphism
+ Abstraction
+ Service orientation
+ By time
+ Event handler
+ Events
- 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.
- 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.
6
+ Advantages:
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.
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.
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.
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.
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.
In order to check that the program works fine, let's stop the debugger session and rerun the
program.
12
+ Click the Run button near the main method. From the menu, select Run.
- 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.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.
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