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

EECE 310: Software Engineering Modular Decomposition, Abstraction and Specifications.
1 Classes and Data Abstraction Chapter What a Class ! ! Specification and implementation Private and public elements Declaring classes data and.
Customizing Word Microsoft Office Word 2007 Illustrated Complete.
Stored Procedures & User Defined Functions MacDonald Ch. 23 MIS 424 MIS 424 Professor Sandvig Professor Sandvig.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Chapter 6: User-Defined Functions I
Code Regions and XML Comments. Code Regions The code editor automatically puts little minus signs next to the header line for each Sub or Function. You.
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.
CMSC 202 Exceptions. Aug 7, Error Handling In the ideal world, all errors would occur when your code is compiled. That won’t happen. Errors which.
Lecture Set 11 Creating and Using Classes Part B – Class Features – Constructors, Methods, Fields, Properties, Shared Data.
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.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
Section 4 - Functions. All of the programs that we have studied so far have consisted of a single function, main(). However, having more than one function.
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”
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
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.
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#
IS 350 Course Introduction. Slide 2 Objectives Identify the steps performed in the software development life cycle Describe selected tools used to design.
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.
Functions CIS 40 – Introduction to Programming in Python
Lecture 9 Concepts of Programming Languages
Control Structures (Structured Programming) for controlling the procedural aspects of programming CS1110 – Kaminski.
Chapter 6 Sub Procedures
User Defined Functions
Classes and Data Abstraction
Abstract Data Types and Encapsulation Concepts
Functions, Procedures, and Abstraction
Lecture 22 Inheritance Richard Gesick.
Classes & Objects: Examples
Object oriented vs procedural programming
Abstract Class As per dictionary, abstraction is the quality of dealing with ideas rather than events. For example, when you consider the case of ,
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
Functions, Return Values, Parameters Getters and Setters
ICT Gaming Lesson 3.
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
Predefined Functions Revisited
Control Structures (Structured Programming) for controlling the procedural aspects of programming CS1110 – Kaminski.
Ch. 1 Vocabulary Alice.
CMSC 202 Exceptions.
Lecture 8 Object Oriented Programming (OOP)
Functions, Procedures, and Abstraction
Programming Techniques
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

A Function by any other name Often referred to by different names Function Function procedure Sub procedure Sub Stored procedure

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

Functions are used to make… Event handlers Public methods in a class Public properties in a class Constructors Test cases 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

Public Functions to make Methods Public function in a class file Becomes a method in an object

Public Functions to make Properties - Getters and Setters

Using the Debugger with Functions