java and declaring the ba cs major object oriented
play

Java and Declaring the BA CS Major? Object-Oriented Programming - PDF document

Java and Declaring the BA CS Major? Object-Oriented Programming Want to declare the BACS major before advising and course selection start in a few weeks? There will be an Infosession this Thursday from 5-6pm in Rice 340 Just show


  1. Java and Declaring the BA CS Major? Object-Oriented Programming • Want to declare the BACS major before advising and course selection start in a few weeks? • There will be an Infosession this Thursday from 5-6pm in Rice 340 – Just show up! – Or email horton@cs.virginia.edu for details. One-Slide Summary Outline • Real databases, unlike PS5, have many concerns, such as scalability and atomic transactions. • PS5 vs. the Real World • A type is a (possibly infinite) set of values. • Each type supports a set of valid operations . • Problem Sets and PS9 • Types can be latent or manifest, static or dynamic, • Types strong or weak. • Java • An object packages state and procedures. • Object-Oriented • A procedure on an object is called a method . We Programming invoke a method by sending the object a message . – Object = State + • Inheritance allows one object to refine and reuse Methods the behavior of another. This is a good thing. • Inheritance • Java is statically-typed and object-oriented . #3 #4 Interlude: PS5 vs. Wild Real Databases • Atomic Transactions: a transaction may involve many How are commercial databases different modifications to database tables, but the changes should only happen if the whole transaction happens (e.g., don’t charge the from what you implemented for PS5? credit card unless the order is sent to the shipping dept) • Security: limit read/write access to tables, UVa’s Integrated Systems Project to entries and fields convert all University information systems to use an Oracle database was • Storage: need to efficiently store data on disk, originally budgeted for $58.2 Million provide backup mechanisms (starting in 1999). Actual cost ended up • Scale: to support really big data tables, over $100 Million. real databases do lots of clever things http://www.virginia.edu/isp/ #5 #6

  2. Rotunda Rotunda How big are big databases? • Microsoft TerraServer – Claimed biggest in 1998 – Aerial photos of entire US (1 meter Amphitheater Amphitheater resolution) – Let's see an example ... You are here You are here #7 #8 Big Databases How much work? • Microsoft TerraServer – 3.3 Terabytes (claimed biggest in 1998) • Suppose we have a huge database. – 1 Terabyte = 2 40 Bytes ~ 1 Trillion Bytes • table-select is in  ( n ) where n is the • Google Maps (possibly bigger?) number of entries in the table – Better color ... – Would your table-select work for Wal-Mart? • Wal-Mart – If 1M entry table takes 1s, how long would it – 285 Terabytes (2003) take Wal-Mart to select from 285TB ~ 2 Trillion Entries? • Stanford Linear Accelerator (BaBar) – 500 Terabytes (30 KB per particle collision) #9 #10 How much work? Objects • table-select is in  ( n ) where n is the An object packages: number of entries in the table – state (“variables”) – Would your table-select work for Wal-Mart? – procedures for manipulating – If 1M entry table takes 1s, how long would it take Wal-Mart to select from 285TB ~ 2 Trillion and observing that state Entries? 2 000 000s = ~ 23 days (“methods”) How do expensive databases perform table-select so much faster? Why is this useful? Hint: How did we make sorting faster? #11 #12

  3. Problem-Solving Strategies Problem-Solving Strategies • PS1-PS4: Functional Programming • PS6: Object-Oriented Programming – Focused on procedures – Focused on objects : package procedures and state – Break a problem into procedures that can be combined to solve it – Model a problem by dividing it into objects – All Python – Lots of problems in real (and imaginary) worlds can be thought of this way • PS5: Imperative Programming – All Java – Focused on data – Design data for representing a problem and procedures for updating that data – All Python + Small Java Intro #13 #14 Problem Sets after PS5 PS9 Assignment PS6: Programming with Objects Problem: Make an interesting dynamic web site. • Teams of 1-50 students PS7: Implementing Interpreters • Can be anything you want that: Java – Involves interesting computation PS8: Dynamic Web Application – Follows University’s use policies (or on SQL, external server) HTML, – Complies with ADA Section 508 (accessible) PS9: Project JavaScript or Build a new Python dynamic web application A list of example topics is provided. #15 #16 Liberal Arts Trivia: Biology PS6 PS6 PS6: Programming with Objects • This egg-laying, venomous (from a calcaneus PS7 PS7: Implementing Interpreters spur found on the hind limb), beaver-tailed, otter-footed mammal is perhaps best known Super for its “nose”, which follows the style of the Ambitious PS9 PS8: Dynamic Web Application Extra Ambitious Anatidae family of birds. It is native to Project PS9 Project eastern Australia and Tasmania, and occurs Exam 2 on the Australian 20 cent coin. PS9: Project Build a dynamic web application Default Negotiate with Wes in advance #17 #18

  4. Most Popular Liberal Arts Trivia: Art History Programming Languages 1. Java • Name the Spanish surrealist artist who 2. C painted The Persistence of Memory (oil on 3. PHP canvas, 1931). 4. C++ 5. Visual Basic 6. C# 7. Python 8. Perl 9. Delphi TIOBE Index, March 2010 10. JavaScript #19 #20 The Reveal Latent Python Danger • Java is almost identical to Python def mydouble (x): – Both have variables, if-else, function definitions, if get_date() != 'Saturday': recursion, mylist[3] = 44, ways to print things, return x * 2 etc. else: • Syntactic Differences: return x * “two” – Python is concise and uses : and [Tab] – Java is verbose and uses ; and { } print mydouble(3) • Semantic Differences: – Java uses Types to notice errors. # What will you get if you run it today? – Java uses Objects to organize state and functions. # Are there any bugs in this program? #21 #22 Types Types Strings Integers programs that halt Colors Beatle’s Songs that don’t end on the Tonic lists of lists of lists of Strings • A Type is a (possibly infinite) set of values • You can do some things with some types, but not others – Each Type has associated valid operations #23 #24

  5. Why have types? Types of Types • Detecting programming errors: (usually) Does regular Python have types? better to notice error than report incorrect result • Make programs easier to read, understand >>> 3[0] and maintain: thinking about types can help TypeError: 'int' object is not subscriptable understand code >>> “hello” + 2 • Verification: types make it easier to prove TypeError: cannot concatenate 'str' and 'int' objects properties about programs • Security: can use types to constrain the Yes, without types 3[0] would produce some silly result. behavior of programs Because of types, it produces a type error. #25 #26 Type Taxonomy Python Sees Types When Running >>> 3 + "hello" • Latent vs. Manifest Traceback (most recent call last): – Are types visible in the program text? • Static vs. dynamic checking File "<stdin>", line 1, in <module> – Do you have to run the program to know if TypeError: unsupported operand type(s) for it has type errors? +: 'int' and 'str' • Weak vs. Strong checking – How strict are the rules for using types? • (e.g., does the predicate for an if need to be a Boolean?) – Continuum (just matter of degree) #27 #28 Scheme/Python/Charme Strict Typing Java> 1 + (5 > 3) • Latent or Manifest? operator + cannot be applied to int,boolean – All have latent types (none visible in code) Python>>> 1 + (5 > 3) • Static or Dynamic? 2 – All are dynamic (checked when expression is evaluated) Scheme> (+ 1 (> 5 3)) • Weak or Strong? 2 – Which is the strictest? C> 1 + (5 > 3) – You tell me! 2 #29 #30

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend