Object-Oriented Design Essentials

comp 2000 object oriented design n.w
1 / 10
Embed
Share

Explore the fundamentals of object-oriented design through the concepts of ArrayList and LinkedList. Understand the implementation details, main ideas, and representations of linked nodes in dynamic data structures. Enhance your understanding of Java Collections Framework for effective software development.

  • OOP
  • Data Structures
  • Java Collections
  • Design
  • LinkedList

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. COMP 2000 Object-Oriented Design DAVID J STUCKI OTTERBEIN UNIVERSITY

  2. ALERTS Read Chapter 9 from The Object The Object- -Oriented Thought Process Oriented Thought Process Questions?

  3. Implementations of List<E> Last time we looked at the code for AbstractList<E>. Let's peek for a minute at the code for List<E>... The actual source code for the JCF can be a little confusing to read for several reasons: 1. It is cluttered with all the JavaDocs comments 2. The methods are not grouped in meaningful ways 3. It uses a lot of private methods that delegate common tasks 4. It is trying to be as general as possible, so includes advanced features and methods that can distract from the main abstraction.

  4. ArrayList<E> So what are the main ideas? An ArrayList HAS An ArrayList HAS- -An array instantiated array The capacity capacity of the ArrayList is the length of the array, while the size ArrayList is the number of elements it contains (which is always less than or equal to the capacity). An array: a private instance variable that is a reference to an size of the Adding an element when size a larger one (with all the elements copied over) size == capacity capacity causes the array to be replaced with Similarly, removing an element (below some threshold) may cause the array to be resized to a smaller one.

  5. LinkedList<E> An alternative to using arrays is the idea of a dynamic data structure A linked list linked list is one of the simplest examples of a dynamic data structure A good visual image for a linked list is a cargo train. Each car in the train carries some cargo (data) but also has a coupler (link) that allows it to be connected to the next car in the train. The final element of the list will have a null value for its coupler to mark the end of the list. Often lists are doubly linked, so that each node points at both the next and the previous node in the list. dynamic data structure

  6. The Representation of Linked Nodes private static class Node<E> { E item; Node<E> next; Node<E> prev; Node(Node<E> prev, E element, Node<E> next) { this.item = element; this.next = next; this.prev = prev; } }

  7. LinkedList<E> public class LinkedList<E> extends AbstractSequentialList<E> { int size; Node<E> first; Node<E> last; LinkedList() { size = 0; first = null; last = null; } }

  8. LinkedList<E> The list (23, 47, 58) would look like this: last size first 3 next next next prev item prev item prev item null null 47 58 23

  9. Linked List Source Code Let's look at the (edited edited) Java source file for LinkedList<E>

  10. Next Time... Return to User Interface Design Return to User Interface Design

Related


More Related Content