Professional Documents
Culture Documents
Modern Programming Concepts in Engineering: Topic 1: Introduction
Modern Programming Concepts in Engineering: Topic 1: Introduction
Topic 1: Introduction
Matthias Baitsch
Vietnamese-German Universit y
About the course. . .
Goals of the course
Problems can not be solved simply by trial and error, rather a rich
set of methods and concepts is required
What are modern programming concepts in engineering?
Short answer
Because object-oriented programming works!
Why object-oriented programming (OOP)?
Short answer
Because object-oriented programming works!
Long answer
Because object-oriented programming
I provides a natural and powerful way to model actual
(engineering) problems
I simplifies the development of software which is extensible and
maintainable
I lets developers split software up into separate, reusable parts
I helps developers to build reliable software systems
I simplifies programming in a team of programmers
→ OOP helps to keep complex software systems manageable
Choosing a programming language for MPCE
We use Java because Java is
I strictly object-oriented
I comparatively easy to learn
I a modern programming language
I supported by various freely available development
environments
I platform independent and programs are portable
We do we not use
I Fortran: Not object oriented, limited to numerics
I C++: Widely used and powerful but hard to learn
I C#: Would be an alternative but proprietary
I Visual Basic: Not suitable for numerical computations
Languages in green: Widely used in engineering
The Java Virtual Machine
Compiled language Java VM
a
Often, VMs are implemented in C
The Java Virtual Machine
Disadvantages
I Impact on execution speed
I Java needs to be installed on the target computer
Summary
Blue Gene at Sandia national labs Linux cluster Bochum Laptop computer Mobile phone
Computers are
I coming in very different flavours
I becoming faster and more powerful
I nowadays everywhere
I present in nearly every aspect of daily life
Network device
Sensor
Interactive programs
I are started by users by clicking an icon
I send and receive data from devices such as monitor, printer,
network card, speakers, hard disk drive
I react on user input from mouse and keyboard
Console program
Console programs
I are started by users by typing a command
I typically do not require user input during execution
I most often store results of computation on the hard disk
I are common in scientific and high-performance computing
Program running on a server computer
html document
Web browser
Server programs
I are started automatically when the computer starts up
I run for weeks or months
I usually do not require any user interaction
I interact with other programs running on another computer
Programs turn computers into specialized machines
Examples:
I Start Word – Your computer becomes a machine for writing a
letter (for your thesis, you might use something else)
I Start Ansys – Your computer becomes a machine for
structural analysis
Program execution
Data
Flow Start of program execution
Monitor Program
Sensor
Program termination
A program
I has a well-defined entry point where program execution starts
I receives input from communication devices
I sends data to communication devices
I reads and writes data to persistent storage devices
I has one or more conditions which terminate program execution
writes a
Program
A programmer
which
a user
runs on
a computer
Building and running programs
using writes a
Program
A programmer
a computer
which
a user
runs on
a computer
Building and running programs
using writes a
Program
A programmer
a computer
which
users
run on
their computers
Building and running programs
using write a
Program
programmers
computers
which
users
run on
their computers
What makes a program a good program?
A good program is
correct: It does what it’s supposed to. This sounds trivial but
do you know any program which never crashes?
extensible: It is easy to change and to add new functionality
readable: The program source code is understandable to
humans!
reusable: Parts of the program can be used later to build other
programs (prevent reinvention of the wheel)
robust: It reacts appropriately to errors
secure: It does not let others misuse your computer
Writing computer programs
y
g = 9.81 m/s²
Node at (0, 0) x
Constraint
n1 . s e t C o n s t r a i n t ( c ) ;
sct . setDiameter ( 0 . 1 ) ;
m. c r e a t e E l e m e n t ( Truss2D . TYPE, mat , s c t , n1 , n2 ) ;
m. c r e a t e E l e m e n t ( Truss2D . TYPE, mat , s c t , n2 , n3 ) ;
m. g e t S e t t i n g s ( ) . s e t A c c e l e r a t i o n (DOF . T Y , 9 . 8 1 ) ;
A n a l y s i s T y p e s . n o n l i n e a r T r a n s i e n t (m, 2 0 , 2 0 0 0 , 1 e − 6 , 0 . 7 ) ;
V i e w e r 2 v i e w e r = new V i e w e r 2 (m) ;
viewer . s e t V i s i b l e ( true ) ;
}
}
The running program
Summary
I Today, engineering and computing are closely connected
I Computers are universal machines
I Feeding a computer with a program turns the computer into a
specialized machine
I An executing program is an immaterial machine
I Object-oriented software models can be close to the problem
domain
I Existing libraries can provide powerful functionality