2. What weâll Learn
ï” Simple Programming Logic
ï” Program Development Cycle
ï” Integrated Development Environments(IDEs)
ï” Compilers and Interpreters
ï” Types of Errors
ï” Programming Paradigms
ï” Introduction to Java
ï” Principles of Good Programming
5. Compilers and Interpreters
ï” Programs that are written in a high-
level language must be translated
into machine language
ï” A compiler is a program that
translates a high-level language
program into a separate machine
language program
ï” The machine language program
can then be executed any time it is
needed
6. Compilers and Interpreters
ï” An Interpreter is a program that both
translates and executes the
instructions in a high-level language
program.
ï” As the interpreter reads each
individual instruction in the program,
it converts it to machine language
instructions and then immediately
executes them
7. Errors
ï” Syntax error
a mistake such as a misspelled key word, a missing
punctuation character, or the incorrect use of an
operator.
ï” Logical error
The logical error is an error that leads to an undesired
output. These errors produce the incorrect output, but
they are error-free, known as logical errors.
ï” Semantic error
errors that occurred when the statements are not
understandable by the compiler.
8. Compile Time vs Run-Time errors
Compile-time Runtime
The compile-time errors are
the errors which are
produced at the compile-
time, and they are detected
by the compiler.
The runtime errors are the
errors which are not
generated by the compiler
and produce an unpredictable
result at the execution time.
In this case, the compiler
prevents the code from
execution if it detects an
error in the program.
In this case, the compiler
does not detect the error, so
it cannot prevent the code
from the execution.
It contains the syntax and
semantic errors such as
missing semicolon at the end
of the statement.
It contains the errors such as
division by zero, determining
the square root of a negative
number.
9. What does a programmer do?
ï” Understanding the problem,
planning the logic,
ï” Coding the program,
ï” Translating the program into
machine language,
ï” Testing the program,
ï” Putting the program into production,
and
ï” Maintaining it.
10. Tools Used to Write
Programs
1.Text Editor
ï” A text editor is a type of computer
program that edits plain text
ï” Text editors are embedded in operating
systems and software development
packages,
ï” Used to change files such as
configuration files, documentation files
and used to write program source
codes.
11. Integrated Development Environment
ï” A software application that provides
comprehensive facilities to computer
programmers for software development.
ï” IDEs present a single program in which all
development is done.
ï” It provides many features for authoring,
modifying, compiling, deploying and
debugging software
ï” The package should contain at least:
ï” Source Code editor
ï” Compiler
ï” Build Automation Tools
ï” Debugger
12. Benefits of Using IDE
Faster Set-Up
Developers have the same set of capabilities in
one place, without the need for constantly
switching tools.
Faster development tasks
Tighter integration of all development tasks
improves developer productivity
Improves Organisation
IDEâs tools and features helps developers
organize resources, prevent mistakes and
take shortcuts.
13. Programming
Paradigms
Procedural Programming
ï” Derived from structured programming,
based upon the concept of calling
procedure.
ï” e.g FORTRAN, ALGOL, COBOL, BASIC,
Pascal and C.
OOP
ï” Based upon the concept of objects.
ï” Objects contain data in the form of
attributes and code in the form of
methods.
ï” e.g Java, C++, C#, Python, PHP,
JavaScript, Ruby, Perl, Objective-C, Dart,
Swift, Scala.
14. BASIS OF COMPARISON OBJECT ORIENTED
PROGRAMMING (OOP)
PROCEDURAL ORIENTED
PROGRAMMING (POP)
Division Of Program
In object oriented
programming, program is
divided into parts
referred to as objects.
In procedural oriented
programming, program is
divided into small parts
referred to as functions.
Data Movement
Objects can move and
communicate with each
other through member
function.
Data can move freely
from function to function
in the system.
Importance
Importance is given to
the data rather than
procedures or functions
because it works as
a real world.
Importance is not given
to data but to functions
as well as sequence of
actions to be done.
Approach
Object oriented
programming follows
Bottom Up approach.
Procedural oriented
programming follows Top
Down approach.
15. BASIS OF COMPARISON
OBJECT ORIENTED
PROGRAMMING (OOP)
PROCEDURAL ORIENTED
PROGRAMMING (POP)
Code Reusability
The existing code in object
oriented programming can
be reused by the feature
referred to as inheritance.
There is no such feature in
procedural oriented
programming.
Addition of New Data And
Function
In object oriented
programming, adding new
data and function is easy.
Adding new data and
function is not easy in
procedural oriented
programming.
Problem Size
It is suitable for solving big
problems.
It is not suitable for solving
big problems.
Data Access
In object oriented
programming, data cannot
move easily from function to
function, it can be kept
public or private so we can
control the access of data.
In procedural oriented
programming, most function
uses global data for sharing
that can be accessed freely
from function to function in
the system.
Examples
Examples of object oriented
programming languages
include: C++, Java, VB.NET,
C#.NET and Python.
C, VB, Fortran and Pascal
are common examples of
procedure oriented
languages.
16. BASIS OF COMPARISON OBJECT ORIENTED
PROGRAMMING (OOP)
PROCEDURAL ORIENTED
PROGRAMMING (POP)
Virtual Classes
Concept of virtual
function appears during
inheritance.
No concept of virtual
classes.
Most Important Attribute
Data is more important
than function.
Function is more
important than data.
Access Modes
In Object oriented
programming, there are
three accessing modes
âpublicâ, âprivateâ,
âprotectedââ that are
used as an accessing
share to access attributes
or functions.
In procedural oriented
programming, there is no
specific accessing mode
to access attributes or
functions in the program.
17. Introduction To Java
ï” James Gosling (a Canadian computer scientist),
at Sun Labs, around 1992 Invented Java.
ï” Used to build visually interesting graphical user
interface (GUI) and Web-based applications.
ï” Java is supported by many operating system,
ï” Java is cross-platformed OR platform
independent.
18. Properties Of Java
1. JAVA IS A ROBUST LANGUAGE -The main features of java that makes
it robust are garbage collection, Exception Handling and
memory allocation.
2. JAVA IS SECURE - A lot of security futures are built into java that
makes it secure. That is why several security flaws are almost
impossible to exploit in Java (examples of such security flaws arestack
corruption or buffer overflow).
3. MULTITHREADING -. Multithreading is a Java feature that allows
concurrent execution of two or more parts of a program for
maximum utilisation of CPU.
4. PORTABLE - âWrite once, run anywhereâ (WORA) is a slogan
developed by Sun Microsystems to describe the ability of one Java
program version to work correctly on multiple platforms.
19. Editions of Java
ï” Java Platform, Standard Edition (Java SE) is the Java platform
for developing client- side applications, which run on desktops,
and applets, which run in web browsers
ï” Java Platform, Enterprise Edition (Java EE) is the Java platform
built on top of Java SE, which is used exclusively to develop
enterprise-oriented server applications. Server- side
applications include servlets, which are Java programs that
are similar to applets but run on a server rather than a client
ï” Java Platform, Micro Edition (Java ME) is also built on top of
Java SE. It is the Java platform for developing MIDlets, which
are Java programs that run on mobile information devices,
and Xlets, which are Java programs that run on embedded
devices (eg ATMs, printers, calculators, thermostats .....)
20. Java Program
Execution
ï” -A Java bytecode is a
machine instruction for a
Java processor. A file of
bytecodes is a machine
language program for a
Java processor.
ï” The javac program is a
compiler (a translator) that
translates the source
program into a bytecode file
called Hello.class.
21. Java Environment
ï” JDK: Java Development - Kit, The JDK is a software development
environment used for developing Java applications and applets.
It includes the Java Runtime Environment (JRE), an
interpreter/loader (java), a compiler (javac), an archiver (jar), a
documentation generator (javadoc) and other tools needed in
Java development.
ï” JRE: Java Run-time Environment is an environment where Java
applications only be ran and not developed (client system). It is
part of the Java Development Kit (JDK), and provides the
minimum requirements for executing a Java application; it
consists of the Java Virtual Machine (JVM), core classes, and
supporting files.
ï” JVM: Java Virtual Machine, is the environment responsible for the
actual execution of a Java program
22. Principles of Good Programming
ï” DONâT REPEAT YOURSELF
As soon as you start repeating yourself (e.g. a long expression, a series of
statements, same concept) create a new abstraction.
ï” ABSTRACTION
Each significant piece of functionality in a program should be
implemented in just one place in the source code.
ï” AVOID REDUNDANCE
You should try not to add functionality until you need it.
ï” SIMPLICITY
Simple code takes less time to write, has fewer bugs and is easier to modify.
23. Principles of Good Programming
ï” EASILY READABLE
The code should be easily read and understood with a minimum of effort
required.
ï” Extension/Modification
Software entities (classes, modules, functions, etc.) should be open for
extension,
but closed for modification. In other words, do not write classes that people
can modify. Write classes that people can extend.
ï” Code Re-Usability
Reusing code improves code reliability and decreases development time.
ï” Avoid Premature Optimization
ï” Minimize Coupling
ï” All modules should be independent as far as possibleâMaintainability
Code Should be Maintainable