0% found this document useful (0 votes)
14 views

Assignment Programming

The document is an assignment for a programming unit that involves creating a phone management system. It includes an introduction to Java programming language concepts. It also covers algorithms including definitions, purposes, importance and representations. It discusses different programming paradigms like procedural programming, object-oriented programming, and event-driven programming. It compares their features and provides examples of applying each paradigm.

Uploaded by

Duy Nguyen
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Assignment Programming

The document is an assignment for a programming unit that involves creating a phone management system. It includes an introduction to Java programming language concepts. It also covers algorithms including definitions, purposes, importance and representations. It discusses different programming paradigms like procedural programming, object-oriented programming, and event-driven programming. It compares their features and provides examples of applying each paradigm.

Uploaded by

Duy Nguyen
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 40

PROGRAM TITLE: BTEC in Computing ( Software Engineering)

UNIT TITLE: Unit 1: Programming

ASSIGNMENT NUMBER: Assignment 1

ASSIGNMENT NAME: Phone Management System


SUBMISSION DATE: 18/9/2022

DATE RECEIVED: 20/8/2022

TUTORIAL LECTURER: Mr.PHAM SON TUNG

WORD COUNT:

STUDENT NAME: NGUYEN HUU DUY

STUDENT ID: BKC13144

MOBILE NUMBER: 0918398233


Summative Feedback:

Internal verification:
CONTENTS

I. Introduction

- JAVA was developed by James Gosling at Sun Microsystems Inc in the year 1995, and later


acquired by Oracle Corporation. It is a simple programming language. Java makes writing,
compiling, and debugging programming easy. It helps to create reusable code and modular
programs. Java is a class-based, object-oriented programming language and is designed to have as
few implementation dependencies as possible. A general-purpose programming language made
for developers to write once run anywhere that is compiled Java code can run on all platforms that
support Java. Java applications are compiled to byte code that can run on any Java Virtual
Machine. The syntax of Java is similar to c/c++.

II. THEORY

1. ALGORITHM

1.1 What is an Algorithm?

- Algorithm, is a system of data processing processes in an order programmed by certain


parameters. In SEO, the “search engine” algorithm is the formula used by search engines to rank
web pages on their search results page. In the search engine, the creation of algorithms to find
websites of good quality, serving readers and reducing the time and lowest cost for search engines.
Nowadays, when information technology is more and more developed, applied to online business,
the SEO profession develops beyond the norm, which makes Google also regularly update the
algorithm to ensure a healthy playing field and for the future. users find the information most
effectively.

1.2 The purpose 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 more.

1.3 The importance of the algorithm:

- As part of the role of the algorithm introduced, the importance of the algorithm for practice is not
small. Algorithms help programmers assess whether new software is working effectively.

- Besides, to understand deeply what the algorithm is, you should predict the possible cases. This
has the effect of minimizing errors for new programs.
- Algorithms are not only used to find the results of good problems in the field of programming. It
is also used to find a way to solve life problems.

1.4 Some representations of the algorithm:

- Use natural language

+ Use everyday communication language to express the algorithm's steps.

- Use flow charts

+ Flowcharts are used to represent problem-solving steps through different shapes.

- Using pseudo-code

+ Pseudocode is a formal language that helps programmers develop algorithms. Pseudocode often
borrows the syntax of a certain language to represent the algorithm.

+ Pseudocode programs are not executable on the computer. They just help you sketch out an
algorithm and represent it in an easy-to-understand way before writing it in a programming
language.

1.5 The relationship between algorithms and programming languages.:

- Considering the algorithm, it must be considered that the algorithm works in any programming
language.

- Considering which programming language, it is necessary to understand what algorithm a certain


programming language needs to be affected to get desired results.

- Which programming language does that algorithm? When any programming language changes,
the algorithm changes to follow.

- What is the relationship between a programming language and an algorithm summarized by


Niklaus Wirth as follows: programming language + Algorithm = Program

1.6 Example of an algorithm (including flowchart or pseudocode, implementation code):

Ex: check if any 3 numbers entered from the keyboard are 3 sides of a triangle.

Flowchart:
Code:

2. PROGRAMMING DIRECTIONS

2.1. Procedural Programming:


- Definition: Procedural programming 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.
The first major procedural programming languages appeared circa 1957–1964, including Fortran,
ALGOL, COBOL, PL/I, and BASIC.[2] Pascal and C were published circa 1970–1972.

- Features of procedural programming:

+ While designing a program, POP follows a top-down programmatic approach.

+ Multi-system data allows multiple functions to be shared.

+ It also divides the larger program into smaller parts called functions.

+ It allows data to be moved around the system.

+ Data is converted by functions from one form to another

2.2. Object-Oriented Programming:


- Definition: Object-oriented programming (OOP) is a programming technique that allows
programmers to create objects in code that abstracts away objects.

- Features of object-oriented programming:

+ OOP models complex things as simple structures.

+ Reusable OOP code, which saves resources.

+ Makes debugging easier. Compared to finding errors in many places in the code, finding errors in
(pre-structured) classes is simpler and less time-consuming.

+ High security, protecting information through encapsulation.

+ Ease of project expansion.

- Main features of object-oriented programming:

+ Encapsulation

+ Inheritance

+ Polymorphism

+ Abstraction

2.3. Event-driven programming

- Definition: In computer programming, event-driven programming 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).

- In an event-driven application, there is generally a main loop that listens for events and then
triggers a callback function when one of those events is detected. In embedded systems, the same
may be achieved using hardware interrupts instead of a constantly running main loop. Event-driven
programs can be written in any programming language, although the task is easier in languages that
provide high-level abstractions, such as await and closures.

- Special features of the setup guide event: Applications, where control flows based on internal or
external events rather than the application's structure, are ideally suited for flexibility and
naturalness.

2.4 . The relationship of programming directions:


- Although there are various sorts of programming instructions, they might all represent the same
overall solution to the issue. However, each programming direction has advantages in terms of its
unique characteristics that allow programmers to mix programming approaches more efficiently
solve problems or pick the best programming path.

2.5 Compare programming directions

Procedural Oriented Object Oriented Event-Driven


Programming (POP) Programming (OOP) Programming (EDP)

Some use cases Create functions to An object is defined Make a form for users
of programming enter data, display it, as a person if it has to fill up with
directions sort it, etc. Create methods like input information like their
arrays to store and display as well as login details, data for
information. properties like name the interface to
and address. calculate with, etc.

Application of - Consider the issue Approach the issue Create a list of


programming in terms of its by identifying the techniques. Then,
directions features, and then potential objects, construct the main
implement the outlining their loop such that a
complete program characteristics and function checks the
following those uses, and figuring out occurrence of events,
features. how they are related calls the event handler
to one another. appropriate condition
- Complex features
to handle it, and links
are divided into Object-oriented
event handlers to
functions, which can programming (OOP)
events so that the
then be further uses object
correct function is
divided into smaller interaction to address
called when the event
functions, up until issues.
occurs.
you believe the
function is
sufficiently simple.

The reasons for - The program is very - You have multiple - Using the event
choosing those unique and few programmers who capturing system, you
applications elements were shared. don’t need to can do things that
understand each regular programming
- The program is
component. instructions can't, such
static and not
- There is a lot of as show the user a
expected to change
code that could be simple graphical
much over time.
shared and reused. interface connected to
- None or only a few
the code.
features are expected - The project is
to be added to the anticipated to change
project over time. often and be added to
over time.
- Different sections
can benefit from
different resources
like data-source or
hardware.

3. IDE, Debug, and some coding standards

3.1 IDE & Text editor

- Definition of IDE: IDE is an integrated environment for programmers to write code, code (short
for Integrated Development Environment) to develop and improve applications. Besides, this
environment also supports programmers with many utilities, such as + Compiler + Interpreter +
Debugger – Check for errors. + Highlight code – Highlight important sections of code. + Search for
codes. + Code directory organization.

- Definition of the Text editor: A text editor is any word processing program that you can use to
type and edit text. Hey, they don’t call it a text editor for anything... Word Pad and NotePad for
Windows and SimpleText and TextEdit for Mac are common text editors. Larger programs such as
Microsoft Word and Word Perfect are also text editors, but they have many more features. You can
write HTML code and create HTML pages with a simple text editor, as long as you know the
correct HTML syntax.

- How IDEs help in application development:

+ A Source Code Editor (code editor): used to write the source code for the application
+ Compiler and/or interpreter

+ Auto Build tool: It will help you link the source code and build the application automatically.
When running the program on localhost on the browser, the source code is also built on it, so it is
very convenient to visually observe the display interface of the program, and can also view the
source code, and can directly edit the code of HTML files, this change of code will change the
display interface directly. Visually observing what your program is doing and directly editing
HTML files and CSS elements for an element (1 tag/1 class...) is a great thing, with a lot of support
and reduction. maximum time spent designing CSS for program interface – the interface is an
indispensable element of web pages; An eye-catching, scientifically arranged, user-friendly
interface is always required in web application development.

+ Debugger: The IDE will make it easier for you to detect and debug.

- Advantages and disadvantages of IDE:

Advantages Disadvantages

- Less time and effort - Learning curve: IDEs are complicated tools.

- The entire purpose of an IDE is to make - Maximizing their benefit will require time
developing faster and easier. and patience. A sophisticated IDE may not be a
good tool for beginning programmers.
- Its tools and features are supposed to help
you organize resources, prevent mistakes, and - Will not fix bad code, practices, or design:
provide shortcuts. you still need to be proficient and meticulous.
An IDE will not eliminate efficiency or
- Enforce project or company standards: performance problems in your application.
Simply by working in the same development
environment, a group of programmers will - IDEs are like paintbrushes.
adhere to a standard way of doing things.

- Standards can be further enforced if the IDE


offers predefined templates, or if code libraries
are shared between different team
members/teams working on the same project.

- Compare the advantages and disadvantages of software development using IDE and software
development without using IDE:

Advantages Disadvantages

- helps increase developer productivity by - limited in software development, causing


combining features like editing, building, many errors
testing, and packaging software into one easy-
to-use application.

3.2 Debug

- Definition: is the process of finding and discovering errors as well as the causes of these errors to
have a fix. Error control of thousands of lines of code is not easy for programmers, especially those
who do not have much experience.

-Purpose of debugging: Debugging is not only to remove errors from the program but also to help
programmers better understand the program and the software that is running. Therefore, debugging
is also an ability used to assess the level of the programmer.

-The importance of debugging: Debugging is important because it allows software engineers and
developers to fix errors in a program before releasing it to the public. It's a complementary process
to testing, which involves learning how an error affects a program overall. If you examine each
section of code, you can discover which variables and functions to adjust systematically. Debugging
can also improve the quality of a product, which may increase the number of positive reviews a
company receives.

-Example of a debugging process (including processing and results):

Step 1: Reproduce the problem.


Step 2: Describe the bug. Try to get as much input from the user to get the exact reason.
Step 3: Capture the program snapshot when the bug appears. Try to get all the variable values and
states of the program at that time.

Step 4: Analyse the snapshot based on the state and action. Based on that try to find the cause of the
bug
Step 5: Fix the existing bug, but also check that any new bug does not occur.

Example: enter 3 real numbers a, b, c. Check if a, b, and c are sides of a triangle


-Logic Errors: As we see in the above example, we have not declared the real numbers a, b, and c so
the program will not run. We will debug by adding declaration statements a, b, and c.
- Conclusion: after declaring a,b,c, the program can run

3.3 Coding Standards

-Definition: Think of coding standards as a set of rules, techniques, and best practices to create
cleaner, more readable, more efficient code with minimal errors. They offer a uniform format by
software engineers can use to build sophisticated and highly functional code.

- Some code standards:

+ Naming Convention

+ Rule of quantity

+ Disembarkation Rules

+ Comment

- Purpose and role of coding standards:

+ Offers uniformity to the code created by different engineers.

+ Enables the creation of reusable code.

+ Makes it easier to detect errors.


+ Make code simpler, more readable, and easier to maintain.

+ Boost programmer efficiency and generates faster results.

- Purpose, the role of coding standards

Purpose of the coding standards Role of the coding standards

- Boost team productivity faster. - Easy to maintain and fix.

- Code Convention's operating rules of - Let others understand your source


consistency and compliance with code.
standards will make it easier for you to
- Unify code among team members.
work.

- When writing Code using Code


Convention, it will make it easier for
others to understand and grasp what you
convey.

- Code Convention software is easy to


upgrade and improve.

- Code Convention is reusable in many


other software and applications.

- System maintenance with Code


Convention becomes more convenient
and easier than ever.

III. Practice (practice the problem at the request of the topic)

1. Math problem, problem analysis (input, output, handle)


- Math problem:
+ Phone management information includes functions: add, update, delete, display and manage tools
including search and sort by price, and release date.

- Input: IMEI, Name, price, RAM, ROM, screen_size, width, thickness, foundIMEI, name,
manufacturer, chip, month, year, day, choose1, choose2, choose3, choose4, choose5.

- Output:

+ Display
+Filter by manufacturer
+Filter by price
+Order by release desc
+Order by price desc

- Handle: Create 3 classes including main, Phones and Menus Create an ArrayList named
phonesList to manage the phones after adding and putting the phones into the phone list through the
created Phones data type object.

And after creating an object with data types Phones and ArrayList PhoneList:
+Add phone function:
+Update phone function:
+Delete phone function
+Display all phone functions:
+ Phone filter tool by manufacturer:
+ Phone filter tool by price:
+ Order by release desc
+ Order by price desc

2. Draw flowcharts or write pseudocode:

-Charts:
- Filter By Manufacturer:
- Order By Release Date:
- Filter By Price:
- Order By Price:
3. Code Deployment

•Class Main:

- Main and Main Menu:

- Menu Phone and Menu Tools:


- Code to use the menu:
•Class Phone:

- Declare the variables used in the Phone class:


- Insert Phone:
- Update Phone:
- Delete Phone:
- Display all:
- Filter by manufacturer:
- Order by release date:

- Filter by price:
- Order by price:

4. Results of the program:

- Menu:
- Menu Phone:

- Menu Tools:

- Insert new phone:


-- Update:
- Delete:

- Display All:

- Filter by manufacturer:
Order by release date:
- Filter by price:

- Order by price:
5. Debug the code of the written program

- I use breakpoints to debug a line of code that I want to test:

- After that, choose Debug to check :

6. Coding standards applied in the program, how to apply

- Naming rules: The naming of identifiers (including variables, constants, classes, etc.) also has a
significant impact on the readability of the code. Imagine a giant software like Windows but each
function is only named like a, b, c, function1, function2, ... then surely the management and
maintenance of the code is extremely difficult. There are three common naming rules: camelCase,
PascalCase, and snake_case. and in the code, I use Pascal Case and Snake Case
- Some general rules for naming:

+ Unambiguous naming that properly describes the function of the identifier.

+ Abbreviations should not be used.

+ Class and variable names often use nouns.

+ Function names often use verbs.

+ It is not recommended to use magic numbers (using numbers directly in the code) but should give
a separate name for the constant. For example:

- Rule of quantity:

+ A line of code should not be more than 80 characters long.

+ A statement should nest up to 4 levels.

+ A function should contain no more than 5 parameters.

+ A function should be no more than 30 lines.

+ A class should not exceed 500 lines,…

+ Each function should only do one thing, if it serves two different purposes, the function name
should clearly show this.

- Disembarkation Rules:

+ If a function has multiple levels of nesting, each level should be a new line.

+ The qualifications code should be in the same column together, the line down should start at the
same level as the line above.

+ Newline before operators (eg +, -, *, ?,...).

- Comment rules:

+Avoid using comments to explain code or comment on obvious facts

+ Delete unused code, do not comment out that code.

+ Comment warning consequences.

+ Comments clarify the meaning of the code (if the logic is complex).

You might also like