the gamedesigninitiative at cornell university Lecture 13 Architecture Design

Similar documents
the gamedesigninitiative at cornell university Lecture 12 Architecture Design

Construction: High quality code for programming in the large

About the required reading. Construction: High quality code for programming in the large. What is high quality code?

Activities Radovan Cervenka

OO Using UML: Dynamic Models

Northeastern University - Seattle. Computer and Information Sciences

Documentation (and midterm review)

Big Java Late Objects

Introduction to pthreads

CSE 100 Advanced Data Structures

Game Architecture Revisited

CTI Short Learning Programme in Internet Development Specialist

MyProgram m i ng Lab. get with the programming. Through the power of practice and immediate personalized

Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach.

CTI Higher Certificate in Information Systems (Internet Development)

AADL Graphical Editor Design

Lecture 24. GUI Applications

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

Refactoring with Eclipse

Object-oriented Programming Project

Express Yourself. Writing Your Own Classes

Unified Modeling Language

Foundations, Reasoning About Algorithms, and Design By Contract CMPSC 122

ощ 'ршорвшэш! цвн-эориэу ощ 'sajbpossv # PIPG DUJ 'ssjmoossv ^ PIPG pipa w н OX ЛЮН VAV

Android Basics Nanodegree Syllabus

CSE 70 Final Exam Fall 2009

SharePoint 2013 Power User

MODEL BASED TEST DESIGN AT UNITY

Spell Casting Motion Pack 5/5/2017

Object-Oriented Design

the gamedesigninitiative at cornell university Lecture 14 2D Sprite Graphics

U N I V E R S I T Y O F W E L L I N G T O N EXAMINATIONS 2015 TRIMESTER 2 SWEN222. Software Design

Second Semester Examinations 2012/13

This page intentionally left blank

Intro. Scheme Basics. scm> 5 5. scm>

PROGRAMMING IN VISUAL BASIC WITH MICROSOFT VISUAL STUDIO Course: 10550A; Duration: 5 Days; Instructor-led

Javadoc. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 7

In This Lecture You Will Learn: Specifying Control. Statechart. Event, State and Transition

CS12020 for CGVG. Practical 2. Jim Finnis

CS 465 Program 4: Modeller

CS11 Introduction to C++ Fall Lecture 7

CS50 Quiz Review. November 13, 2017

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

Programming in C. main. Level 2. Level 2 Level 2. Level 3 Level 3

02291: System Integration

Write for your audience

CSCI-1200 Data Structures Fall 2009 Lecture 25 Concurrency & Asynchronous Computing

Soda Machine Laboratory

CT 229 Arrays in Java

CS 354R: Computer Game Technology

Classes, interfaces, & documentation. Review of basic building blocks

Interlude. Object Oriented Design

Chapter 6 Introduction to Defining Classes

Object-Oriented Design

Deriving Model-to-Code Transformation Rules at the Meta- Model Level

Principles of Computer Game Design and Implementation. Lecture 3

Game Development for

Lecture 24. GUI Applications

Hackveda Appsec Labs Java Programming Course and Internship Program Description:

Lecture 10 Notes Linked Lists

Setting up A Basic Scene in Unity

6.170 Laboratory in Software Engineering Java Style Guide. Overview. Descriptive names. Consistent indentation and spacing. Page 1 of 5.

Software Architecture

Server: Discrete Event-Driven Simulations

Lecture Notes on Memory Layout

Binghamton University. CS-211 Fall Software Design

SystemVerilog Essentials Simulation & Synthesis

Process Modelling. Fault Tolerant Systems Research Group. Budapest University of Technology and Economics

Lecture 10 Notes Linked Lists

[CHAPTER] 1 INTRODUCTION 1

Week 1 INTRODUCTION TO WEB DESIGN

College Board. AP CS A Labs Magpie, Elevens, and Picture Lab. New York: College Entrance Examination Board, 2013.

Abstract Classes and Interfaces

Principles of Computer Game Design and Implementation. Lecture 11

Unity Game Development

BEAWebLogic. Portal. Overview

Introduction to Extreme Programming

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Introduction to Unreal Engine Blueprints for Beginners. By Chaven R Yenketswamy

(Refer Slide Time: 02.06)

Mathematics/Science Department Kirkwood Community College. Course Syllabus. Computer Science CSC142 1/10

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107

GB Programming Challenges

Process Modelling. Fault Tolerant Systems Research Group. Budapest University of Technology and Economics

Extreme programming XP 6

Word Found Meaning Innovation

CS 160: Interactive Programming

61A LECTURE 1 FUNCTIONS, VALUES. Steven Tang and Eric Tzeng June 24, 2013

Objects First with Java

Lecture 04 FUNCTIONS AND ARRAYS

Dealing with Bugs. Kenneth M. Anderson University of Colorado, Boulder CSCI 5828 Lecture 27 04/21/2009

Lecture 34 SDLC Phases and UML Diagrams

Course Wrap-up. CSC207 Fall 2015

Lecture Notes on Queues

Agile Development

What s Next. INF 117 Project in Software Engineering. Lecture Notes -Spring Quarter, Michele Rousseau Set 6 System Architecture, UML

(Movement - Synthesis) Improve existing programming skills by developing much larger and more complex programs than in previous classes.

EECS 282 Information Systems Design and Programming. Atul Prakash Professor, Computer Science and Engineering University of Michigan

Object-Oriented Software Engineering Practical Software Development using UML and Java. Chapter 2: Review of Object Orientation

CS61B, Spring 2003 Discussion #17 Amir Kamil UC Berkeley 5/12/03

Transcription:

Lecture 13

Take Away for Today What should lead programmer do? How do CRC cards aid software design? What goes on each card? How do you lay m out? What properties should y have? How do activity diagrams aid design? How do y relate to CRC cards? Difference between design & documentation 2

Role of Lead Programmer Make high-level architecture decisions How are you splitting up MVC? What is your computation model? What is stored in data files? What third party libraries are you using? Divide work among programmers Who works on what parts of game? What do y need to coordinate? 3

Architecture: The Big Picture 4

Identify Modules (Subsystems) Modules: logical unit of functionality Often reusable over multiple games Implementation details are hidden API describes interaction with rest of system Natural way to break down work Each programmer decides implementation But entire team must agree on API Specification first, n programming 5

Architecture: The Big Picture API Subsystem or Module 6

Example: Physics Engines API to manipulate objects Put physics objects in container Specify ir connections (e.g. joints) Specify forces, velocity Everything else hidden from user Collisions detected by module Movement corrected by module 7

Relationship Graph Shows when one module depends on anor Module A calls a method/function of Module B Module A creates/loads instance of Module B General Rule: Does A need API of B? How would we know this? Module 1 Module 2 Module 3 Module 1 does not need to know about Module 3 8

Relationship Graph Edges in relationship graph are often directed If A calls a method of B, is B aware of it? But often undirected in architecture diagrams Direction clear from or clues (e.g. layering) Developers of both modules should still agree on API Module 1 Module 2 Module 3 Does Module 1 need to know about Module 2? 9

Dividing up Responsibilities Each programmer has a module Programmer owns module Final word on implementation Owners collaborate w/ neighbors Agree on API at graph edges Call meetings Interface Parties Works, but must agree on modules and responsibilities ahead of time Module 1 Module 2 Module 3 Owner: Bob Owner: Anne Owner: Doug 10

Nested (Sub)modules Can do this recursively Module is a piece of software Module 1 Can break into more modules Nested APIs are internal Only needed by module owner Parent APIs may be different! Critical for very large groups Module 2 Each small team gets a modules Inside team, break up furr Even deeper hierarchies possible 11

Architecture: The Big Picture Nested Module 12

How Do We Get Started? Remember design caveat: Must agree on module responsibilities first Orwise, code is duplicated or even missing Requires a high-level architecture plan Enumeration of all modules What ir responsibilities are Their relationships with each or Responsibility of lead architect 13

Design: CRC Cards Class-Responsibility-Collaboration Class: Important class in subsystem Responsibility: What that class does Collaboration: Or classes required May be part of anor subsystem English description of your API Responsibilities become methods Collaboration identifies dependencies 14

Controller Responsibility Enumerates game objects in scene Adds/removes game objects to scene Selects object at mouse location CRC Card Examples Responsibility Pathfinding: Avoiding obstacles Strategic AI: Planning future moves Character AI: NPC personality Model AI Controller Scene Model Game Object Game Object Class Name Collaboration Game Object, Scene Model Player Model, Action Model Game Object, Level Editor Script Collaboration Mouse Event, Game Object 15

Creating Your Cards Start with MVC Pattern Gives 3 basic subsystems List responsibilities of each May be all that you need (TemperatureConverter) Split up a module if Too much for one person API for module too long Don t need to nest (yet) Module Responsibility Collaboration Perils of ravioli code 16

Creating Your Cards Start with MVC Pattern Gives 3 basic subsystems List responsibilities of each Module 1 Responsibility Collaboration May be all that you need (TemperatureConverter) Split up a module if Too much for one person API for module too long Don t need to nest (yet) Module 2 Responsibility Collaboration Perils of ravioli code 17

Avoid Cyclic Collaboration Controller collaborates with Z Y collaborates with X Y collaborates with X 18

Avoid Cyclic Collaboration Example: Lab 3 Ship fires projectiles Must add to game state Originally all in model Ship referenced game state And game state stored ship Cyclic Reference Game State Ship.cs We added a new controller It references game state Only it adds to game state Cycle broken 19

Avoid Cyclic Collaboration Example: Lab 3 Ship fires projectiles Must add to game state GameplayController.cs Originally all in model Ship referenced game state And game state stored ship Cyclic Reference We added a new controller It references game state Only it adds to game state Cycle broken Game State Ship.cs 20

Alternative: Interfaces Relationships are for APIs Implementation not relevant Can be class or interface Interfaces can break cycles Start with single class Break into many interfaces Refer to interface, not class Needed if actions in model Abstracts game state Hides all but relevant data GameplayController.cs Game State Ship.cs 21

Architecture: The Big Picture 22

CRC Index Card Exercise Responsibility Try to make collaborators adjacent Class 1 Collaboration Class 2 Class 3 Class 4 Class 2 Responsibility Collaboration Class 3 Responsibility Collaboration 23 If cannot do this, time to think about nesting! Responsibility Class 4 Collaboration

Designing Class APIs Make classes formal Turn responsibilities into methods Turn collaboration into parameters Responsibility Enumerates game objects Adds game objects to scene Removes objects from scene Selects object at mouse Scene Model Method Iterator<GameObject> enumobjects() void addobject(gameobject) void removeobject(gameobject) GameObject getobject(mouseevent) 24

Documenting APIs Use a formal documentation style What parameters method takes What values method returns What method does (side effects) How method responds to errors (exceptions) Make use of documentation comments Example: JavaDoc in Java C# uses an XML style for comments 25

Documenting API (Java) /**! * Returns an Image object that can n be painted on screen. The url! * argument must specify an absolute {@link URL}. The name argument is! * a specifier that is relative to url argument.! * <p>! * This method always returns immediately, wher or not image exists.! * When this applet attempts to draw image on screen, data will! * be loaded. The graphics primitives that draw image will incrementally! * paint on screen.! *! * @param url an absolute URL giving base location of image! * @param name location of image, relative to url argument! * @return image at specified URL! * @see Image! */! public Image getimage(url url, String name) {! try {! return getimage(new URL(url, name));! } catch (MalformedURLException e) { return null; } } 26

Documenting API (C#/XNA) /// <summary>! /// Returns an Image object that can n be painted on screen. The url! /// argument must specify an absolute <see cref="url"/>. The name argument! /// is a specifier that is relative to url argument.! /// <p/>! /// This method always returns immediately, wher or not image exists.! /// When this applet attempts to draw image on screen, data will! /// be loaded. The graphics primitives that draw image will incrementally! /// paint on screen.! /// </summary>! /// <param name="url">an absolute URL giving base location of image</param>! /// <param name="name"> location of image, relative to url argument</param>! /// <returns> image at specified URL </returns>! /// <see cref="image"/>! public Image getimage(url url, String name) {! try {! return getimage(new URL(url, name));! } catch (MalformedURLException e) { return null; } } 27

Taking This Idea Furr UML: Unified Modeling Language Often used to specify class relationships But expanded to model or things Examples: data flow, human users How useful is it? Extremely useful for documentation Less useful for design (e.g. before implementation) A language to program in anor language 28

Activity Diagrams Define workflow of your program Very similar to a standard flowchart Can follow simultaneous paths (threads) Are an component of UML But did not originate with UML Mostly derived from Petri Nets One of most useful UML design tools Activity diagrams are only UML we use 29

Activity Diagram Example Find Beverage [found coffee] [no coffee] [found cola] [no cola] Put Coffee in Filter Add Water to Reservoir Get Cups Get Can of Cola Put Filter in Machine Turn On Machine Brew Coffee [coffee dispensed] Pour Coffee Drink Beverage 30

Activity Diagram Example Start Find Beverage [found coffee] [no coffee] Guard Decision [found cola] [no cola] Put Coffee in Filter Add Water to Reservoir Get Cups Get Can of Cola Activity Put Filter in Machine Synch Bar Turn On Machine Brew Coffee Synch Condition [coffee dispensed] Pour Coffee Drink Beverage End 31

Activity Diagram Components Synchronization Bars In: Wait until have happened Out: Actions simultaneous or order does not matter Potential Threads Decisions In: Only needs one input Out: Only needs one output Guards When we can follow edge * is iteration over container [if yes] If-Then Logic *[for each] 32

Asynchronous Pathfinding Get Input *[for each object] Determine Goal *[for each selected] Reset Pathfinder Measure to Goal [new goal] [path found] * * Find Path [all objects checked] *[for each object] Move Object Draw 33

Asynchronous Pathfinding Get Input *[for each object] Determine Goal Iteration *[for each selected] Reset Pathfinder Measure to Goal [new goal] [path found] * * Buffer Find Path [all objects checked] *[for each object] Move Object Draw Task Separator 34

Asynchronous Pathfinding Get Input *[for each object] [all objects checked] Measure to Goal Move Object Determine Goal *[for each selected] *[for each object] Iteration [new goal] [path found] * Reset Pathfinder Synchronization + Guard Think of as multiple outgoing * Buffer edges (with guard) from bar Find Path 35 Draw Task Separator

Expanding Level of Detail Get Input *[for each object] Measure to Goal Determine Goal *[for each selected] [new goal] * Draw [path found] Background * Reset Pathfinder Find Path [all objects checked] Move Object *[for each object] Draw Objects Draw HUD Draw 36

Using Activity Diagrams Good way to identify major subsystems Each action is a responsibility Need extra responsibility; create it in CRC Responsibility not re; remove from CRC Do activity diagram first? Anor iterative process Keep level of detail simple Want outline, not software program Update Draw 37

Architecture Specification Identify major subsystems in CRC cards List responsibilities List collaborating subsystems Draw activity diagram Make sure agrees with CRC cards Revise CRC cards if not Create class API from CRC cards Recall intro CS courses: specifications first! 38

Programming Contract Once create API, it is a contract Promise to team that works this way Can change implementation, but not interface If change interface, must refactor Restructure architecture to support interface May change CRCs and activity diagram Need to change any written code 39

Summary Architecture design starts at a high level Class-responsibilities-collaboration Layout as cards to visualize dependencies Activity diagrams useful for update loop Outline general flow of activity Identifies dependencies in process Must formalize class APIs Same detail as Java documentation Creates a contract for team members 40