Code reading skills LEVEL GAME.  Common scenario:  Students raise hand. Point to code, say they don’t understand why it’s not working.  public void.

Slides:



Advertisements
Similar presentations
And so to Code. Forward, Reverse, and Round-Trip Engineering Forward Engineering Reverse Engineering Round-Trip Engineering.
Advertisements

UML Diagrams Jung Woo. What is UML? Standard language for specifying, visualizing, constructing, and documenting the artifacts of software systems, business.
C Lab 3 C Arraylist Implementation. Goals ●Review ○ Referencing/Dereferencing ○ Free ●realloc and memmove ●ArrayList ●Debugging with GDB.
General OO Concepts and Principles CSE301 University of Sunderland Harry R. Erwin, PhD.
Chapter 3.5 Debugging Games
Ch 12: Object-Oriented Analysis
Software Engineering and Design Principles Chapter 1.
Designing Classes Chapter 3. 2 Chapter Contents Encapsulation Specifying Methods Java Interfaces Writing an Interface Implementing an Interface An Interface.
Design The goal is to design a modular solution, using the techniques of: Decomposition Abstraction Encapsulation In Object Oriented Programming this is.
Programming in Java CSE301 Half Lecture Harry Erwin, PhD University of Sunderland.
Chapter 15 Interaction Diagrams. Most Common Sequence Diagram Communication Diagram Sequence Diagrams illustrate interactions between classes of a program.
Structured Programming and UML Overview Session 2 LBSC 790 / INFM 718B Building the Human-Computer Interface.
Fall 2007CS 2251 Software Engineering Intro. Fall 2007CS 2252 Topics Software challenge Life-cycle models Design Issues Documentation Abstraction.
CS350/550 Software Engineering Lecture 1. Class Work The main part of the class is a practical software engineering project, in teams of 3-5 people There.
IEG 3080 Tutorial 1 Wilson Ip. Outline Lecture reviews: Some basics of Software Engineering principle Some basics of OOP How to use Visual Studio.NET.
1 CSC 1401 S1 Computer Programming I Hamid Harroud School of Science and Engineering, Akhawayn University
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
Architecture, Implementation, and Testing Architecture and Implementation Prescriptive architecture vs. descriptive architecture Prescriptive architecture:
Pattern Abstract Factory
Basic Concepts The Unified Modeling Language (UML) SYSC System Analysis and Design.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
Chapter 7 Requirement Modeling : Flow, Behaviour, Patterns And WebApps.
CS 8532: Adv. Software Eng. – Spring 2007 Dr. Hisham Haddad Tuesday Class will start momentarily. Please Stand By … CS 8532: Advanced Software.
1 Shawlands Academy Higher Computing Software Development Unit.
Design Patterns OOD. Course topics Design Principles UML –Class Diagrams –Sequence Diagrams Design Patterns C#,.NET (all the course examples) Design Principles.
Design Dan Fleck CS 421 George Mason University. What is the design phase? Analysis phase describes what the system should do Analysis has provided a.
Introduction Ellen Walker CPSC 201 Data Structures Hiram College.
CSC 213 – Large Scale Programming Lecture 2: Object-Oriented Analysis & Object-Oriented Design.
CS 3610: Software Engineering – Spring 2009 Dr. Hisham Haddad – CSIS Dept. Class Project OO Design Document Here is what you need to do for your class.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
Putting together a complete system Chapter 10. Overview  Design a modest but complete system  A collection of objects work together to solve a problem.
Introduction to Software Design Chapter 1. Chapter Objectives  To become familiar with the software challenge and the software life cycle  To understand.
1 The Software Development Process  Systems analysis  Systems design  Implementation  Testing  Documentation  Evaluation  Maintenance.
Overloading Binary Operators Two ways to overload –As a member function of a class –As a friend function As member functions –General syntax Data Structures.
CSC 395 – Software Engineering Lecture 13: Object-Oriented Analysis –or– Let the Pain Begin (At Least I’m Honest!)
Question of the Day  On a game show you’re given the choice of three doors: Behind one door is a car; behind the others, goats. After you pick a door,
Dr. Tom WayCSC Testing and Test-Driven Development CSC 4700 Software Engineering Based on Sommerville slides.
Question of the Day  On a game show you’re given the choice of three doors: Behind one door is a car; behind the others, goats. After you pick a door,
Effective C#, Chapter 1: C# Language Elements Last Updated: Fall 2011.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
SWE © Solomon Seifu ELABORATION. SWE © Solomon Seifu Lesson 12-5 Software Engineering Design Goals.
UML diagrams What is UML UML diagrams –Static modeoing –Dynamic modeling 1.
Code reading skills LEVEL GAME.  Skeleton has error messages.  Notice the red lines on right slider. Click… you’ll go to an error.  pieces = levels.getPieces();
Software Engineering Principles. SE Principles Principles are statements describing desirable properties of the product and process.
CS242.  Reduce Complexity  Introduce an intermediate, understandable abstraction  Avoid code duplication  Support subclassing  Hide sequences  Hide.
“The perfect project plan is possible if one first documents a list of all the unknowns.” Bill Langley.
Incremental Design Why incremental design? Goal of incremental design Tools for incremental design  UML diagrams  Design principles  Design patterns.
Refactoring 2. Admin Blackboard Quiz Acknowledgements Material in this presentation was drawn from Martin Fowler, Refactoring: Improving the Design of.
The Software Development Process
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Chapter 8 Lecture 1 Software Testing. Program testing Testing is intended to show that a program does what it is intended to do and to discover program.
Software Design Patterns Curtsy: Fahad Hassan (TxLabs)
Lecture 4 Page 1 CS 111 Online Modularity and Virtualization CS 111 On-Line MS Program Operating Systems Peter Reiher.
Spring 2007 Week 10: Object Modeling (1)Use Case Model IFS410: Advanced Analysis and Design.
SOLID Design Principles
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
CSIS 4850: CS Senior Project – Spring 2009 CSIS 4850: Senior Project Spring 2009 Object-Oriented Design.
Mid-Year Review. Coding Problems In general, solve the coding problems by doing it piece by piece. Makes it easier to think about Break parts of code.
Unified Modeling Language. What is UML? Standard language for specifying, visualizing, constructing, and documenting the artifacts of software systems,
CSCE 240 – Intro to Software Engineering Lecture 3.
Chapter 4: Business Process and Functional Modeling, continued
UML Diagrams By Daniel Damaris Novarianto S..
Chapter 3: Using Methods, Classes, and Objects
UML Diagrams Jung Woo.
Object-Orientated Programming
Testing and Test-Driven Development CSC 4700 Software Engineering
CS 8532: Advanced Software Engineering
Chapter 2. Problem Solving and Software Engineering
Object Oriented Design & Analysis
Presentation transcript:

Code reading skills LEVEL GAME

 Common scenario:  Students raise hand. Point to code, say they don’t understand why it’s not working.  public void someFn() {  if (some condition)  do some action;  }  assumption: method is called  assumption: if condition is true  Test your assumptions! How? println OR use debugger  GUI program… println may be better  repeated code… println may be better  otherwise… debugger may be better DEBUGGING AS SCIENTIFIC METHOD

 Eclipse will take you directly to the line of code generating the error  obj.var OR obj.method()  What if: obj.method(obj2.getter().method());  May need to break apart to see which is null  In general, null pointer exceptions are fairly easy to diagnose. 1.Figure out which object is null 2.Figure out where you think memory should have been allocated 3.Figure out why it wasn’t (often because method that allocates space is not actually called, OR you allocate space for a local variable)  Remember, you need to allocate space for the collection (array, ArrayList, etc.) AND allocate space for each element in the collection. NULL POINTER EXCEPTION

UML

for (Moveable piece : movingPieces) { piece.move(pieces, playerLocation); } for (InteractingPiece piece : interactingPieces) { InteractionResult result = piece.interact(pieces, playerLocation); // use result to determine how to update player status } for (? piece : pieces) { if this piece moves move it…. NOTE: all pieces must now have a move method (may be blank) if this piece interacts get the result …. NOTE: all pieces must now have interact method update INTERFACES CAN SIMPLIFY CODE

 Don’t make your interfaces “fat”  no client should be forced to depend on methods it does not use.  ISP splits interfaces which are very large into smaller and more specific ones so that clients will only have to know about the methods that are of interest to them. INTERFACE SEGREGATION PRINCIPLE Wikipedia

 Single Responsibility Principle  every class should have responsibility over a single part of the functionality provided by the software, and that responsibility should be entirely encapsulated by the class. All its services should be narrowly aligned with that responsibility.  Martin defines a responsibility as a reason to change, and concludes that a class or module should have one, and only one, reason to change.  Why would LevelEngine change? Ultimately, it would change if config files that define levels change.  Why would GameEngine change? If rules of game play change.  What if we don’t expect level definition format to change? May not need two classes. DO WE NEED LEVEL ENGINE?

WITHOUT LEVEL ENGINE

 Purpose of UML is to communicate  Agile manifesto: value working software over comprehensive documentation  Does NOT mean no documentation ever!  UML is used especially to show relationships between classes  Do we need all the GameEngine details?  In fact, do all the GameEngine methods need to be public?  Would any other class call these methods? UML COMPLEXITY

WITH PRIVATE METHODS

 Use abstract class if there are common attributes  Use abstract class if you want to provide some (but not all) method implementations  THIS EXERCISE  No attributes that are really needed for ALL pieces  BUT, it’s a simple enough game that a valid alternative might be to use an abstract Piece class  In a more complex game, might want to stick with interfaces  Enemy: weapon, strength, attack()  Friend: goodWill, assist()  Treasure: pointValue  Obstacle: secretWord, disable()  All can be drawn, some move and some don’t INTERFACE VS ABSTRACT CLASS

ABSTRACT CLASS