Compsci 290/Mobile, Java

Similar documents
Goals of Lecture. Lecture 27: OO Design Patterns. Pattern Resources. Design Patterns. Cover OO Design Patterns. Pattern Languages of Programming

What is a Pattern? Lecture 40: Design Patterns. Elements of Design Patterns. What are design patterns?

Design Patterns. An introduction

Idioms and Design Patterns. Martin Skogevall IDE, Mälardalen University

Software Design Patterns. Background 1. Background 2. Jonathan I. Maletic, Ph.D.

Design Patterns. it s about the Observer pattern, the Command pattern, MVC, and some GUI. some more

CSE 70 Final Exam Fall 2009

The Strategy Pattern Design Principle: Design Principle: Design Principle:

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

1 Software Architecture

Application Architectures, Design Patterns

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

Patterns. Giovanni Sakti. in Software Engineering. Starqle

SDC Design patterns GoF

Software Engineering - I An Introduction to Software Construction Techniques for Industrial Strength Software

Writing your own Java I/O Decorator p. 102 Tools for your Design Toolbox p. 105 Exercise Solutions p. 106 The Factory Pattern Baking with OO

Lecture 13: Design Patterns

Pattern Resources. Lecture 25: Design Patterns. What are Patterns? Design Patterns. Pattern Languages of Programming. The Portland Pattern Repository

Design Patterns. Gunnar Gotshalks A4-1

Design Patterns Reid Holmes

CSC207H: Software Design Lecture 6

Inheritance. EEC 521: Software Engineering. Dealing with Change. Polymorphism. Software Design. Changing requirements Code needs to be flexible

An Expert System for Design Patterns Recognition

CS/CE 2336 Computer Science II

GRASP Design Patterns A.A. 2018/2019

Design Patterns. Observations. Electrical Engineering Patterns. Mechanical Engineering Patterns

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar

Ingegneria del Software Corso di Laurea in Informatica per il Management. Design Patterns part 1

Trusted Components. Reuse, Contracts and Patterns. Prof. Dr. Bertrand Meyer Dr. Karine Arnout

INTERNAL ASSESSMENT TEST III Answer Schema

Responsibilities. Using several specific design principles to guide OO design decisions.

LECTURE NOTES ON DESIGN PATTERNS MCA III YEAR, V SEMESTER (JNTUA-R09)

17. GRASP: Designing Objects with Responsibilities

OODP Session 4. Web Page: Visiting Hours: Tuesday 17:00 to 19:00

Foundations of Software Engineering Design Patterns -- Introduction

Design Patterns גרא וייס המחלקה למדעי המחשב אוניברסיטת בן-גוריון

Crash course on design patterns

Welcome to Design Patterns! For syllabus, course specifics, assignments, etc., please see Canvas

An Introduction to Patterns

Software Engineering I (02161)

Design Pattern What is a Design Pattern? Design Pattern Elements. Almas Ansari Page 1

Software Architecture With ColdFusion: Design Patterns and Beyond Topics Outline Prepared by Simon Horwith for CFUnderground 6

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

DESIGN PATTERN - INTERVIEW QUESTIONS

Ingegneria del Software Corso di Laurea in Informatica per il Management. Design Patterns part 1

CSC7203 : Advanced Object Oriented Development. J Paul Gibson, D311. Design Patterns

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar

CPSC 310 Software Engineering. Lecture 11. Design Patterns

Slide 1. Design Patterns. Prof. Mirco Tribastone, Ph.D

Design Patterns. CSC207 Winter 2017

INTERNATIONAL JOURNAL OF COMPUTER ENGINEERING & TECHNOLOGY (IJCET) NEED FOR DESIGN PATTERNS AND FRAMEWORKS FOR QUALITY SOFTWARE DEVELOPMENT

Exam Questions. Object-Oriented Design, IV1350. Maximum exam score is 100, grade limits are as follows. Score Grade 90 A 80 B 70 C 60 D 50 E

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

INSTITUTE OF AERONAUTICAL ENGINEERING

Software Engineering I (02161)

Improve Your SystemVerilog OOP Skills

Design Pattern- Creational pattern 2015

Patterns of learning

Design Pattern and Software Architecture: IV. Design Pattern

GOF Patterns Applied

Software Engineering

Information Systems Analysis and Design. XIV. Design Patterns. Design Patterns 1

Topics. Software Process. Agile. Requirements. Basic Design. Modular Design. Design Patterns. Testing. Quality. Refactoring.

THE OBJECT-ORIENTED DESIGN PROCESS AND DESIGN AXIOMS (CH -9)


An Introduction to Patterns

Work groups meeting 3

Lectures 24 and 25 Introduction to Architectural Styles and Design Patterns

Think of drawing/diagramming editors. ECE450 Software Engineering II. The problem. The Composite pattern

Chapter 12 (revised by JAS)

Work groups meeting 3

More on Design. CSCI 5828: Foundations of Software Engineering Lecture 23 Kenneth M. Anderson

PROCESS DEVELOPMENT METHODOLOGY The development process of an API fits the most fundamental iterative code development

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

Applying Design Patterns to accelerate development of reusable, configurable and portable UVCs. Accellera Systems Initiative 1

Last Lecture. Lecture 17: Design Patterns (part 2) Kenneth M. Anderson Object-Oriented Analysis and Design CSCI 4448/ Spring Semester, 2005

Design Patterns. CSC207 Fall 2017

Patterns and Testing

The Design Patterns Matrix From Analysis to Implementation

3 ADT Implementation in Java

Object-Oriented Design

Software Engineering Fall 2015 (CSC 4350/6350) TR. 5:30 pm 7:15 pm. Rao Casturi 11/03/2015

Principles of Software Construction: Objects, Design, and Concurrency

01 INTRODUCTION TO COURSE

google define: design Vad är design? google define: design the act of working out the form of something Den Röda Tråden

CPS122 Lecture: Design Patterns Last revised March 20, 2012

Last Lecture. Lecture 26: Design Patterns (part 2) State. Goals of Lecture. Design Patterns

Object-Oriented Design

Software Design COSC 4353/6353 D R. R A J S I N G H

Design Patterns Revisited

Design patterns. Jef De Smedt Beta VZW

192. Design Patterns in Java Software

administrivia today UML start design patterns Tuesday, September 28, 2010

Object-Oriented Design

Implementing GUI context-sensitive help... ECE450 Software Engineering II. Implementing GUI context-sensitive help... Context-sensitive help

CS246 Software Abstraction and Specification Final Examination

Plan. Design principles: laughing in the face of change. What kind of change? What are we trying to achieve?

CSCU9T4: Managing Information

Java EE Patterns. Student Guide - Volume 1. SL-500 Rev C.0.1. D61856GC10 Edition 1.0 D62465

Object-Oriented Design

Transcription:

Compsci 290/Mobile, Java Owen Astrachan Landon Cox January 16, 2018 1/16/2018 Mobile 290, Spring 2018, Java 1

Java Classes and Objects Class encapsulates state and behavior State is typically private Android uses minstancevar convention Class is an object factory Calling new creates a new instance Everything in Java is a pointer/reference 1/16/2018 Mobile 290, Spring 2018, Java 2

Classes and Objects Classes communicate and collaborate Parameters: use-a, send and receive Containment: has-a, aggregate or responsible Inheritance: is-a, extends, specializes Inheritance and interfaces More on this throughout semester, especially at beginning 1/16/2018 Mobile 290, Spring 2018, Java 3

Tell Don't Ask Tell objects what you want them to do, do not ask questions about state, make a decision, then tell them what to do Think declaratively, not procedurally (Pragmatic Programmers, LLC) Don't ask for a map, then walk through the map Instead of iteration, apply to all Breaks when we don't want to apply to all Rules are made to be broken Reduce coupling, better code 1/16/2018 Mobile 290, Spring 2018, Java 4

Law of Demeter Don't talk to objects, don't call methods. The more you talk, the more you rely on something that will break later Call your own methods Call methods of parameter objects Call methods if you create the object Do NOT call methods on objects returned by calls List all = obj.getlist(); all.addspecial(key,getvalue()); obj.addtolist(key,getvalue()); // ok here 1/16/2018 Mobile 290, Spring 2018, Java 5

Open Closed Principle Classes and Programs will be changed Open to extension Closed to modification What does this mean? If not modified, don't need to be re-tested on a Unit testing basis Extension can be by design, by language features 1/16/2018 Mobile 290, Spring 2018, Java 6

Loose Coupling We want classes to be loosely coupled Independent of each other in that they interact via APIs Changes in one class have minimal impact on other classes except via APIs and those should be changed infrequently Applications and programs change Minimize the "ripple" effect through the system 1/16/2018 Mobile 290, Spring 2018, Java 7

High Cohesion Classes capture one abstraction Create more classes when you need them, don't be a class miser or misanthrope (word abuse) Keep things simple, strive for simplicity Don't use Swiss-army knife approach, one tool for one purpose Loose coupling and high cohesion, goals for programming 1/16/2018 Mobile 290, Spring 2018, Java 8

Design Patterns... describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice Christopher Alexander, quoted in GOF Name good name is a handle for the pattern, builds vocabulary Problem when applicable, context, criteria to be met, design goals Solution design, collaborations, responsibilities, and relationships Forces and Consequences trade-offs, problems, results from applying pattern: help in evaluating applicability 1/16/2018 Mobile 290, Spring 2018, Java 9

Odyssey of the Mind 1/16/2018 Mobile 290, Spring 2018, Java 10

MolecularBalls https://en.wikipedia.org/wiki/abstract_factory_pattern https://coursework.cs.duke.edu/ola/molecules Where do MolecularBalls come from? Is the source of the ballimportant? Should Main Program be aware of source? Is there more than one kind of Ball? Bouncing behavior? Color What's state and what's behavior? 1/16/2018 Mobile 290, Spring 2018, Java 11

Writing Programs Always do the hard part first. If the hard part is impossible, why waste time on the easy part? Once the hard part is done, you re home free. Always do the easy part first. What you think at first is the easy part often turns out to be the hard part. Once the easy part is done, you can concentrate all your efforts on the hard part. Whenever possible, re-use, share, borrow, but do not steal code 1/16/2018 Mobile 290, Spring 2018, Java 12

Design Patterns MVC, aka Observer/Observable Separate concerns, especially important for GUIs Composite Container is/contains Layout/View, File/Directory Factory Separate creation from class, install new creators 1/16/2018 Mobile 290, Spring 2018, Java 13

Proxy/Adapter Stand-in with same interface, adapt interface as needed Decorator Is-a and Has-a, e.g., Filters and java I/O Command Function/request object, undoable action 1/16/2018 Mobile 290, Spring 2018, Java 14