Unit 6
Unit 6
FUNDAMENTALS OF PROGRAMING
Definition of Algorithm
Some of the most widely used definitions of an algorithm are described here under.
ƒ
To solve the problem using computers, we must follow the steps described below.
Characterstics of Algorithm
1
Clear and unambiguous: The algorithm should be unambiguous. Each of
its steps should be clear in all aspects and must lead to only one meaning.
Well-defined inputs: If an algorithm says to take inputs, they should be
well-defined.
Well-defined outputs: The algorithm must clearly define what output will
be yielded and it should be well-defined as well.
Finiteness: The algorithm must be finite, i.e. it should not end up in infinite
loops or similar.
Feasible: The algorithm must be simple, generic and practical so that it can
be executed upon the available resources. It must not contain some future
technology or anything.
Language independent: The algorithm designed must be language
independent, i.e. it must be just plain instructions that can be implemented in
any language, and yet the output will be the same as expected.
Advantages of algorithm ƒ
2
In the algorithm the problem is broken down into smaller pieces or
steps; hence, it is easier for the programmer to convert it into an actual
program.
Disadvantages of algorithm
ƒ Step 2: If the number is less than 0, then display that the entered number is
negative.
ƒ Step 3: If the number is greater than 0, display that the entered number is
positive.
3
We need a way to describe our algorithms in a precise manner with a well-defined
syntax and clear, unambiguous semantics.
There are two main ways in which algorithms can be represented; they are
flowcharts and pseudo code.
An algorithm can be described using many techniques and tools. One tool for
designing an algorithm is by using a flowchart.
A flow chart for the program of displaying the sum of two numbers
4
Example 3: Write the algorithmic description and draw a flowchart to find
the sum of the first 50 natural numbers as stated: Sum = 1+2+3+…. + 50
Algorithmic description
ƒ Increase counter by 1.
5
6.5.2 Pseudocode
6
6.6 Integrated Development Environment (IDE)
7
Common Features of Integrated Development Environments
An IDE typically contains a code editor, a compiler or interpreter, and a debugger accessed
through a single graphical user interface (GUI). The user writes and edits source code in the code
editor. The compiler translates the source code into a readable language that is executable for a
computer. The debugger tests the software to solve any issues or bugs. The fundamental features
of IDE are discussed in the following. ƒ
Code editor: This feature is a text editor designed for writing and editing source code.
Source code editors are distinguished from text editors because they enhance or simplify
the writing and editing of code.
Text editors: Virtually every IDE will have a text editor designed to write and
manipulate source code. ƒ
8
Debugger: This tool is used during testing to help debug application programs. ƒ
Build automation tools: These tools automate common developer tasks. In addition,
some IDEs might also include the following:
Class browser: This tool is used to examine and reference the properties
of an object-oriented class hierarchy.
Object browser: This feature is used to examine the objects instantiated
in a running application program. ƒ
Class hierarchy diagram: This tool allows the programmer to visualize the structure of
object-oriented programming code. Note that IDE may be a stand-alone application or
may be included as part of one or more compatible applications.
The overall goal and main benefit of an integrated development environment are improved
developer productivity. IDEs boost productivity by reducing setup time, increasing the speed of
development tasks, keeping developers up to date and standardizing the development process.
Faster setup: Without an IDE interface, developers would need to spend time
configuring multiple development tools. With the application integration of an IDE,
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. For Example, code can be parsed and syntax checked while being
edited, providing instant feedback when syntax errors are introduced. Developers do not
9
need to switch between applications to complete tasks. In addition, the IDE’s tools and
features help developers organize resources, prevent mistakes and take shortcuts.
Further, IDEs streamline development by encouraging holistic thinking. They enforce
developers to think of their actions in terms of the entire development lifecycle, rather
than as a series of discrete tasks. ƒ
Continual learning: Staying up to date and educated is another benefit. For instance, the
IDEs topics are constantly being updated as well as new samples, project templates, etc.
Programmers who are continually learning and with current best practices are more likely
to contribute value to the team and the enterprise, and boost productivity.
Standardization: The IDE interface standardizes the development process which helps
developers work together more smoothly and helps new hires get up to speed more
quickly.
Some IDEs are designed to work with one specific language, cloud-based IDEs, IDEs
customized for the development of mobile applications or HTML and IDEs meant specifically
for Apple development or Microsoft development
Multi-language IDE
Multi-language IDEs such as Eclipse, NetBeans and Komodo support multiple programming
languages.
10
Eclipse: Supports C++, Python, PHP, Java and more. This free and open source editor
is model for many development frameworks. The eclipse began as a Java development
environment and has expanded through plugins. Eclipse is managed and directed by the
Eclipse.org Consortium. ƒ
NetBeans: Supports Java, JavaScript, PHP, Python, Ruby, C, C++ and more. This
option is also free and open source. All the functions of the IDE are provided by modules
that each provide a well-defined function. Support for other programming languages can
be added by installing additional modules.
IDE for mobile development: There are IDEs specifically used for mobile development,
for instance, Android Studio and Visual Studio. ƒ
HTML IDE: Some of the most popular IDEs are those for developing HTML
applications. For Example, IDEs such as HomeSite, DreamWeaver or FrontPage
automate many tasks involved in website development. ƒ
Cloud-based IDE: Cloud IDEs give developers access to their code from anywhere.
For Example, Nitrous is a cloud-based development environment platform that supports
more than 40 languages including PHP, Ruby, Python, JavaScript with Node.js and Go
11