Programming Languages Design Specification and Implementation G22 2210 001 Rob Strom October 26 2006 Administrative Alternative mailing address for me robstrom us ibm com Everyone should subscribe to the class mailing list http www cs nyu edu mailman listinfo g22 2110 001 fa06 Reading Ada C generics Java http java sun com j2se 1 5 pdf generics tutorial pdf Simple Homework due next class Polymorphism Project due 2 weeks after simple homework BUT START NOW Come to office hours for help Academic integrity Violation of any of the following rules constitutes cheating Students are to do all assignments individually with no collaboration or sharing of work unless the instructor explicitly permits collaboration If one student shows or gives his her work to another then both students are considered to be cheating Students may not use work provided by any person outside the class Furthermore students may not solicit other people to do assignments in whole or in part for them When an instructor permits collaboration on an assignment then collaboration is permitted only to the degree and in the respects that he she specifies Each assignment that is done collaboratively must state that it was done collaboratively and must list the collaborators External sources such as published materials or material on the Web may be used in assignments only to the extent permitted by the instructor If such a source is used the assignment must include an attribution to the source Ideas algorithms text code and experimental results all require proper attribution A student may not submit the same assignment to two different classes whether in the same semester or in different semesters without the explicit permission of both instructors During an exam students must not communicate in any way nor use any materials or technology not explicitly permitted by the instructor other than pens and pencils One student may not look at another student s test A student may not attempt to gain possession of or look at an exam before the start of the exam Students providing unauthorized information and those using it are cheating and are ALL subject to disciplinary action Disciplinary actions can vary in severity and can result in probation or termination from the graduate program The GSAS Policies and Procedures Manual under Topic 3 Discipline includes a complete outline of sanctions and procedures Departmental policy is to give a grade of F in the course in which the cheating occurred By the rules of GSAS the penalty for a second offense is termination from the graduate program Small homework next week In C Java and Ada first define a simple type Person either as a record or as a class containing Name Address and PhoneNumber Then implement a container class that uses doubly linked lists to create a list of Person supporting operations Insert add a person to the list at position n Position of return position of the person on the list starting at 0 exception if not on the list Get nth return a copy of the nth item exception if no nth item Remove nth remove the nth item exception if no nth item In later homework we will use generics to allow a single package to work with any type not just Person This homework verifies that you are familiar with defining new abstract classes that hide their implementation Polymorphic Programming Project 2 weeks This project builds a system exploiting polymorphism Choose one of the 3 languages C Ada or Java to do it This system models a world composed of the following kinds of objects rooms they have doors to neighboring rooms and access to factories factories they create objects solids coins keys bags pots some of which are containers bags pots jars liquids water juice must be in a container can only be transferred with a funnel doors they transfer solid objects from one room to a neighbor funnels they transfer liquids from one container to another Objects have attributes weight mass and different kinds enforce different restrictions You manipulate things by repeatedly choosing a room and giving it a script that can do any of these things in that room Ask factories in the room for things by name e g you can ask for 10 keys different factories might return different weight keys or might return them in a bag inside a package etc You can ask containers what s inside them You can remove solid things from inside containers you have in the room with you You can insert solid things from the room into containers A container will complain if its capacity is exceeded or if you are trying to mix solids and liquids in the same container You can transfer x amount of liquid from one container to another by invoking a method on a funnel It will complain if there is too little liquid in the source container or if the receiving container doesn t accept that kind of liquid Usually containers will not accept liquid if they are also holding solids You can ship a container and by implication everything in it from a room to a neighbor by invoking a method on one of the room s doors Use polymorphic programming to Configure a network of at least 5 rooms with doors between them and different kinds of factories in each Design different kinds of solid objects containers and liquids with different properties at least 3 of each Example pot1 can hold solid up to 5 pounds or liquid up to 10 ounces but not both solid and liquid Write a variety of scripts to obtain things from factories extract their contents from containers repackage them and ship them to neighboring rooms and then go to the neighboring rooms and unpackage them again Programming Languages Core Exam Syntactic issues regular expressions context free grammars CFG BNF Imperative languages program organization control structures exceptions Types in imperative languages strong typing type equivalence unions and discriminated types in C and Ada Block structure visibility and scoping issues parameter passing Systems programming and weak typing exposing machine characteristics type coercion pointers arrays in C Run time organization of block structured languages static scoping activation records dynamic and static chains displays Programming in the large abstract data types modules packages and namespaces in Ada Java and C Functional programming list structures higher order functions lambda expressions garbage collection metainterpreters in Lisp and Scheme Type inference and ML Object Oriented programming classes inheritance polymorphism dynamic dispatching
View Full Document
Unlocking...