Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
1 Advanced Object Oriented Systems (CM0318) Introductory Lecture (Last modified: 28th January 2002) 2 Suggested linked list implementation • 2 classes: MyLinkedList and MyLink (NB actually Java provides a class LinkedList) 3 MyLinkedList • instance variables: – MyLink first – MyLink last – int size • methods: – – – – – MyLinkedList() void add(Object element) Enumeration elements() int size() ... 4 MyLink • Instance variables – MyLink next; – Object element; 5 Suggested Deptl. Info. System implementation • Classes include: – – – – Lecturer Student Module (Department) 6 Lecturer • instance variables: – String name (or could be split up into parts) – Vector modules_given • methods: – void add_module(Module m) – Enumeration all_modules() (or Vector?) – (optionally things to set the name, etc., which could then be made private) 7 Student • instance variables – String name (or could be split up into parts) – int student_number (or should it be a String?) – Vector modules_taken • methods – things to add a module, etc., similar to Lecturer 8 Module • instance variables – String module_code – String module_title • methods – accessors (set code, etc.) 9 Department • instance variables – Vector lecturers – Vector students – Vector available_modules • methods – Vector lecturer_names() (or Enumeration?) – Vector all_students() 10 Note Well • Always more than one way to model a problem! • Because of Java’s type system, collections like Vectors are horrible to use - but better than nothing! E.g. to iterate through the lecturers’ names you’ll need code like this: Enumeration e = lecturers.elements(); while (e.hasMoreElements()) { do_something_with( ((Lecturer) e.nextElement()).name);} 11 Topics • Why OO? – – – – intuitive modelling software quality reuse • Features of OO that give these qualities 12 Java • Using the libraries • Modelling non-trivial problems 13 Design • ACJ: – Design by contract • AIA: – Methodologies – Communicating design • CRC Cards • UML – Design patterns 14 Other OO languages • Dynamically typed languages – Smalltalk – Self (classless!!) • Statically typed languages – C++ – Eiffel (NB supports design by contract) 15 Building systems interactively • ACJ: – The Smalltalk programming environment approach • AIA: – The CASE approach 16 Distributed objects - CORBA • Language & platform independence • Wrapping legacy applications 17 Implementation of OO languages • Memory management • Virtual machines • Bottlenecks & clever ideas!!