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

Introduction

This document introduces programming concepts including algorithms, problem solving steps, program development process, and documentation. Key points covered include defining algorithms, analyzing problems, designing solutions, coding programs, testing and debugging. Flowcharts and use case diagrams are discussed as tools for design.

Uploaded by

Trung Kiên
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

Introduction

This document introduces programming concepts including algorithms, problem solving steps, program development process, and documentation. Key points covered include defining algorithms, analyzing problems, designing solutions, coding programs, testing and debugging. Flowcharts and use case diagrams are discussed as tools for design.

Uploaded by

Trung Kiên
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 43

Programming

Introduction
Topics
 Course introduction
 Problem solving and algorithm
 Program development steps
 Practice

Unit 1 - Programming / Lecture 1 - Introduction 2


Course introduction

 This unit introduces students to the core concepts of programming


with an introduction to algorithms and the characteristics of programming
paradigms
On successful completion of this unit students will be able to design and
implement a simple computer program in a chosen language (C#) within
a suitable IDE (Visual Studio .NET)

Unit 1 - Programming / Lecture 1 - Introduction 3


Learning outcomes
 LO1: Define basic algorithms to carry out an operation and outline the
process of programming an application.
 LO2: Explain the characteristics of procedural, object-orientated and
event-driven programming, conduct an analysis of a suitable Integrated
Development Environment (IDE)
 LO3: Implement basic algorithms in code using an IDE.
 LO4: Determine the debugging process and explain the importance of
a coding standard

Unit 1 - Programming / Lecture 1 - Introduction 4


Assignment for course
 Login to CMS
 Choose correct class
 Enroll by class name
CMS Folder:
o Assignment 1
o Assignment 2

Unit 1 - Programming / Lecture 1 - Introduction 5


Course preparation
 Drawing tools (choose one):
o Visio
o Draw.io or Lucichart (online)
o Astah (recommendation, using student email to register full version)
 IDE
o Visual Studio Community 2017 or 2019

Unit 1 - Programming / Lecture 1 - Introduction 6


COURSE READING
 Learning materials on FLM
o https://flm.greenwich.edu.vn/
 C# 6.0 and .NET Framework 4.6
o http://library.books24x7.com/toc.aspx?bookid=104367
o Registered with student email
 Mohammad Rahman, Expert C#5.0 with .NET 4.5 Framework

Unit 1 - Programming / Lecture 1 - Introduction 7


Problem solving
 It’s a creative process, it is an act of
o Defining a problem
o Determining the cause of the problem
o Identifying, prioritizing, and selecting alternative for a solution
o Implementing a solution

Unit 1 - Programming / Lecture 1 - Introduction 8


Algorithm
 An algorithm is a step-by-step description of the solution to a problem.
 Characteristics of an Algorithm
o Definiteness: Each step must be precisely defined; the actions to be carried out must be rigorously
and unambiguously specified for each case
o Finiteness: The algorithm must always terminate after a finite number of steps.
o Precise and Effective: All operations to be performed must be sufficiently basic that they can be
done exactly and in finite length.
o Implementation independent: An algorithm should have step-by-step directions, which should be
independent of any programming code

Unit 1 - Programming / Lecture 1 - Introduction 9


Algorithm
 Example of Algorithms in Programming
Algorithm to add two numbers entered by the user
Step 1: Start
Step 2: Declare variables num1, num2 and sum.
Step 3: Read values num1 and num2.
Step 4: Add num1 and num2 and assign the result to sum.
sum = num1+num2
Step 5: Display sum
Step 6: Stop

Unit 1 - Programming / Lecture 1 - Introduction 10


Steps in Program Development

The various steps involved are


o Defining or Analyzing the problem
o Design (Algorithm)
o Coding
o Documenting the program
o Compiling and running the program
o Testing and Debugging
o Maintenance

Unit 1 - Programming / Lecture 1 - Introduction 11


STEPS IN Program Development:
1. Analyzing or Defining the Problem
The problem is defined by doing a preliminary investigation
Defining a problem helps us to understand problem clearly
It is also known as Program Analysis

Unit 1 - Programming / Lecture 1 - Introduction 12


Tasks in defining a problem

 Followings are the tasks in order to


define a problem
o Specifying the input requirements
o Specifying the output requirements
o Specifying the processing requirements

Unit 1 - Programming / Lecture 1 - Introduction 13


Specifying the input requirements
The input specification is obtained by answering following questions
o What specific values will be provided as input to the program?
o What format will the values be?
o For each input item, what is the valid range of values that it may assume?
o What restrictions are placed on the use of these values?

Unit 1 - Programming / Lecture 1 - Introduction 14


Specifying the output requirements
The output specification is obtained by answering the following questions
o What values will be produced?
o What is the format of these values?
o What specific annotation, headings, or titles are required in the report?
o What is the amount of output that will be produced?

Unit 1 - Programming / Lecture 1 - Introduction 15


Specifying the processing requirements
The processing requirement is obtained by answering following questions
o What is the method (technique) required in producing the desired output?
o What are the validation checks that need to be applied to the input data?
o What calculations are needed?

Unit 1 - Programming / Lecture 1 - Introduction 16


Activity: Find Factorial Number
Input?
Output?
Process?

Unit 1 - Programming / Lecture 1 - Introduction 17


Activity Find Factorial Number
Input: Positive integer number
Output: Factorial of that number
Process: Solution technique which transforms input to output. Factorial of a
number can be calculated by the formula n!=1*2*3*…*n

Unit 1 - Programming / Lecture 1 - Introduction 18


Use-case diagram
Use case diagrams are used to gather the requirements of a system
So when a system is analyzed to gather its functionalities, use cases are
prepared and actors are identified.
The purposes of use case diagrams can be as follows:
o Used to gather requirements of a system
o Used to get an outside view of a system
o Identify external and internal factors influencing the system
o Show the interacting among the requirements are actors

Unit 1 - Programming / Lecture 1 - Introduction 19


Main elements of use-case diagram

Unit 1 - Programming / Lecture 1 - Introduction 20


Activity: Draw use-case diagram
You are hired to develop FAI’s library system with following description
- Admin who could
- Manage books, readers (staff, lecturers, and students), etc.
- Manage borrow/return books
- Users (staff, lecturers, students) who could
- View/search books
- Reserve books
- Borrow/return books
Please draw Use-case diagram for this scenario
Unit 1 - Programming / Lecture 1 - Introduction 21
STEPS IN Program Development:
2. Design
A design is the path from the problem to a solution in code
The well designed program is likely to be:
o Easier to read and understand later
o Less of bugs and errors
o Easier to extend to add new features
o Easier to program in the first place

Unit 1 - Programming / Lecture 1 - Introduction 22


Modular Design
Once the problem is defined clearly, several design methodologies can be
applied
An important approach is Top-Down program design
It is structured design technique
o It breaks up the problem into a set of sub-problems called Modules
o It creates a hierarchical structure of the modules

Unit 1 - Programming / Lecture 1 - Introduction 23


Flowchart
Flowchart is a diagrammatic representation of an algorithm
It uses different symbols to represent the sequence of operations, required to
solve a problem
It serves as a blueprint or a logical diagram of the solution to a problem

Unit 1 - Programming / Lecture 1 - Introduction 24


Flowchart symbols (1/2)

Unit 1 - Programming / Lecture 1 - Introduction 25


Flowchart symbols (2/2)

Unit 1 - Programming / Lecture 1 - Introduction 26


Activity: Drawing flowchart
 Draw a flowchart for the algorithm to find factorial number in
previous activity

Unit 1 - Programming / Lecture 1 - Introduction 27


STEPS IN Program Development:
3. Coding
 An algorithm expressed in programming languages is called Program
 Writing a program is called Coding
 The logic that has been developed in the algorithm is used to write program

Unit 1 - Programming / Lecture 1 - Introduction 28


STEPS IN Program Development:
4. Documenting the Program
 Document explains
o How the program works and how to use the program (user manual)
o How to maintain the program (developer manual)
 Details of particular programs, or particular pieces of programs, are easily for
gotten or confused without suitable documentation

Unit 1 - Programming / Lecture 1 - Introduction 29


Forms of documentation
Documentation comes in two forms
o External documentation, which includes things such as reference manuals, algorithm
descriptions, flowcharts, and project workbooks
o Internal documentation, which is part of the source code itself (essentially, the
declarations, statements, and comments)

Unit 1 - Programming / Lecture 1 - Introduction 30


STEPS IN Program Development:
5. Compiling and Executing the Program
Compilation is a process of translating a source program into machine
understandable form
The compiler is system software
o It examines each instruction for its correctness
o It does the translation
During the execution
o Program is loaded into the computer’s memory
o The program instructions are executed

Unit 1 - Programming / Lecture 1 - Introduction 31


STEPS IN Program Development:
6. Testing and Debugging
Testing is the process of executing a program with the deliberate intent of
finding errors
Testing is needed to check whether the expected output matches the actual
output
Testing is done during every phase of program development
Initially, requirements can be tested for its correctness
Then, the design (algorithm, flow charts) can be tested for its exactness and
efficiency

Unit 1 - Programming / Lecture 1 - Introduction 32


Test criteria
Programs are tested with several test criteria and the important ones are
given below
o Test whether each and every statement in the program is executed at least one (Basic
path testing)
o Test whether every branch in the program is traversed at least once (control flow)
o Test whether the input data flows through the program and is converted to an output
(data flow)

Unit 1 - Programming / Lecture 1 - Introduction 33


Significant test cases
Significant test cases increase the possibility to discover bugs.
It is important to design test cases for abnormal input conditions
o The boundary (or extreme) cases
o The unusual cases
o The invalid cases

Unit 1 - Programming / Lecture 1 - Introduction 34


STEPS IN Program Development:
6. Testing and Debugging
 Debugging is a process of correcting the errors
o Programs may have logical errors which cannot be caught during compilation
o Debugging is the process of identifying their root causes
o One of the ways is to print out the intermediate results at strategic points of
computation
o Another way is to use support from the IDE
 Testing vs Debugging
o Testing means detecting errors
o Debugging means diagnosing and correcting the root causes

Unit 1 - Programming / Lecture 1 - Introduction 35


STEPS IN Program Development:
7. Maintenance
 Program maintenance
o Continuing process of maintenance and modification
o To keep pace with changing requirements and technologies
 Maintainability of the program is achieved by
o Modularizing it
o Providing proper documentation for it
o Following standards and conventions (naming conventions, using symbolic constants,
etc.)

Unit 1 - Programming / Lecture 1 - Introduction 36


INTRODUCTION TO PROGRAMMING LANGUAGE

Unit 1 - Programming / Lecture 1 - Introduction 37


What is a Programming Language?
It is an art of making a computer to do the required operations
o By means of issuing sequence of commands to it
It can be defined as
o A vocabulary (unique set of characters/keywords)
o A set of grammatical rules (syntax)
The term programming languages usually refers to high-level languages
o E.g., BASIC, C, C++, COBOL, FORTRAN, Ada, and Pascal

Unit 1 - Programming / Lecture 1 - Introduction 38


Types of programming languages

There are two major types of programming languages


o Low level languages (LLL)
o High level languages (HLL)

Unit 1 - Programming / Lecture 1 - Introduction 39


What makes a good language?
Every language has its strengths and weaknesses
FORTRAN is good for numeric data but not good to organize large program
PASCAL is good for structured and readable programs, but it is not as flexible
as C
C++ has powerful object-oriented features, but it is complex and difficult to
learn
The choice of PL depends on type of the computer used, type of program,
and the expertise of the programmer

Unit 1 - Programming / Lecture 1 - Introduction 40


Development Environments
Programming on Host Environment:
o The environment under which a program is designed, coded, tested and debugged
Operating on Target Environment
o The external environment which supports the execution of a program Target

Hello.c Hello.exe
Hello.exe
Unit 1 - Programming / Lecture 1 - Introduction 41
Summary
 Draw a mind-map to summarize the content of this lecture

Unit 1 - Programming / Lecture 1 - Introduction 42


Install Visual Studio - IDE
 Install Visual Studio 2019
https://visualstudio.microsoft.com/vs/

Unit 1 - Programming / Lecture 1 - Introduction 43

You might also like