CIV 257- COMPUTER PROGRAMMING Lecture 2 CIVIL AND GEOMATIC ENGINEERING FT Okyere.

Slides:



Advertisements
Similar presentations
Programming Paradigms and languages
Advertisements

Visual Basic Introduction IDS 306 from Shelly, Cashman & Repede Microsoft Visual Basic 5: Complete Concepts and Techniques.
ASP.NET Programming with C# and SQL Server First Edition
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
C++ fundamentals.
Copyright © 2001 by Wiley. All rights reserved. Chapter 1: Introduction to Programming and Visual Basic Computer Operations What is Programming? OOED Programming.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
 A data processing system is a combination of machines and people that for a set of inputs produces a defined set of outputs. The inputs and outputs.
Programming Paradigms Imperative programming Functional programming Logic programming Event-driven programming Object-oriented programming A programming.
Microsoft Visual Basic 2012 CHAPTER ONE Introduction to Visual Basic 2012 Programming.
Microsoft Visual Basic 2005 CHAPTER 1 Introduction to Visual Basic 2005 Programming.
Object Oriented Software Development
A First Program Using C#
Visual Basic Chapter 1 Mr. Wangler.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
Learning Objectives Data and Information Six Basic Operations Computer Operations Programs and Programming What is Programming? Types of Languages Levels.
Microsoft Visual Basic 2005: Reloaded Second Edition
An Object-Oriented Approach to Programming Logic and Design
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
Chapter 6 Understanding the Structure of an Application: Procedures, Modules, and Classes.
Design patterns. What is a design pattern? Christopher Alexander: «The pattern describes a problem which again and again occurs in the work, as well as.
CHAPTER ONE Problem Solving and the Object- Oriented Paradigm.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
CSCI-383 Object-Oriented Programming & Design Lecture 13.
Computer Concepts 2014 Chapter 12 Computer Programming.
Chapter 7 Objects and Classes 1 Fall 2012 CS2302: Programming Principles.
Representing Data: Constants and Variables CHAPTER THREE Matakuliah: T0063 – Pemrograman Visual Tahun: 2009.
Lecture Set 11 Creating and Using Classes Part B – Class Features – Constructors, Methods, Fields, Properties, Shared Data.
Computer Programs and Programming Languages What are low-level languages and high-level languages? High-level language Low-level language Machine-dependent.
Advanced Object- Oriented Programming Programming Right from the Start with Visual Basic.NET 1/e 14.
Working with the VB IDE. Running a Program u Clicking the”start” tool begins the program u The “break” tool pauses a program in mid-execution u The “end”
Chapter 12 Computer Programming. Chapter Contents Chapter 12: Computer Programming 2  Section A: Programming Basics  Section B: Procedural Programming.
University of Sunderland CIF 102/FIF102 Fundamentals of DatabasesUnit 15 Programming in Microsoft Access using VBA Using VBA to add functionality.
Object-Oriented Design Simple Program Design Third Edition A Step-by-Step Approach 11.
Chapter Two Creating a First Project in Visual Basic.
Principles of Software Development 1 Principles Of Software Design and Development Types of language / Choosing a language.
Applications Development
1 Programming Paradigms Object Orientated Programming Paradigm (OOP)
Chapter 4 Introduction to Classes, Objects, Methods and strings
Theory of Programming Languages Introduction. What is a Programming Language? John von Neumann (1940’s) –Stored program concept –CPU actions determined.
Practical Programming COMP153-08S Week 5 Lecture 1: Screen Design Subroutines and Functions.
INM205 Object Oriented Programming in JAVA Dr. Michael Casey Department of Computing.
1.
Chapter One An Introduction to Programming and Visual Basic.
Salman Marvasti Sharif University of Technology Winter 2015.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
Introduction to Object-Oriented Programming Lesson 2.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
Algorithms and Computer Programming. Algorithms algorithm is an ordered sequence of instructions for solving a problem. Look at it as a building blocks.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
Object-Oriented Programming: Classes and Objects Chapter 1 1.
Software Design and Development Languages and Environments Computing Science.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
CPS120: Introduction to Computer Science Lecture 16A Object-Oriented Concepts.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
Algorithms and Flowcharts
OCR A Level F453: High level languages Programming techniques a. identify a variety of programming paradigms (low-level, object- oriented,
IS 350 Course Introduction. Slide 2 Objectives Identify the steps performed in the software development life cycle Describe selected tools used to design.
Visual Basic.NET Windows Programming
Object-Orientated Programming
Concepts of Object Oriented Programming
Programming Logic and Design Seventh Edition
PRINCIPALES OF OBJECT ORIENTED PROGRAMMING
An Introduction to Visual Basic
Computer Programming.
VISUAL BASIC.
CIS16 Application Development Programming with Visual Basic
Chapter One: An Introduction to Programming and Visual Basic
Presentation transcript:

CIV 257- COMPUTER PROGRAMMING Lecture 2 CIVIL AND GEOMATIC ENGINEERING FT Okyere.

Expressing and executing algorithms To express algorithms we use a programming language which is a means to write down the instructions of an algorithm in a form that allows: – Humans to write and read them (a means of communication between people) – A machine to execute the instructions without further human intervention (we do not have to further explain the steps to the machine) A computer is seen in the context of computer programming learning as an algorithm execution machine. A computer system provides support to get information in and out in a form useful to humans.

Creation of algorithms Algorithms are created by your ingenuity Creativity Computers languages and computers are just a means to express and execute algorithms. They are like the paint and canvas, not the art. The algorithm is the art.

Principles of expressing algorithms When we write algorithms we need a way to: 1. Name both data and algorithms in a way that is unambiguous, flexible and easy to understand 2. Store and retrieve data using names and other identifying information 3. Operate on data using names and literal values (For example, 1, and "string" are literal values.) a. multiply numbers, add letter to word, display image

Principles of expressing algorithms 4. Apply an algorithm to data, both identified by name 5. Denote the order of operations 6. Express choice based on the data a. if this, then do that, otherwise do something else 7. Express repetition  repeat this task 1,000,000 times

Flow Charts A flow chart is a diagram of the sequence of operations in a computer program. The steps the algorithm must take are shown as boxes. The boxes are connected by arrows to show the order in which the steps follow. Flow charts are used in designing, analysing, in other fields of study

Flow Charts Start and end symbols -circles, ovals or rounded rectangles usually containing the word “start” or “end” or the equivalent. Flow of the program is =arrow symbol. An arrow coming from one symbol and ending at another symbol represents that control passes to the symbol the arrow points to. Processing steps =rectangles containing information about the process (example, “add text”). A condition or decision are represented as diamond (call it rhombus). These typically contain a Yes/No question or True/False test. It has two arrows coming in and out. The arrows are labelled as appropriate. The symbols should be labelled by writing a description of its function within the appropriate box.

Algorithm Example An arithmetic sum of two numbers, current deposit and account balance to obtain the current balance. We then compute the 5% interest of the currbal.

Flow Charts- Example

Diagram A and B are the same except; Diagram A is cumbersome because complete Words have been used in describing the function of boxes whiles Diagram B uses shorthand way of representing the algorithm also known as pseudocode(A notation resembling a simplified programming language, used in program design). For example curr for current, bal for balance and Acc for Account. Computation of the sum of two numbers, current deposit and account balance respectively to give the current balance. Decision on whether to calculate interest of 5% on the current balance or do something else. ????  Computation of 5% interest if the decision is ‘Yes’ current balance is greater than $100

Important Note No Handout No Score 30% ?Because Thievery cannot be rewarded! Fresh Juice costs 10 cedis! 75% Attendance or No Exams- check Student handbook! Dare and meet me again June 2013, lets start over again…

COMPUTER PROGRAMMING PARADIGMS or CONCEPTS Objects and Classes Assemblies Forms as objects Setting and retrieving properties Variables – Scalar – Array Datatypes Repetition, conditional statements Functions(Procedures or subroutine) Assigment

OOP AND Visual Basic Concepts There are two main computer programming paradigms; Procedural programming and the Object-Oriented Programming (OOP). A procedural programming language provides a programmer a means to define precisely each step in the performance of a task. Object Oriented Programming (OOP) is all about writing programs that manipulate objects. Object-oriented programming is a programming paradigm that uses "objects" – data structures consisting of datafields and methods together with their interactions – to design applications and computer programs. VB, Delphi, along with C++ and Java, are fully object oriented languages.

COMPUTER PROGRAMMING PARADIGMS or CONCEPTS What Is an Object? An object is a software bundle of related state and behavior. Software objects are often used to model the real-world objects that you find in everyday life.

COMPUTER PROGRAMMING PARADIGMS or CONCEPTS Classes and Objects The terms class and object are sometimes used interchangeably, but in fact, classes describe the structure of objects, while objects are usable instances of classes. Each instance is an exact yet distinct copy of its class. Because an object is an instance of a class, the act of creating an object is called instantiation. blueprints describe the items that form buildings

COMPUTER PROGRAMMING PARADIGMS or CONCEPTS The four principles of object oriented programming:  Abstraction  Encapsulation  Inheritance  Polymorphism Visual basic has evolved to become an object oriented language.

COMPUTER PROGRAMMING PARADIGMS or CONCEPTS Encapsulation means that a group of related properties, methods(procedure), and other members are treated as a single unit or object. Abstraction is achieved through encapsulation. Abstraction means to generalize or conceptualise

COMPUTER PROGRAMMING PARADIGMS or CONCEPTS Inheritance describes the ability to create new classes based on an existing class. The new class inherits all the properties and methods and events of the base class, and can be customized with additional properties and methods. class libraries can be purchased

COMPUTER PROGRAMMING PARADIGMS or CONCEPTS For example, you can create a new class named "Truck" based on the "Car" class. The "Truck" class inherits the "Colour“ property from the "Car" class and can have additional properties such as "Four WheelDrive.“ Polymorphism is the concept that different objects have different implementations of the same characteristic. For example, consider two objects, one representing a Porsche matic 2matic

Assemblies Assemblies are the most common source of objects for Visual Basic applications. The.NET Framework (as in Visual Basic.NET in MS VS 2005, 2008, 2010) includes assemblies that contain commonly used objects. Intrinsic objects Extrinsic objects (use imports statement)

Properties In Object Oriented programming we treat statements representing instructions as objects as explained above. Scientifically, objects or materials have properties. For example, a balloon Notice the order of the code- the object (Balloon),period, followed by the property (Colour), followed by the assignment of the value (= Red). You could change the balloon's colour by substituting a different value.

Properties of objects Properties you can set and read are called read-write properties. Properties you can read but not modify are called read-only properties. Properties you can write but not read are called write-only properties. You set the value of a property when you want to change the appearance or behaviour of an object. For example, you change the Text property of a text box control to modify the contents of the text box. Read-onlyRead-and-write

How to: Set and Retrieve Properties When working with forms and controls in Visual Basic, you can set their properties programmatically at run time (i.e. within the program), or you can set them in design mode using the Properties window. The properties of most other objects, such as objects from assemblies or objects you create, can only be set programmatically. E.g design mode and program’ty Button1.Anchor = AnchorStyles.Top Button1.Anchor = AnchorStyles.Left

How to: Set and Retrieve Properties To set property values Use the following syntax: Object.property = expression The following statements provide examples of how to set properties in Visual Basic:

How to: Set and Retrieve Properties To get property values Use the following syntax: Variable = Object.property You can also get a property value as part of a more complex expression, without assigning the property to a variable. The following code changes the Top property of a radio button control: i=i+1 is same as i+=1 x=x+1 is same as x+=1

Forms as Objects Forms are graphical objects that make up your application's user interface.

Forms as Objects Forms are graphical objects that make up your application's user interface. Within VisualBasic, classes define how forms are displayed and what they can do. Syntax: Public Class Form1 Public Sub PrintMyJob() ' Insert the code for your method here. End Sub End Class

Forms as Objects Public sub createnewform() Dim newForm1 As New Form1 newForm1.show() End sub The above code create a new form object called newForm1 and displays it.

Variable Naming Variables A variable is a convenient placeholder that refers to a computer memory location where you can store program information that may change during the time your script is running. For example, you might create a variable called ClickCount to store the number of times a user clicks an object on a particular Web page. Where the variable is stored in computer memory is unimportant. What is important is that you only have to refer to a variable by name to see or change its value. In VBScript, E.g temp=1, temp is the variable

Variable Naming Declaring Variables You declare variables explicitly in your script using the Dim statement, the Public statement, and the Private statement. For example: Dim DegreesFahrenheit - Dimensions DegreesFahrenheit as variable whose data type is not declared. Public myStr as string – Dimensions the variable myStr as a string in memory during run time Any time the program runs and comes to this line

Variable Naming Restrictions Name variables in a way that make sense to another user of your program. The variable name should suit the variable it represents. You can start the name with a lower case abbreviation that tells which container or object the variable is stored in, followed by a description of the variable. Example is ‘txtTax’. This variable stores its value in a textbox (abbreviated as txt) and stores an amount of tax. cmd- command button lbl- label. etc

Variable Naming Restrictions Variable names follow the standard rules for naming anything in VBScript. A variable name: Must begin with an alphabetic character. (E.g. 1vol is not a good variable name but vol is Cannot contain an embedded period. (vol.1 is not a good variable name but Vol1 is

Variable Naming Restrictions Must not exceed 255 characters. (keep variable names considerably simple but meaningful) thisisMyvariableanditisverylong Must be unique in the scope in which it is declared.