Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall 645-4739 1.

Similar presentations


Presentation on theme: "CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall 645-4739 1."— Presentation transcript:

1 CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall 645-4739 alphonce@buffalo.edu 1

2 Announcements Cell phones off Name signs out 2

3 Last class High-level languages Requirements for a programming language 3

4 Today’s lessons Objects 4

5 I have a question for you! What did you have for breakfast today?

6 Activity The goal of this short activity is to demonstrate two things: 1.objects have behaviors 2.sending message to objects can trigger those behaviors

7 Volunteers? I need 3 volunteers. 7

8 Activity details 3 volunteers, a.k.a. objects When I tell you… (I) …you should… (II) …you should… (III) …you should… STARTbegin doing jumping jacksstart counting slowly, 0…1…2… etc, but always starting at zero do nothing STOPstop jumping, and stand normally stop counting, but remember where you left off do nothing CONTINUEdo nothingkeep counting up from where you left off do nothing anything elsedo nothing

9 Activity Review Why did we do this activity? –To introduce the idea of an object. What is an object? –It is a representation of something in our problem domain –It has both: CAPABILITIES PROPERTIES / STATE

10 Questions? 10

11 Example Describe the game of soccer. http://en.wikipedia.org/wiki/Soccer

12 Executable Model Conceptual Model Apply same idea to developing software solutions:

13 The conceptual model A model of the problem domain Problem domain consists of: –objects properties capabilities –relationships between objects

14 PROGRAM CODE Executable Model MACHINE EXECUTABLE Initial Conceptual Model Problem Domain Iterative refinement of model Compilation A more refined picture (iterative refinement in action!)

15 Tools Editor Compiler Execution environment Integrated Development Environment (IDE) DrJava, Eclipse, NetBeans, Emacs, etc. 15

16 Review Software development is an iterative and incremental process. OO software systems are systems of interacting objects. Objects have –properties: things objects know (think of the counting object last class) –behaviors: things objects do (think of the “jumping jack” object)

17 How do we create objects? –new example1.Terrarium() –There are three parts to this expression: new example1.Terrarium ()

18 Let’s try it! We use a tool called Eclipse… …and a plug-in for Eclipse called DrJava DrJava provides an interactions pane

19 Eclipse tour terminology –view: a subwindow in Eclipse –perspective: a collection of views Eclipse: a framework for building tools –Eclipse is extended via plug-ins –a plug-in: Java Development Tools (JDT) –others: DrJava, Green, CDT, …

20 Expression evaluation evaluating new example1.Terrarium() –causes an object to be created and initialized –produces a value

21 (part of) memory 107 108 109 110 111 112 113 114 115

22 evaluating a ‘new’ expression used available used 107 108 109 110 111 112 113 114 115 When evaluating an expression like ‘new example1.Terrarium()’, the operator ‘new’ first determines the size of the object to be created (let us say it is four byte for the sake of this example)

23 evaluating a ‘new’ expression used reserved by ‘new’ available used 107 108 109 110 111 112 113 114 115 When evaluating an expression like ‘new example1.Terrarium()’, the operator ‘new’ first determines the size of the object to be created (let us say it is four bytes for the sake of this example) Next, new must secure a contiguous block of memory four bytes large, to store the representation of the object.

24 evaluating a ‘new’ expression used 10101010 available used 107 108 109 110 111 112 113 114 115 When evaluating an expression like ‘new example1.Terrarium()’, the operator ‘new’ first determines the size of the object to be created (let us say it is four byte for the sake of this example) Next, new must secure a contiguous block of memory four bytes large, to store the representation of the object. Bit strings representing the object are written into the reserved memory locations.

25 evaluating a ‘new’ expression used 10101010 available used 107 108 109 110 111 112 113 114 115 When evaluating an expression like ‘new example1.Terrarium()’, the operator ‘new’ first determines the size of the object to be created (let us say it is four byte for the sake of this example) Next, new must secure a contiguous block of memory four bytes large, to store the representation of the object. Bit strings representing the object are written into the reserved memory locations. The starting address of the block of memory holding the object’s representation is the value of the ‘new’ expression. This address is called a ‘reference’.


Download ppt "CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall 645-4739 1."

Similar presentations


Ads by Google