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

PROGRAM TITLE: Higher National Diploma In Computing

UNIT TITLE: 1: Programming

ASSIGNMENT NUMBER: 2

ASSIGNMENT TITTLE: Paradigms

DATE RECEIVED: 19/5/2021

TUTORIAL LECTURER: NGUYEN MINH TRANG

WORD COUNT: 2585

STUDENT NAME: Do Tran Trong Hieu

STUDENT ID: BKC18368

PHONE NUMBER: 0336 810 146

MAIL: hieudo.0601@gmail.com
Summative Feedback:

Internal verification:
LO2. EXPLAIN THE CHARACTERISTICS OF PROCEDURAL, OBJECT-
ORIENTATED AND EVENT-DRIVEN PROGRAMMING.

• Give explanations of what procedural, object-orientated and event-driven paradigms


are

A Programming-languages communicates with machines by giving it instructions, they are


used to create programs for a machine of a computer.

• Procedural programming:

Procedural language is a list of instructions telling a computer, step-by-step. In this


programming practice developer write line by line code which executes a single action each line.
In procedural programming first line of code is executed, then the second, then the third and so
on, lines cannot jump from the 1st to the 7th to achieve something it must first complete 1-6 in
order to get to the 7th line. procedural programming also focuses on the idea that all algorithms
are executed with functions and data that the developer has access to and is able to change.
Procedural programming uses a top down approach to executing codes. Examples of procedural
languages are – BASIC, COBOL, PASCAL, FORTRAN, C and PL1.

• Object orientated programming - OOP

OOP languages are very popular and they widely used in various different software
applications and games.

Object orientated programming refers to the creation of reusable software object types and
classes that can be efficiently developed and easier incorporated into multiple programs. Unlike
the procedural programming practice which is a top down approach to executing the code OOP
is a bottom up approach.

OOP also provides data hiding which improves the programs security, for example you can set
public, private, internal and protected label on a class to make sure no one from outside the
program can see the inner workings of your program.
In OOP an object presents an entity in the real world (the properties we talked about before). An
OOP program is a collection of objects that interact to solve a task or problem.

Example of object orientated programming languages are C#, Java, Action Script, C++,
Objective C, Ruby on Rails and others.

• Event driven programming

Event driven programming is a paradigm which is determined by events or user actions E.G
clicking on a mouse. It can only be used using a graphical user interface which is one of its main
features. It can interact with any hardware that is attached to a computer and is not a complex
program to use. A program can easily be developed and all of the properties used in the program
are all independent so they can save altogether saving the programmer time and effort saving
them separately.

Event driven programming uses the following coding types Visual Basic, java, java script and
C++. Java script can be used to provide interactivity for web pages. Visual basic provides a
graphical user interface for the user. Java is used in applications such as games etc and C++ is a
professional programming language which is complex but works similar to java.

• Definitions of: data types (the role of constants/variables), methods (including


input/output), control structures, iteration, scope, parameter passing, classes,
inheritance and events.

• Data types (the role of constants/variables):

Data types are the classification or categorization of data items. It represents the kind of value
that tells what operations can be performed on a particular data.

Since everything in this subject is an object in Python programming, data types are actually
classes and variables are instance (object) of these classes.

Following the standard data types in Python:


• Numeric

In Python, numeric data type represent the data which has numeric value. Numeric value can
be integer, floating number or even complex numbers. These values are defined
as int, float and complex class in Python.
• Integers – This value is represented by int class. It contains positive or negative
whole numbers (without fraction or decimal). In Python there is no limit to how
long an integer value can be.

• Float – This value is represented by float class. It is a real number with floating
point representation. It is specified by a decimal point. Optionally, the character e or
E followed by a positive or negative integer may be appended to specify scientific
notation.
• Complex Numbers – Complex number is represented by complex class. It is
specified as (real part) + (imaginary part)j. For example – 2+3j

• Dictionary
Dictionary in Python is an unordered collection of data values, used to store data values
like a map, which unlike other Data Types that hold only single value as an element,
Dictionary holds key: value pair. Key-value is provided in the dictionary to make it more
optimized. Each key-value pair in a Dictionary is separated by a ‘colon’, whereas each key is
separated by a ‘comma’.

• Boolean
Data type with one of the two built-in values, True or False. Boolean objects that are equal to
True are truthy (true), and those equal to False are falsy (false). But non-Boolean objects can
be evaluated in Boolean context as well and determined to be true or false. It is denoted by the
class bool.

• Set
Set is an unordered collection of data type that is iterable, mutable and has no duplicate
elements. Items in a set are not ordered. Set is defined by values separated by comma
inside braces { }
• Sequence Type
In Python, sequence is the ordered collection of similar or different data types. Sequences
allows to store multiple values in an organized and efficient fashion. There are several
sequence types in Python:
• String:
In Python, Strings are arrays of bytes representing Unicode characters. A string
is a collection of one or more characters put in a single - quote, double - quote or triple
- quote. In python there is no character data type, a character is a string of length one. It
is represented by str class.
• List:
Lists are just like the arrays, declared in other languages which is an ordered
collection of data. It is very flexible as the items in a list do not need to be of the same
type.
• Tuple:
Just like list, tuple is also an ordered collection of Python objects. The only
difference between type and list is that tuples are immutable i.e. tuples cannot be
modified after it is created. It is represented by tuple class.

• Methods (including input/output):

Input usually means the data entered by the end-user of the program. When you use Microsoft
Word, you are playing the role of the end-user (sometimes shortened to just plain 'user'). When
you play a video game, you are its 'end-user'. When programming, we often switch between
playing the role of programmer and end-user. We're the end-user when we are testing whether
the program works. We usually call the program itself the system, as in:

'when the end-user enters a number, the system responds by...'

Input can also come from a file. For instance, when you type 'python someprog.py' the program
called 'python' is getting its input from a file called someprog.py.

Output is what the program produces. For command-line programs, it's just whatever is printed
on the screen. Of course, for programs with graphical user interfaces, the output is much more
complex.

According to the structure theorem, any computer program can be written using the
basic control structures. A control structure (or flow of control) is a block of programming that
analyses variables and chooses a direction in which to go based on given parameters. In simple
sentence, a control structure is just a decision that the computer makes. So, it is the
basic decision-making process in programming and flow of control determines how a computer
program will respond when given certain conditions and parameters.

There are two basic aspects of computer programming: data and instructions. To work with


data, you need to understand variables and data types; to work with instructions, you need to
understand control structures and statements. Flow of control through any given program is
implemented with three basic types of control structures: Sequential, Selection and Repetition

• Iteration: Iteration is a general term for taking each item of something, one after another.
Any time you use a loop, explicit or implicit, to go over a group of items, that is iteration.

• Scope:

In programming, the scope of a name defines the area of a program in which you can
unambiguously access that name, such as variables, functions, objects, and so on. A name will
only be visible to and accessible by the code in its scope. Several programming languages take
advantage of scope for avoiding name collisions and unpredictable behaviors. Most commonly,
you’ll distinguish two general scopes:

• Global scope: The names that you define in this scope are available to all your
code.

• Local scope: The names that you define in this scope are only available or visible
to the code within the scope.

• Parameter passing:

All parameters (arguments) in the Python language are passed by reference. It means if you
change what a parameter refers to within a function, the change also reflects back in the calling
function.

• Classes:

Classes provide a means of bundling data and functionality together. Creating a new class creates
a new type of object, allowing new instances of that type to be made. Each class instance can
have attributes attached to it for maintaining its state. Class instances can also have methods
(defined by its class) for modifying its state.

Python classes provide all the standard features of Object-Oriented Programming: the class
inheritance mechanism allows multiple base classes, a derived class can override any methods of
its base class or classes, and a method can call the method of a base class with the same name.
Objects can contain arbitrary amounts and kinds of data. As is true for modules, classes partake
of the dynamic nature of Python: they are created at runtime and can be modified further after
creation.

• Inheritance and events:

• Compare and contrast the procedural, object-oriented and event driven paradigms
used in given source code of an application
The relationship between procedural, object-oriented and event-driven paradigm:

• Procedural programming means that as a series of steps, you describe a program and its
subprograms. On the other hand, declarative programs attempt to define the result
irrespective of the steps taken to calculate it but rather some description or denotation of
the desired result.

• Object-oriented programming is a way to organize code around the concepts of


encapsulation, inheritance, replacement, programming to interfaces, etc.

• 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.

• These three categories are thus not related strictly hierarchically, but in common usage
they are mostly nested within one another
 Table of comparison:

Paradigm Description Main Traits Related Examples


paradigms
Procedural Derived from structured Local variables, sequence, Structured,
programming, based on the selection, iteration, and imperative C, C++, Lisp, PHP,
concept of modular modularization  Python
programming or
the procedure call
Event- Control flow is determined Main loop, event Procedural,  JavaScript, ActionSc
driven mainly by events, such handler, asynchronous dataflow ript,
as mouse clicks or interrupts processes  Visual Basic, Elm
including timer
Object- Treats data Objects, methods, message Procedural Common Lisp, C+
oriented fields as objects manipulated passing, information +, C#, Eiffel, 
through hiding, data Java, Kotlin, PHP, 
predefined methods only abstraction, encapsulation,  Python, Ruby, Scala, 
polymorphism, inheritance JavaScript
, serialization-marshalling

• Define what is an IDE, key components of an IDE with a brief explanation each
component.

Definition of IDE:

IDE stands for Integrated Development Environment. It is a software application that


provides facilities for developing software. It consists of tools such as source code editor,
automation tools, and debugger. Most IDEs have compilers and interpreters. Therefore, it is
easier to write the code and compile it. Some IDEs support various languages. For example, in
Microsoft Visual Studio IDE, the developer can write programs in languages such as C#, C++,
Visual Basic, and JavaScript.
Furthermore, most IDEs have intelligent code completion. When the programmer types the code,
the IDE provides the list of matching options or commands. Therefore, the programmer can
easily select the required command from that. Also, the GUI makes it easier to organize the code.
Overall, an IDE provides all the necessary tools in a single environment to make the
development process easier.
What is the definition of Text Editor, IDE?

• Text Editor

A text editor is a computer program that lets a user enter, change, store, and usually print text
(characters and numbers, each encoded by the computer and its input and output devices,
arranged to have meaning to users or to other programs). Typically, a text editor provides an
"empty" display screen (or "scrollable page") with a fixed-line length and visible line numbers.
You can then fill the lines in with text, line by line. A special command line lets you move to a
new page, scroll forward or backward, make global changes in the document, save the document,
and perform other actions. After saving a document, you can then print it or display it. Before
printing or displaying it, you may be able to format it for some specific output device or class of
output device. Text editors can be used to enter program language source statements or to create
documents such as technical manuals.

A popular text editor in IBM's large or mainframe computers is called XEDIT. In UNIX systems,
the two most commonly used text editors are Emacs and Vi . In personal computer systems,
word processor s are more common than text editors. However, there are variations of mainframe
and UNIX text editors that are provided for use on personal computers. An example is KEDIT,
which is basically XEDIT for Windows.

• IDE :An integrated development environment (IDE) is software for building applications
that combines common developer tools into a single graphical user interface (GUI). An IDE
typically consists of:

• Source code editor: A text editor that can assist in writing software code with features
such as syntax highlighting with visual cues, providing language specific auto-
completion, and checking for bugs as code is being written.

• Local build automation: Utilities that automate simple, repeatable tasks as part of
creating a local build of the software for use by the developer, like compiling computer
source code into binary code, packaging binary code, and running automated tests.

• Debugger: A program for testing other programs that can graphically display the location
of a bug in the original code.
• Use of addition of advanced text editors to view code (Visual Studio Code, Sublime
Text, ...)

• Visual Studio Code:

Visual Studio Code is a code editor developed by Microsoft for Windows, Linux,
and macOS. It supports functional debugging, comes with Git, has syntax
highlighting, smart autocompletion, code snippets, and code enhancements. It also
allows for adjustments, so users can change themes, turn off keyboard shortcuts
and other options. It is free and open source software code, even though the
packages themselves are downloaded by themselves, they are still licensed.
• Subline Text:

Sublime Text is a shareware cross-platform source code editor with a Python


application programming interface (API). It natively supports many programming
languages and markup languages, and functions can be added by users with
plugins, typically community-built and maintained under free-software licenses.

You might also like