1 / 24

CSE115: Introduction to Computer Science I

CSE115: Introduction to Computer Science I. Dr. Carl Alphonce 219 Bell Hall 645-4739 alphonce@buffalo.edu. Announcements. Cell phones OFF and put away Name signs out Lab 1 starts this week Exam 1 next week (!) Monday: review Wednesday: exam. Problem solving.

manton
Download Presentation

CSE115: Introduction to Computer Science I

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Announcements • Cell phones OFF and put away • Name signs out • Lab 1 starts this week • Exam 1 next week (!) • Monday: review • Wednesday: exam

  3. Problem solving • How do we go about solving a problem? • Simplification through abstraction is key. • A process of iterative refinement • Start with little detail in solution • Refine solution, adding more detail

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

  5. Apply same idea to developingsoftware solutions: Executable Model Conceptual Model

  6. The conceptual model • A model of the problem domain • Problem domain consists of: • objects • properties • capabilities • relationships between objects

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

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

  9. 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)

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

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

  12. 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, …

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

  14. (part of) memory

  15. evaluating a ‘new’ expression 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)

  16. evaluating a ‘new’ expression 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.

  17. evaluating a ‘new’ expression 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.

  18. evaluating a ‘new’ expression 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’.

  19. evaluating a ‘new’ expression A similar thing happens when we evaluate another ‘new’ expression like ‘new example1.Caterpillar()’.

  20. evaluating a ‘new’ expression A similar thing happens when we evaluate another ‘new’ expression like ‘new example1.Caterpillar()’. Supposing that an example1.Caterpillar object occupies two bytes of memory, new reserves a contiguous block of two bytes…

  21. evaluating a ‘new’ expression A similar thing happens when we evaluate another ‘new’ expression like ‘new example1.Caterpillar()’. Supposing that an example1.Caterpillar object occupies two bytes of memory, new reserves a contiguous block of two bytes, writes bit strings representing the object to those memory locations, and the starting address of this block of memory is the value of the ‘new’ expression.

  22. DrJava’s response When we evaluate these ‘new’ expressions in DrJava, what is the response we get? > new example1.Terrarium() example1.Terrarium[frame0,0,0,608x434,layout=java.awt.BorderLayout,title=,resizable,normal,defaultCloseOperation=EXIT_ON_CLOSE,rootPane=javax.swing.JRootPane[,4,30,600x400,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true] > new example1.Caterpillar() example1.Caterpillar@bd93cd

  23. DrJava’s response These responses don’t look like memory addresses. What’s going on? After DrJava evaluates the expression, it must print the value. The way Java works, when a reference is printed a textual representation of the object it refers to is produced (as defined by the object itself)

  24. Object communication To put an example1.Caterpillar object inside an example1.Terrarium object: > new example1.Terrarium().add(new example1.Caterpillar())

More Related