T YPES OF M ODELS Prasun Dewan Department of Computer Science University of North Carolina at Chapel Hill Code available at: https://github.com/pdewan/ColabTeachinghttps://github.com/pdewan/ColabTeaching.

Slides:



Advertisements
Similar presentations
ArrayLists The lazy mans array. Whats the matter here? int[] list = new int[10]; list[0] = 5; list[2] = hey; list[3] = 15; list[4] = 23;
Advertisements

P ROPERTIES OF C OLLABORATIVE U SER I NTERFACES Prasun Dewan Department of Computer Science University of North Carolina at Chapel Hill
C OMP 110/401 C OLLECTION K INDS Instructor: Prasun Dewan.
ObjectEditor Prasun Dewan Comp 114. ObjectEditor Automatic user-interface generation. You only write computation code Separate object to do I/O Main just.
Lecture 9 Concepts of Programming Languages
Chapter 1 An Overview of Database Management. 1-2 Topics in this Chapter What is a Database System? What is a Database? Why Database? Data Independence.
State Instance Variables Procedures Properties Print Statements Println Vs Print Overloading J++
CS 106 Introduction to Computer Science I 04 / 30 / 2010 Instructor: Michael Eckmann.
C OMP 401 P ATTERNS, I NTERFACES AND O BJECT E DITOR Instructor: Prasun Dewan.
C OMP 110/401 C OMPOSITE A NNOTATIONS Instructor: Prasun Dewan.
Chapter 10 Strings, Searches, Sorts, and Modifications Midterm Review By Ben Razon AP Computer Science Period 3.
23-Oct-15 Abstract Data Types. 2 Data types A data type is characterized by: a set of values a data representation, which is common to all these values,
Data Design and Implementation. Definitions of Java TYPES Atomic or primitive type A data type whose elements are single, non-decomposable data items.
Encapsulation COMP 401, Fall 2014 Lecture 06 9/4/2014.
C OMP 401 A DVANCED G ENERICS Instructor: Prasun Dewan.
Aug 9, CMSC 202 ArrayList. Aug 9, What’s an Array List ArrayList is  a class in the standard Java libraries that can hold any type of object.
A NATOMY OF AN I NTERACTIVE A PPLICATION Prasun Dewan Department of Computer Science University of North Carolina at Chapel Hill Code.
Practical Session 4 Java Collections. Outline Working with a Collection The Collection interface The Collection hierarchy Case Study: Undoable Stack The.
Java Beans. Definitions A reusable software component that can be manipulated visually in a ‘builder tool’. (from JavaBean Specification) The JavaBeans.
CourseOutline Example & JavaBeans Lec Start with Example Displaying Course Outlines User will select either course “web design & development” or.
CSCI 6962: Server-side Design and Programming JSF DataTables and Shopping Carts.
Lab 4 - Variables. Information Hiding General Principle: – Restrict the access to variables and methods as much as possible Can label instance variables.
JAVA BEANS JSP - Standard Tag Library (JSTL) JAVA Enterprise Edition.
Computer Science 209 Software Development Inheritance and Composition.
C OMP 401 G RAPH VS. D AG VS. T REE O BJECT S TRUCTURES Instructor: Prasun Dewan.
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
CSE 1201 Object Oriented Programming ArrayList 1.
Lorenz: Visitor Beans: An Aspect-Oriented Pattern Aspect-oriented pattern: describes a solution to a tangling problem in a particular context.
1 CS162: Introduction to Computer Science II Abstract Data Types.
CMSC 202 ArrayList Aug 9, 2007.
Andrew(amwallis) Classes!
Sections Inheritance and Abstract Classes
Structure of a web application
Abstract Data Types and Encapsulation Concepts
UNIT – I Linked Lists.
John Hurley Cal State LA
Fundamentals of Java: AP Computer Science Essentials, 4th Edition
Java Beans Sagun Dhakhwa.
Stacks.
Hash Tables 3/25/15 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M.
Top Ten Words that Almost Rhyme with “Peas”
structures and their relationships." - Linus Torvalds
Hash table another data structure for implementing a map or a set
Lecture 9 Concepts of Programming Languages
Still Aggregation and Composition
CS148 Introduction to Programming II
Abstract Data Types and Encapsulation Concepts
CISC124 Assignment 4 on Inheritance due next Monday, the 12th at 7pm.
CMSC 202 ArrayList Aug 9, 2007.
Beans and object editor
ArrayList Collections.
תירגול 9 אובייקטים.
CSCI N207 Data Analysis Using Spreadsheet
Arrays .
Cs212: Data Structures Computer Science Department Lecture 2: Arrays.
CMSC 202 ArrayList Aug 9, 2007.
Topics discussed in this section:
Variables, Lists, and Objects
Review Session Biggest discrepancy questions
Array Lists CSE 1310 – Introduction to Computers and Programming
ArrayLists 22-Feb-19.
Collections Framework
slides created by Marty Stepp
Review of Previous Lesson
CS2013 Lecture 7 John Hurley Cal State LA.
Fall 2018, COMP 562 Poster Session
Topic 25 - more array algorithms
structures and their relationships." - Linus Torvalds
Lecture 9 Concepts of Programming Languages
Unit – V Data Controls.
Presentation transcript:

T YPES OF M ODELS Prasun Dewan Department of Computer Science University of North Carolina at Chapel Hill Code available at:

2 P RE -R EQUISITES Model-Interactor Separation

3 M ODEL T YPES Model Interactor Types of models?

4 G ENERAL P ATTERN Model Interactor Write methods Read methods

5 E XAMPLE ASimpleList Interactor add() size() get() Write methods Read methods

6 L IST M ODELS List Model Interactor add() Write methods Read methods size() get() delete() Models define methods to read and write indexed elements in variable length lists They differ in the set of write methods

7 L OGICAL VS. P HYSICAL S TRUCTURE public class ASimpleList implements SimpleList { List simpleList = new ArrayList(); List > observers = new ArrayList(); public void add(ElementType anElement) { simpleList.add(simpleList.size(), anElement); } public void observableAdd(int anIndex, ElementType anElement) { add(anIndex, anElement); notifyAdd(anIndex, anElement); } public void notifyAdd(List > observers, int index, ElementType newValue) { for (ListObserver observer:observers) observer.elementAdded(index, newValue); } … } Replacing array list with array does not change logical structure of model, which is determined by public methods ArrayList  Array?

8 O THER M ODELS ? List Model Interactor add() Write methods Read methods size() get() delete() Models define methods to read and write indexed elements in variable length lists They differ in the set of write methods Other important kinds of models?

9 B EAN M ODELS Bean Model Interactor setP1() Write methods Read methods getP1() getP2() setP2() Models define getter and setter methods to read fixed number of typed properties

10 R EAD - ONLY AND E DITABLE P ROPERTIES public class C { } public T getP() {... } public void setP(T newValue) {... } Typed, Named Unit of Exported Object State Name P Type T Name P Type T Read-only Editable Getter method Setter method newP obtainP Violates Bean convention Bean Bean convention: For humans and tools

11 I NDEXED B EAN Bean also defines fixed length indexed collections which we will ignore

12 M ODEL C OMPOSITION Bean Model List Model Bean Model

13 C OMPOSING H ISTORY M ODEL We already have a model for History

14 E XAMPLE M ODEL C OMPOSITION IM Bean Model Simple List History Topic

15 C ONNECTING M ODEL /I NTERACTOR H IERARCHIES Model Bean Model Interactor A model subtree can be connected to a single interactor A model can be connected to an interactor subtree

16 S UMMARY OF M ODELS Lists Variable length indexed lists Differ based on subsets of list operations exposed Beans Property collections Differ in properties Table model is another important kind not needed in this course Model composition Useful when user interfaces are composed Model hierarchies can be connected to interactor hierarchies in arbitrary ways