UT Arlington CSE 3302 - Lecture 3 - Objects (32 pages)

Previewing pages 1, 2, 15, 16, 31, 32 of 32 page document View the full content.
View Full Document

Lecture 3 - Objects



Previewing pages 1, 2, 15, 16, 31, 32 of actual document.

View the full content.
View Full Document
View Full Document

Lecture 3 - Objects

91 views


Pages:
32
School:
University of Texas at Arlington
Course:
Cse 3302 - Programming Languages
Programming Languages Documents

Unformatted text preview:

CSE 3302 Lecture 3 Objects 2 September 2010 Nate Nystrom University of Texas at Arlington Administration Out of town this afternoon thru Monday HW1 due next Thursday 9 9 Types Last time strongly typed if no type errors occur at run time statically typed languages rule out type errors at compile time requires programmers to write type declarations dynamically typed languages rule out type errors at run time dynamic checks before operations Records A record is a value consisting of a sequence of named fields Declaring a record C struct int a float b Pascal record a integer b real end Support access operations via field names x a x b Records as ADTs struct IntList int head struct IntList tail must be a pointer Records as ADTs struct IntList int head struct IntList tail must be a pointer int get IntList xs int i if i 0 return xs head else get xs tail i 1 void append IntList xs IntList ys if xs tail NULL xs tail ys else append xs tail ys Problems Implementation exposed Only one implementation supported Clients of the ADT must all use same implementation Objects Focus is on data rather than on processes Programs composed of self contained interacting objects vs as a list of tasks to perform Bundle data with the operations on that data Encapsulate hide implementation from clients Can only access data through public interface Objects Source code for class defines concrete type implementation Interface defined by public variables and methods of a class class IntList private int head private IntList tail public int get int i if i 0 return this head else return get this tail i 1 public void append IntList ys if this tail null this tail ys else this tail append ys OO languages Not an exhaustive survey C Simula 67 Java C Scala Objective C Smalltalk Self JavaScript Ruby CLOS LISP ML OCaml C OO languages Two kinds of OO languages class based Simula Smalltalk C Java C Scala prototype based Self Cecil JavaScript Class based languages A class defines a template for creating objects



View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

Loading Unlocking...
Login

Join to view Lecture 3 - Objects and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 3 - Objects and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?