Chapter 11 - More Object Oriented Programming (Ferrell)

Ace your homework & exams now with Quizwiz!

IDE

acronym for integrated development environment, which is the visual development environment in some programming languages

whole-part relationship

an object of one class is contained within an object of another class

packages

another name for libraries in some language

constructor

automatically called method that establishes an object; a method that has the same name as the class; write any statement you want in a constructor; place the constructor anywhere inside the class (often listed first)

'exception' tye

built in exceptions in a programming language cannot cover every condition; create your own throwable exception extend a built in exception class

ancestors

of derived class are the entire list of parent classes from which the class is derived

abstract class

one from which you cannot create concrete objects, but from which you can inherit

visual development environment

one in which you can create programs by dragging components such as buttons and labels onto a screen and arranging them visually

derived class OR extended class

one that is extended from a base class

base class

one that is used as a basis for inheritiance

default constructor

one that requires no argument; created automatically by the compilier for every class you write

'throw' statement

one that sends an 'exception' object out of a method so it can be handled elsewhere

nondefault constructor

requires at least one argument; once you write a constructor for a class, you no longer receive the automatically written default constructor; if a class's only constructor requires an argument, you must provide an argument for every object of the class you create

libraries

stored collections of classes that serve related purposes

superclass and parent class

synonyms for base class

subclass and child class

synonyms for derived class

multiple inheritance

the capability to inherit from more than one class

exception

the generic term used for an error in object oriented languages. Errors are not usual occurences; they are exceptions to the rule

throw an exception

to pass it out of a block where it occurs, usually to a block that can handle it

catch an exception

to receive it from a throw so it can be handled

'protected' access specifier

used when you want no outside classes to be able to use a data field, except classes that are children of the original class

Exception Handling in Python

while True: try: n = raw_input ('Please enter an integer:') n = int(n) break except ValueError: print 'No valid integer! Please try again...' print 'Great you successfully entered an integer'

overload methods

write multiple versions of a method with the same name but different argument lists; any method or constructor in a class can be overloaded; python does no distinguish between constructor

'try' block

- a block of code you attempt to execute while acknowledging that an exception might occur. -use the 'try' followed by any number of statements. -if a statement in the block causes an exception, the remaining statements in the try block do not execute and the try block is abandonded.

sunny day case

-a case in which nothing goes wrong -when there are no exceptions and nothing goes wrong with a program

catch block

-a segment of code written to handle an exception that might be thrown by the try block that preceds it - Example: catch(exception) - Statements that take the action you want to use to handle the error conditions - endcatch statement indicates the end of the catch block in the pseudocode

exception handling

-a set of techniques for handling errors in object oriented programs -handling should be left to the application that uses the object

destructor:

-an automatically called method that contains the actions you require when an instance of a class is destroyed -instance destroyed: when the object goes out of scope -if you do not explicity create a destructor for a class, one is provided automatically -desclare a destructor: identifier consists of a tilde (~) followed by the class name - Cannot provide any parameters to a destructor - empty parameter list - cannot be overloaded -no return type -never explicitly call a destrocutor (invoked automatically) -the last object created is the first object destroyed

composition

-the technique of placing an object within an object of another class -when a class contains objects of another class as data fields, the relationship is called a whole part relationship or composition. -placing a class object within another class object - called has-a relationship because one class "has an" instance of another

inheritance

1. A principle that enables you to apply your knowledge of a general category to more specific objects. 2. understanding classes helps you organize objects in real life 3. Create a class by making it inherit from another class. - provided with data fields & methods automatically -reuse fields and methods that are already written and tested.

in object oriented programming, you 'try'

a metho that might throw an exception

has-a relationship

describes a whole-part relationship

inaccessible

describes any field or method that cannot be reached because of a logical error

fragile

describes classes that depend on field names from parent classes. They are prone to errors- they are easy to 'break'

reliable

describes code that has already been tested and used in a variety of situations


Related study sets

BISC208 Mastering Biology Exam 2 (University of Delaware, Dr. DeVito)

View Set

Lab 7.2-7.4 (Module 2): "The Bones Within Us"

View Set

The Science of Nutrition - Chapter 11

View Set

itf+ Test Prep errors FULL LENGTH TEST SET 13

View Set

Chapter 31: The Infant and Family

View Set