Procedural and Object-Oriented Programming Chap 1 Notes
- Created by: Osman_S
- Created on: 29-10-17 20:59
Procedural and Object-Oriented Programming
Procedural & Object-oriented programming are the two popular approaches to writing computer programs.
- When you write a procedural program, you use your knowledge of a programming language to create and name computer memory locations (variables) that can hold values, and you write a series of steps to manipulate those values - e.g. a simple payroll program might contain instructions similar to the following:
- get hoursWorked
- pay = hoursWorked * 10.00
- outpay pay
For convenience, the individual operations (steps) used in a procedural program often are grouped into logical units called methods. E.g. a series of 4 or 5 comparisons and calculations that together determine an employee's withholding tax value might be grouped as a method named CalculateWithholdingTax().
- Capitalizing the first letter of all new words in an identifier, including the first one, as in CalculateWithholdingTax(), is a style called Pascal casing (upper camel casing).
- You can start a method with a lower case letter, however the convention is used in C# is for methods to be named using Pascal casing - it helps distinguish them from variables which use lower camel casing.
- Additionally, in C# all method names are follwed by a set of brackets ()
A procedural program divides a problem solution into multiple methods. The program then calls/invokes the methods to input, manipulate and output the values stored in these locations. A single procedural program often contains hundreds of variables and thousands of method calls.
Object-oriented programming (OOP) is an extension of procedural programming. OOP uses variables and methods like procedural programs do, but it focuses on objects.
- An Object is a concrete entity that has attributes and behaviours.
- The attributes of an object are the features it "has"; the values of an object's attributes constitute the state of the object.
- The behaviours of an object are things it "does".
With either approach, procedural or object-oriented, you can produce a correct paycheck, and both techniques employ reusable program modules. The major difference lies in the focus the programmer takes during…
Comments
No comments have yet been made