Beyond CSE143. What s Left To Do? Templates. Using Templates. A Template Class. A Problem with Reusing Code CSE 143

Similar documents
1. What is Jav a? simple

Core Java Syllabus. Pre-requisite / Target Audience: C language skills (Good to Have)

School of Computing and Information Sciences. Course Title: Data Structures Date: 3/30/2010 Course Number: COP 3530 Number of Credits: 3

GUI and its COmponent Textfield, Button & Label. By Iqtidar Ali

GUI Program Organization. Sequential vs. Event-driven Programming. Sequential Programming. Outline

Java Swing Introduction

Object-oriented programming in Java (2)

Question No: 1 ( Marks: 1 ) - Please choose one One difference LISP and PROLOG is. AI Puzzle Game All f the given

Graphic User Interfaces. - GUI concepts - Swing - AWT

Windows and Events. created originally by Brian Bailey

CS 445: Data Structures Final Examination: Study Guide

Example Programs. COSC 3461 User Interfaces. GUI Program Organization. Outline. DemoHelloWorld.java DemoHelloWorld2.java DemoSwing.

G51PGP Programming Paradigms. Lecture 008 Inner classes, anonymous classes, Swing worker thread

Chair of Software Engineering. Languages in Depth Series: Java Programming. Prof. Dr. Bertrand Meyer. Exercise Session 3

CSCE 210/2201 Data Structures and Algorithms. Prof. Amr Goneid

CSCE 210/2201 Data Structures and Algorithms. Prof. Amr Goneid. Fall 2018

Review sheet for Final Exam (List of objectives for this course)

CS Exam 1 Review Suggestions

CSE wi Final Exam 3/12/18. Name UW ID#

(Incomplete) History of GUIs

CS 11 java track: lecture 3

Introduction. Overview of the Course on Java. Overview of Part 1 of the Course

be used for more than one use case (for instance, for use cases Create User and Delete User, one can have one UserController, instead of two separate

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class

7. Program Frameworks

Topic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more

Topic 9: Swing. Why are we studying Swing? GUIs Up to now: line-by-line programs: computer displays text user types text. Outline. 1. Useful & fun!

CSE wi Final Exam 3/12/18 Sample Solution

«Computer Science» Requirements for applicants by Innopolis University

Introduction to the JAVA UI classes Advanced HCI IAT351

CompuScholar, Inc. Alignment to Nevada "Computer Science" Course Standards

Run Time Environment

About this exam review

STRUCTURE AND SYLLABUS APPROVED IN THE BOARD OF STUDIES MEETING ON 2001 TO BE EFFECTIVE FROM THE ACADEMIC YEAR

CS506 Web Programming and Development Solved Subjective Questions With Reference For Final Term Lecture No 1

Topics in Object-Oriented Design Patterns

Control Flow: Overview CSE3461. An Example of Sequential Control. Control Flow: Revisited. Control Flow Paradigms: Reacting to the User

Short Notes of CS201

Fibonacci in Lisp. Computer Programming: Skills & Concepts (CP1) Programming Languages. Varieties of Programing Language

VALLIAMMAI ENGINEERING COLLEGE

CS201 - Introduction to Programming Glossary By

CSE 143. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT

Frames, GUI and events. Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling

Window Interfaces Using Swing Objects

DIABLO VALLEY COLLEGE CATALOG

MSc(IT) Program. MSc(IT) Program Educational Objectives (PEO):

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

PROGRAMMING IN C++ (Regulation 2008) Answer ALL questions PART A (10 2 = 20 Marks) PART B (5 16 = 80 Marks) function? (8)

WITH C+ + William Ford University of the Pacific. William Topp University of the Pacific. Prentice Hall, Englewood Cliffs, New Jersey 07632

Cpt S 122 Data Structures. Course Review FINAL. Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University

MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012

CSEN401 Computer Programming Lab. Topics: Graphical User Interface Window Interfaces using Swing

First Programming Language in CS Education The Arguments for Scala

Curriculum Map Grade(s): Subject: AP Computer Science

Graphical User Interfaces (GUIs)

Original GUIs. IntroGUI 1

Kickstart Intro to Java Part I

Computer Programming II C++ (830)

6.S096 Lecture 10 Course Recap, Interviews, Advanced Topics

Introduction to Computation and Problem Solving

EL2310 Scientific Programming

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17

State Application Using MVC

Big Java Late Objects

CSE 100 Advanced Data Structures

CS 240 Final Exam Review

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

COEN244: Class & function templates


CSE P 501 Compilers. Static Semantics Hal Perkins Winter /22/ Hal Perkins & UW CSE I-1

Java Bytecode (binary file)

Objectives of CS 230. Java portability. Why ADTs? 8/18/14

CS2013 Course Syllabus Spring 2018 Lecture: Mon/Wed 2:00 P.M. 2:50 P.M. SH C259 Lab: Mon/Wed 2:50 P.M. 4:00 P.M. SH C259

The Java programming environment. The Java programming environment. Java: A tiny intro. Java features

Page 1. Human-computer interaction. Lecture 1b: Design & Implementation. Building user interfaces. Mental & implementation models

Computer Programming II Python

Introduction to Programming

THINK LIKE CREATIVE PROBLEM SOLVING V. ANTON SPRAUL

Design Issues. Subroutines and Control Abstraction. Subroutines and Control Abstraction. CSC 4101: Programming Languages 1. Textbook, Chapter 8

CS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find

Introduction to Programming System Design CSCI 455x (4 Units)

CS 231 Data Structures and Algorithms, Fall 2016

Visual Basic Primer A. A. Cousins

Borland JBuilder 7 Product Certification. Study Guide

Classes, subclasses, subtyping

Object-Oriented Programming

Spring 2003 Instructor: Dr. Shahadat Hossain. Administrative Matters Course Information Introduction to Programming Techniques

Data Structures and Algorithms Design Goals Implementation Goals Design Principles Design Techniques. Version 03.s 2-1

COLLEGE OF THE DESERT

SEMANTIC ANALYSIS TYPES AND DECLARATIONS

Data Structures and Algorithm Analysis in C++

Binary Search Trees Treesort

Array Basics: Outline. Creating and Accessing Arrays. Creating and Accessing Arrays. Arrays (Savitch, Chapter 7)

Casting -Allows a narrowing assignment by asking the Java compiler to "trust us"

Internet Application Developer

PYTHON TRAINING COURSE CONTENT

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc.

Outline. Object Oriented Programming. Course goals. Staff. Course resources. Assignments. Course organization Introduction Java overview Autumn 2003

Absolute C++ Walter Savitch


Transcription:

What s Left To Do? Beyond CSE143 Templates Modern Software Development Windows and Java 143 Wrapup Beyond the C++ covered in this course Many topics, many more details of topics we did cover Main omission: templates: a C++ power feature Trends in programming Applications development MFC (C++) Java A look back at the topics in 143-1 -2 A Problem with Reusing Code Inheritance gives us a way to extend and reuse code Sometimes inheritance isn t the solution Example: Bank simulation. I have implemented a queue of customers; I also need a queue of stock transactions. No "is-a" or "has-a" relationships between the items Must reimplement the queue from scratch Would really like to have one Queue class, which could somehow be reused with different item types -3 Templates A template is a general pattern for a class or a function in C++ Everything is filled in, except one or more types Examples: a queue template class, with all the definitions complete, methods implemented, etc, but the type of the data item left open as a parameter a sort template function: type of the item being sorted is left open An extremely powerful feature of C++ Found in only a few advanced programming languages. -4 A Template Class class Queue { public: void insert(t item); T remove(); ; // in queue.cpp void Queue<T>::insert(T item) {... T Queue<T>::remove() Using Templates Queue<int> intqueue; Queue<double> dblqueue; intqueue.insert(5); intqueue.insert(7); dblqueue.insert(3.9); dblqueue.insert(-5.3); double dv = dblqueue.remove(); int iv = intqueue.remove(); Queue<Book *> books; books.insert(new Book( Moby Dick )); books.insert(new Book( Java for Dummies )); Book *eveningreading = books.remove(); {... -5-6

The STL: Standard Template Library The new Standard Library of C++ contains templates for many useful container types and generic algorithms Includes class templates like: list, set, map, stack, queue, vector, etc. generic algorithms for searching, sorting, merging, etc. To use these, you need to understand 1. C++ templates and container classes there are some thorny details, such as "iterators." 2. The data structures and algorithms themselves (abstractly) 3. Exact usage details (method names, parameters, etc.) -7 Trends in Programming Old School Input/process/output Reuse via libraries of functions Programmer calls functions COBOL, C/C++, Ada, Pascal, etc. Data stored in files and databases New Wave (YHQWGULYHQ 5HXVHÃYLDÃOLEUDULHVÃRIÃ FODVVHVÃFRPSRQHQWVÃ DQGÃGHVLJQÃSDWWHUQV 3URJUDPPHUÃLQKHULWVÃ IURPÃFODVVHVÃOLQNVÃ FRPSRQHQWVÃWRJHWKHU &Ã-DYDÃ9LVXDOÃ%DVLFÃ VFULSWLQJÃODQJXDJHVÃHWF $OOÃWKDWÃSOXVÃ22Ã GDWDEDVHVÃQHWRUNVÃ :HE -8 Beyond Objects: Components Component: a "sealed" object Some methods and data are "exposed" to the outside world Language-neutral source code not visible may be used within any compliant programming language or environment, possibly even at a distance. Supporting and related technologies Microsoft: VB, COM, OLE, Active-X, ASP, etc. Sun: JavaBeans CORBA Windows Application Development in C++ and Java Most C++ Windows development uses Microsoft Foundation Classes (MFC) MFC and Java Key features Graphical User Interface (GUI) Windows, menus, buttons, drawing areas Event-driven Respond to internal and external events Multi-threaded Object-oriented Built-in class hierarchies for standard reusable objects Programmer s job: Understand the hierarchy; use and extend given classes; hook into events; add custom logic Scripting languages (VBScript, JavaScript, etc.) -9-10 MFC Class Hierarchy Key MFC Classes -11 Everything descends from CObject CObject/CCmdTarget/CWinThread/CWinApp One per application, container for the whole thing CObject/CCmdTarget/CWnd A window (rectangular area); about 50 subclasses FrameWnd: resizable main frame CControlBar, CDialog, CButton, CEdit, etc. for user interaction CObject/Exception CObject/CFile CObject/CDC: graphics context -12

Using MFC Java Hard to learn "Wizards" help somewhat Nevertheless, a big improvement over previous environment: Win16/Win32 API: Hundreds of individual C functions Very widely used Not perfectly integrated with Windows OS mismatch with event handling Not part of C++ Mismatch or conflicts with standard libraries Compiler can t check everything A new language created by Sun Microsystems A "cleaned-up C++" similar syntax no explicit pointers new but no delete : garbage collected safety checking (array bounds, etc.) no preprocessor Designed from the ground up to be object-oriented no stand-alone functions GUI (Swing and AWT: Abstract Windows Toolkit) platform-independent Internet-friendly Not available on all platforms -13-14 Java s Object Model Java Class Hierarchy Chart Similar to C++ in notation and overall concept All classes descend from "Object" Wrapper classes for the elementary types e.g. Integer for int, with useful methods. All methods automatically virtual Deliberately missing some C++ power features No multiple inheritance Except from "interfaces," which are similar to abstract base classes with no data. No operator overloading No templates -15-16 Sample Java Code More Sample Code import javax.swing.*; // like #include in C++ import java.awt.*; import java.awt.event.*; // in Java, everything goes in a class! public class MyApplication { // this is how you declare main() public static void main(string[] args) { // create a window frame JFrame frame = new JFrame("MyApplication"); // create a label to go in it JLabel label = new JLabel("Hello, World!"); frame.getcontentpane().add(label); -17 // create an object to handle events frame.addwindowlistener(new WindowAdapter() { // called when the window is closed public void windowclosing(windowevent e){ System.exit(0); // exit the program! ); frame.pack(); // organize the frame frame.setvisible(true); // show the frame -18

Wrapping Up 143 What did we learn? Knowledge And Skills C++ Programming Specifics Classes Dynamic memory Stream I/O, Overloading, other C++ specifics General programming Recursion Object-oriented programming style [ Professor Dickey, why is this slide blank? ] -19-20 Knowledge and Skills (cont.) Knowledge and Skills (cont.) Software Engineering interpreting specs building sizable systems documenting (charts, descriptions, comments) robustness testing techniques for code reuse working in teams Data structures and algorithms Analysis of complexity Big-O notation Classic ADTs: List, Queue, Stack Sorting and Searching, incl. Binary Search, quadratic sorts, QuickSort, MergeSort Tree concepts Binary Trees and traversals Binary Search Trees and TreeSort Tables and hashing -21-22 What s Beyond 143? CS or CE Major CS: more software emphasis CE: more hardware emphasis Other major + CSE courses Long-term, a real winner Combine interest/aptitude in any field with CS knowledge "Real-world" programming Often involves maintenance of existing programs Requires knowledge of customer application Work as part of a team Courses After 143, it s assumed you can program! Non-majors courses 373 (Data Structures) Most direct successor to 143 410 (Computer Systems) 413 (Programming Languages) 415 (Artificial Intelligence) Majors courses 321 (Discrete Structures) 322 (Formal Models) 326 (Data Structures) 370 (Digital Logic) May use some specialized programming tools -23-24

$UHÃHÃQRWÃGUDQÃRQDUGÃ HÃIH"Ã'UDQÃRQDUGÃWRÃ QHÃHUD" IURPÃ:D\ORQ %UXQHWWHÃ -25