Functions, Return Values, Parameters Getters and Setters

Slides:



Advertisements
Similar presentations
User-Defined Functions Like short programs Can operate on their own data Can receive data from callers and return data to callers.
Advertisements

1 Classes and Data Abstraction Chapter What a Class ! ! Specification and implementation Private and public elements Declaring classes data and.
Evan Korth New York University Computer Science I Classes and Objects Professor: Evan Korth New York University.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Lecture 9 Concepts of Programming Languages
More C++ Bryce Boe 2013/07/18 CS24, Summer 2013 C.
Programming Paradigms Imperative programming Functional programming Logic programming Event-driven programming Object-oriented programming A programming.
CSCI 130 Chapter 2. Program Components main() #include Variable Definition Function Prototype Program Statements Function Call Function Definition Comments.
Object Oriented Software Development
Using Data Active Server Pages Objectives In this chapter, you will: Learn about variables and constants Explore application and session variables Learn.
Chapter 6: User-Defined Functions I Instructor: Mohammad Mojaddam
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC BUILDING BLOCKS Bilal Munir Mughal 1 Chapter-5.
Lecture Set 11 Creating and Using Classes Part B – Class Features – Constructors, Methods, Fields, Properties, Shared Data.
Introduction to TypeScript Sergey Barskiy Architect Level: Introductory.
Advanced Object- Oriented Programming Programming Right from the Start with Visual Basic.NET 1/e 14.
Functions, Procedures, and Abstraction Dr. José M. Reyes Álamo.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 6 Using Methods.
Agenda Object Oriented Programming Reading: Chapter 14.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC PROGRAMMING FUNDAMENTALS Bilal Munir Mughal 1 Chapter-8.
Overview The Basics – Python classes and objects Procedural vs OO Programming Entity modelling Operations / methods Program flow OOP Concepts and user-defined.
CS0007: Introduction to Computer Programming Classes: Documentation, Method Overloading, Scope, Packages, and “Finding the Classes”
Chapter 3 Top-Down Design with Functions Part II J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National.
08 Encapsulation and Abstraction. 2 Contents Defining Abstraction Levels of Abstraction Class as Abstraction Defining a Java Class Instantiating a Class.
Object-Oriented Programming Chapter Chapter
Object-Oriented Programming. Objectives Distinguish between object-oriented and procedure-oriented design. Define the terms class and object. Distinguish.
CSci 162 Lecture 10 Martin van Bommel. Procedures vs Objects Procedural Programming –Centered on the procedures or actions that take place in a program.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 6: User-Defined Functions I.
Chapter 3: User-Defined Functions I
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 6: User-Defined Functions I.
Constructors A constructor is a method that has the same name as the class itself It is automatically called when an object is instantiated (in other words,
5.1 Basics of defining and using classes A review of class and object definitions A class is a template or blueprint for an object A class defines.
SCORE Sequence Choices to be made Once may not be enough Reuse and recycle Evaluate and improve.
Abstract Factory Pattern Jiaxin Wang CSPP Winter 2010.
1 Classes and Data Abstraction Chapter What a Class ! ! Specification and implementation Private and public elements Declaring classes data and.
INTRODUCTION TO CLASSES & OBJECTS CREATING CLASSES USING C#
Chapter 6: User-Defined Functions I
Phil Tayco Slide version 1.0 Created Sep 18, 2017
IS 350 Application Structure
Information Marketing Group, Inc.
Abstract Data Types and Encapsulation Concepts
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Using Multiple Forms.
ATS Application Programming: Java Programming
Lecture 9 Concepts of Programming Languages
Control Structures (Structured Programming) for controlling the procedural aspects of programming CS1110 – Kaminski.
User Defined Functions
Classes and Data Abstraction
Abstract Data Types and Encapsulation Concepts
Introduction to Data Structures
Lecture 22 Inheritance Richard Gesick.
Classes & Objects: Examples
Object oriented vs procedural programming
Data Structures and Algorithms for Information Processing
Controls, Properties, and Procedures
What language other than MXML you can use for writing a Flex Application.
Chapter 6: User-Defined Functions I
CIS16 Application Development and Programming using Visual Basic.net
Object-Oriented Programming
Recitation 5 In this recitation you will have an example on displaying multiple objects on ObjectEditor. The code can be found in the recitation page.
Controls, Properties, and Procedures
Functions, Return Values, Parameters Getters and Setters
Predefined Functions Revisited
Control Structures (Structured Programming) for controlling the procedural aspects of programming CS1110 – Kaminski.
CMSC 202 Exceptions.
Lecture 8 Object Oriented Programming (OOP)
Functions, Procedures, and Abstraction
Encapsulation.
CSG2H3 Object Oriented Programming
Lecture 9 Concepts of Programming Languages
Presentation transcript:

Functions, Return Values, Parameters Getters and Setters

Procedures in Everyday Life We use procedures all time – fire drill or recipe They are set up in advance with a detailed set of instructions We only refer to them (Call them) when we need them Procedures allow us to repeat the same task over and over again

Function Procedures Procedures in programming languages are the same They are set up in advance with a detailed set of instructions We only refer to them (Call them) when we need them Procedures allow us to repeat the same task over and over again

Functions are used to make… Event handlers Public methods in a class Public properties in a class Constructors None of the above just a function

Function Example

Return Values Two parts of the function work together…

Pick the Return Data Type

Calling Functions May use function with the assignment operator… When a function call is completed the flow of code returns to the line where the call was made from!

Ignoring the Return Value

Void Functions

Parameters This code is not very versatile… Add parameters…

Use the Parameters

Calling the Function with Parameters

Benefits of Functions Give greater functionality Hide complexity Promote code re-use Simplify maintenance

Functions gives Greater Functionality When we want to use the function we simply call it

Hides Complexity Who cares how it works?

Simplify Maintenance Create a function Call it multiple times around our system Need to make a change Modify the one function definition All of the multiple calls benefit from the change

Functions Promote Code re-use A function should perform one task well Accept enough data via parameters for the task Return an appropriate value Organise into class libraries Allow us to recycle code

Public v Private Public function in a class file Becomes a method in an object

Functions and Public Properties Getters and Setters

Using the Debugger with Functions Use the sample driving test 2 as an example