You are on page 1of 4

Component 4: Introduction to

Information and Computer Science

Unit 5: Overview of Programming

Languages, Including Basic
Programming Concepts
Lecture 5
This material was developed by Oregon Health & Science University, funded by the Department of Health and Human
Services, Office of the National Coordinator for Health Information Technology under Award Number IU24OC000015.

Unit 5 Objectives
a) Define the purpose of programming languages.
b) Define the different types of programming languages.
c) Explain the continuum of programming languages from
machine code and assembly languages through
scripting languages and high level structured
programming languages.
d) Explain the compiling and interpreting process for
computer programs.
e) Use the following components of programming
languages to build a simple program: variables, loops
and conditional statements.
f) Introduce additional programming concepts such as
objects and modularity.
Health IT Workforce Curriculum
Component 4/Unit 5-5 2
Version 2.0/Spring 2011

Object Oriented Programming

Object Oriented Programming (OOP) is a
Very popular today
C++, C#, Java, Python, Ruby
Supports software engineering principles
Graphical User Interface (GUI)
programming naturally conforms to OOP

Health IT Workforce Curriculum

Component 4/Unit 5-5 3
Version 2.0/Spring 2011

Objects have
Identity (name)
Attributes (instance variables)
Behavior (methods)
Way of organizing code
Data and related methods stored together
Allows for code reuse
Health IT Workforce Curriculum
Component 4/Unit 5-5 4
Version 2.0/Spring 2011

Classes vs. Objects

Classes are the code definition for objects
They are the "blueprint"
Objects are created when the program
Similar to declaring a variable

Health IT Workforce Curriculum

Component 4/Unit 5-5 5
Version 2.0/Spring 2011

Procedural vs. OOP

double circleArea(double class Circle
radius) {
{ double radius;
return 3.14*radius*radius; void setRadius(double rValue)
} {
radius = rValue;
In class, radius is stored }
with the calcArea method double calcArea()
In procedure, radius is {
passed into calcArea as a return 3.14*radius*radius;
parameter }
How would we add
circumference calculation?
Health IT Workforce Curriculum
Component 4/Unit 5-5 6
Version 2.0/Spring 2011

OOP Designs
Programs are BMICalculator

designed using tools double weight

double height
UML (Unified double bmi
void setWeight(double wValue)
Modeling Language) void setHeight(double hValue)
is very common void calcBmi()
void outputBmi()
Example for class of void outputBmiCategory()

Health IT Workforce Curriculum

Component 4/Unit 5-5 7
Version 2.0/Spring 2011

Inheritance is a powerful feature of OOP
Classes can inherit methods and instance
Makes coding less redundant
Allows for polymorphism

Health IT Workforce Curriculum

Component 4/Unit 5-5 8
Version 2.0/Spring 2011

String accountNum
double balance
void setAccountNum(double aValue)
void setBalance(double bValue)
double getBalance()
void printAccountInfo()

CheckingAccount SavingsAccount
double overdraft double interestRate
void setOverdraft(double oValue) void setInterestRate (double iValue)
double getOverdraft() void accrueInterest()

Child classes inherit all methods and instance variables from parent class

Health IT Workforce Curriculum

Component 4/Unit 5-5 9
Version 2.0/Spring 2011

Separation of code into components such as
Non object oriented languages implement
Allows for
reuse of code

Health IT Workforce Curriculum

Component 4/Unit 5-5 10
Version 2.0/Spring 2011

Objects can declare methods and instance variables
to be private or public
Typically instance variables are private
Some (all) methods are public
Class definition controls
Valid ranges for values
Rules for setting values, calling methods
Details of implementation are hidden
Interface is public methods & documentation

Health IT Workforce Curriculum

Component 4/Unit 5-5 11
Version 2.0/Spring 2011

Unit Summary
In this unit, you learned
The purpose of programming languages
Different types of programming languages
The compilation/interpreter process
Programming language constructs
Object Oriented Programming (OOP)
Gained an understanding
How programs are designed and implemented
What code looks like
What objects are and why they are used

Health IT Workforce Curriculum

Component 4/Unit 5-5 12
Version 2.0/Spring 2011