Higher Nationals in Computing: Assignment No.2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

Higher Nationals in Computing

Programming

ASSIGNMENT

No.2

Learner’s Name: Nguyen Phuc Khang

Assessor Name: NGUYEN VAN SON

Class: GCS0803B
ID: GCS18036
Assignment due: 19/03/2020
Assignment submitted: 1 7 / 0 3 / 2 0 2 0
ASSIGNMENT 2 FRONT SHEET
Qualification BTEC Level 5 HND Diploma in Computing

Unit number and


Unit 1: Programming
title

Submission date Date Received 1st submission

Re-submission Date Date Received 2nd submission

Nguyễn
Student Name Phúc Student ID GCS18036
Khang

Nguyễn Văn
Class GCS0703B Assessor name
Sơn

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

Grading grid
P2 P3 P4 P5 M2 M3 M4 D2 D3 D4

❒ Summative Feedback: ❒ Resubmission


Feedback:

Grade: Assessor Signature: Date:


Lecturer Signature:
ASSIGNMENT 2 BRIEF
Qualification BTEC Level 5 HND Diploma in Computing

Unit number and


Unit 1: Programming
title

Assignment title Application development with IDE

Academic Year

Unit Tutor

Submission
Issue date
date

Submission Format:

Format: The submission is in the form of an individual written report. This should be
written in a concise, formal business style using single spacing and font size
12. You are required to make use of headings, paragraphs and subsections as
appropriate, and all work must be supported with research and referenced
using the Harvard referencing system. Please also provide a bibliography
using the Harvard referencing system.
Submission Students are compulsory to submit the assignment in due date and in a way
requested by the Tutors. The form of submission will be a soft copy in PDF
posted on corresponding course of http://cms.greenwich.edu.vn/
Note: The Assignment must be your own work, and not copied by or from another
student or from
books etc. If you use ideas, quotes or data (such as diagrams) from books, journals or
other sources, you must reference your sources, using the Harvard style. Make sure that
you know how to reference properly, and that understand the guidelines on plagiarism. If
you do not, you definitely get fail
Assignment Brief and Guidance:

Scenario: You have applied for a post as a trainee with a software development
company and have been invited for an interview. You have been passed the
presentation to demonstrate your problem solving and basic programming skills. Now
you are given a more challenge task to create a fully working, secure application that
has been developed using an IDE and adheres to coding standards for a detailed
business problem.

Tasks
You will discuss a suitable problem with your mentor and list the user requirements
before designing, implementing (coding) and testing a solution. You will create a
report that should include:
● Introduction to your program (list of requirements and screenshots of program)
● Explain some of programming paradigms. Evaluate why and how your program use
these (or some of) paradigms.
● Explain the common features of an IDE should have and evidence of how the IDE
was used to manage the development of your code.
● An evaluation of developing applications using an IDE versus developing an
application without using an IDE.
● An explanation and evaluation of the debugging process in the IDE used and how it
helped with development.
● An explanation and evaluation of coding standards used in your program and the
benefits to organisations of using them.

The working application produced must also be demonstrated together with the
presentation.

Learning Outcomes and Assessment Criteria

Pass Merit Distinction


LO2 Explain the characteristics of procedural, object-oriented and event-driven programming,
conduct an analysis of a suitable Integrated Development Environment (IDE)
P2 Give explanations of M2 Analyse the common D2 Critically evaluate the
what procedural, object- features that a developer has source code of an application
oriented and event-driven access to in an IDE. which implements the
paradigms are; their programming paradigms, in
characteristics and the terms of the code structure and
relationship between them. characteristics.
LO3 Implement basic algorithms in code using an IDE
LO4 Determine the debugging process and explain the importance of a coding standard
P3 Write a program that M3 Use the IDE to manage the D3 Evaluate the use of an IDE
implements an algorithm development process of the for development of applications
using an IDE. program. contrasted with not using an
IDE.

P4 Explain the debugging M4 Evaluate how the debugging D4 Critically evaluate why a
process and explain the process can be used to help coding standard is necessary in
debugging facilities available develop more secure, robust a team as well as for the
in the IDE. applications. individual.
P5 Outline the coding
standard you have used in
your code.
Table of Contents
P2 Give explanation of what procedural, object-oriented and event-driven paradigms are;
their characteristics and the relationship between them…………………………………….1
P3 Write a program that implements an algorithm using an IDE…………………………….5
P4 Explain the debugging process and explain the debugging facilities available in the IDE..13
P5 Outline the coding standard you have used in your code………………………………..15
Reference…………………………………………………………………………………….16
LO2 Explain the characteristics of procedural, object-oriented and event-
driven programming, conduct an analysis of a suitable Integrated
Development Environment (IDE)
P2 Give explanations of what procedural, object-oriented and event-driven paradigms are;
their characteristics and the relationship between them.
 Procedural programming:
 Definition :
Procedural programming is a programming paradigm that uses a linear or top-
down approach. It relies on procedures or subroutines to perform computations.
In procedural programming, a program consists of data and modules/procedures
that operate on the data.

In Procedural programming or Procedural-Oriented programming (POP), a


programmer will analyze and divide a large problem into several simple one , in
order to solve all the problem by the specific algorithm that can be easily
illustrated by the algorithm language. This analyze and design method called top-
down, so as to present the progress from the general to specific.

 Characteristic of Procedural programming (POP):


 Algorithm are more complex, hence are more difficult to design.
 Implementation of complex algorithm is difficult because of the size
of the program.
 Larger program, testing, debugging and maintenance will be difficult
 Facilitates top-down modular programming: Mudularity bring logical
clarity to the programs.

1
o Avoids the need for redundant code: Repeat instruction can be
written as a function, which can be called its is need.
 Facilitates re-usability: Create in one program can be used In others.

 Object-orientated programming:
 Definition:
Object Oriented Programming (OOP) is programming object orientation, object
programming method as the basis for the construction of algorithms, building the
program. In fact this is not a new method which is a new look in the programming.
We can imagine by the name of it that this algorithm solve the problem from
small to large by observing and imagining the actions, characteristics of real-life
entity and bring into programming as a virtual object. Through the class, object
which act as the function (method) and the main characteristics are the variables. Or
we could say that OOP is the art of observing of objects in their natural appearance
and trying to capture the functional abstractnesses in descriptive programming way,
and to visualize them as virtual-workable objects

 Characteristic of Object-oriented programming (OOP):


 Focusing on the data instead of the function.
 The program is divided into independent objects.
 The data structure is designed so that the specification of the object
data hiding, protection.
 The Exchange objects through the function.
 Programs are designed according to the bottom-up approach.
 Event-driven programming:

2
 Definition:
In software development, event-driven programming is a programming model in
which all business processing (business logic) are made in the source code of the
program. The stream processors at runtime of the program will be determined based
on events. Events here may refer to:
 Click on the button on the screen.
 Press the key on the keyboard.
 Hover .
 Timeout .
 The output signal of the sensor .
 Receive messages from other programs or threads.
 …
Event-driven programming model is mainly used in applications that focus on making
the processor responds to the user's manipulation.

 Characteristic of Event-driven programming:


 Time driven:
The time driven feature in event driven programming runs a specific code
on a timely basis like once an hour, once a week or once a month meaning it
is pre set to do a task on a time trigger. An example for this feature is the OS
update in your computer system can be set to check for updates once a
month or the anti-virus programme set to run a virus scan every day.
 Event Handler:
Event handlers in event driven programming are designed to run a
specific action when a specific event is triggered. There are numerous event

3
handlers an example of some are the keys in your keyboard when the letter
"t" is clicked wile in word document it sends a signal to input that letter, also
the "Ctrl + Alt + Del" buttons are clicked together it sends a signal to start up
task manager on your system. Also mouse movements trigger a software
routine that processes its actions to what the curse is doing on the display.
 Trigger Function:
Trigger functions in event driven programming are mechanisms that
decide what code to run when a specific event occurs, trigger functions are
used to select which event handler to use for the specific event that has
occurred. Many devices have trigger functions with a specific event that runs
for it.
 Event:
o Event is the key. Logic of program is represented by events.
o Programmer select event that is useful for program to implement
(not all).
 Mouse event:
Moving a mouse in certain directions causing cursor to respond to the
movements on the display. Scroll button up down and click. Left button click,
right button click, double click. All these triggers have a specific event tied to
them.

 Relationships between procedural, object-oriented and event-driven programming.

 Procedural programming means that you define a program and its subprograms as a
series of steps. In contrast, declarative programs try to describe the result without
regard to the steps taken to computer it but rather some description or denotation
of the desired result.

 Procedural programming is you define a program and its sub subprograms as a series
of step

 Object oriented programming is a way of organizing code around the principles of


encapsulation, inheritance, substitution, programming to interfaces, and so on.
Object oriented programs are usually mostly procedural.

 Event based programming is about writing event handling procedures and having the
core event loop provided by the underlying system. In this way you can save the
trouble of writing your own event loop and benefit from various libraries that
already work with the system provided event loop. Event based programs are very
often writing using object-oriented style, but not always.

4
 Therefore, there are not actually a relationship between procedural, object-oriented
and event-driven programming. Based on the problem, you pick the most efficiency
paradigm to solve the problem.

LO3 Implement basic algorithms in code using an IDE


LO4 Determine the debugging process and explain the importance of a
coding standard
P3 . Write a program that implements an algorithm using an IDE.
I’m have build an app called “Phone store management”, this app is used to
managing phone within the store. It have some basic feature like add new phone including
Phone’s name, Phone’s brand, Quantity, Phone’s price and amount. View all phone in the
store, count number of phones and calculate revenue.
Requirement:
 Add new phone (Name, Brand, Quantity, price, Amount)
 View all phones
 Count Number of phones
 Calculate revenue
 Search
Class diagram:

5
App:

Add:
When we enter 1, the program will allow us to add new data(phone) including phone’s
name, phone’s brand, phone’s quantity and phone’s price.

6
View:
When we enter 2, the program will show us all the phone that we have added.

Statistic:
When we enter3, the program will show the statistic of all the the phone.

7
Search:

Implementation:
Phone.cs:
using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace PhoneStore

class Phone

public String name { set; get; }

public String brand { set; get; }

public int quantity { set; get; }

public double price { set; get; }

public double amount { set; get; }

public Phone() { }

public Phone(String name, String brand, int quantity, double price)

8
{

this.name = name;

this.brand = brand;

this.quantity = quantity;

this.price = price;

this.amount = quantity * price;

public String _pName

get { return name; }

set { name = value; }

public String _pBrand

get { return brand; }

set { brand = value; }

public int _pQuan

get { return quantity; }

set { quantity = value; }

public double _pPrice

get { return price; }

set { price = value; }

Managephone.cs:
using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

9
using System.Threading.Tasks;

namespace PhoneStore

class ManagePhone

static private List<Phone> list = new List<Phone>();

public ManagePhone()

int choice;

do

Console.Clear();

Console.WriteLine("======MENU=======");

Console.WriteLine("1.Add new phone");

Console.WriteLine("2.View all phone");

Console.WriteLine("3.Statistic");

Console.WriteLine("4. Search");

Console.WriteLine("5. Exit");

Console.WriteLine("-----------------");

Console.WriteLine("Please choose:");

choice = int.Parse(Console.ReadLine());

switch (choice)

case 1: Add(); break;

case 2: View(); break;

case 3: Statistic(); break;

case 4: Search(); break;

Console.ReadKey();

} while (choice != 4);

//Add Function

public void Add()

10
{

Console.Write("Enter phone's name:");

String name = Console.ReadLine();

Console.Write("Enter brand:");

String category = Console.ReadLine();

Console.Write("Enter quantity:");

int quantity = int.Parse(Console.ReadLine());

Console.Write("Enter price:");

double price = double.Parse(Console.ReadLine());

list.Add(new Phone(name, category, quantity, price));

//View Function

public void View()

foreach (Phone x in list)

Console.WriteLine("{0}, {1}, {2} * {3} = {4}", x.name, x.brand,


x.quantity, x.price, x.amount);

//Show Statistic

public void Statistic()

int quan = 0;

double revenue = 0;

foreach (Phone x in list)

quan = quan + x.quantity;

revenue = revenue + x.amount;

Console.WriteLine("\nNumber of phones: {0}, Revenue: {1}", quan, revenue);

11
//Search Function

public void Search()

int max = list.Count;

for (int i = 0; i < max; i++)

if (list[i] == list[max - 1])

int choice;

Console.WriteLine("1.Find by Phone Name");

Console.WriteLine("2.Find by Phone Brand");

Console.WriteLine("--------------------");

Console.WriteLine("Choose funtion:");

choice = int.Parse(Console.ReadLine());

switch (choice)

case 1:

Console.WriteLine("Enter phone Name: ");

String n = Console.ReadLine();

var result = list.Find(d => d._pName == n);

if (result != null)

Console.WriteLine("Found: {0}, {1}", result._pName,


result._pBrand, result._pQuan, result._pPrice);

else

Console.WriteLine("Not found");

break;

case 2:

Console.WriteLine("Enter phone Brand: ");

String m = Console.ReadLine();

var result1 = list.Find(d => d._pBrand == m);

Console.WriteLine("Found: {0}, {1}, {2}, {3}",


result1._pName, result1._pBrand, result1._pQuan, result1._pPrice);

break;

12
}

Program.cs:
using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace PhoneStore

class Program

static void Main(string[] args)

ManagePhone p = new ManagePhone();

P4 Explain the debugging process and explain the debugging facilities available in the IDE.
Definition:
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.
To prevent incorrect operation of a software or system, debugging is used to find and
resolve bugs or defects. When various subsystems or modules are tightly coupled,
debugging becomes harder as any change in one module may cause more bugs to appear in
another. Sometimes it takes more time to debug a program than to code it.
Here’s the debugging process:
 Reproduce the problem.
 Describe the bug. Try to get as much input from the user to get the exact reason.

13
 Capture the program snapshot when the bug appears. Try to get all the variable values
and states of the program at that time.
 Analyse the snapshot based on the state and action. Based on that try to find the cause
of the bug.
 Fix the existing bug, but also check that any new bug does not occur.

The debugging facilities available in the IDE:


 Debuggers can help me do ad hoc inspection or alteration of variables, code, or any
other aspect of the runtime environment, whereas manual debugging requires me to
stop, edit, and re-execute the application (possibly requiring recompilation).
 Debuggers can attach to a running process or use a crash dump, whereas with manual
debugging, "steps to reproduce" a defect are necessary.
 Debuggers can display complex data structures, multi-threaded environments, or full
runtime stacks easily and in a more readable manner.
 Debuggers offer many ways to reduce the time and repetitive work to do almost any
debugging tasks.
 Visual debuggers and console debuggers are both useful, and have many features in
common.
 A visual debugger integrated into an IDE also gives you convenient access to smart
editing and all the other features of the IDE, in a single integrated development
environment (hence the name).

Example:

14
P5. Outline the coding standard you have used in your code.
Here are some coding standard that I have used in my code.
-Line indentation and spacing:
-Written to a tab for the commands located in the command block {}.

Written to space after the sign “,” and “;”

Uppercase:
All characters in the identifier must be capitalized. Use this rule to have the designation
from 2 characters back down.

The commands namspace and using:


Both these commands have to be close to the left.

15
Reference

https://economictimes.indiatimes.com/definition/debugging

https://link.springer.com/chapter/10.1007/978-3-642-13244-5_34

https://www.quora.com/How-does-IDE-help-in-the-debugging-procedure

https://stackoverflow.com/questions/426569/why-is-debugging-better-in-an-
ide

https://www.geeksforgeeks.org/coding-standards-and-guidelines/

16

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy