Design of Large Programs
Design of Large Programs CS 351L
Popular in Course
Popular in ComputerScienence
This 15 page Class Notes was uploaded by Trent Dare on Wednesday September 23, 2015. The Class Notes belongs to CS 351L at University of New Mexico taught by Joe Kniss in Fall. Since its upload, it has received 11 views. For similar materials see /class/212198/cs-351l-university-of-new-mexico in ComputerScienence at University of New Mexico.
Reviews for Design of Large Programs
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 09/23/15
Interfaces amp Generics I g i 7 Lecture O3Aug 28 2007 LastTime 1 i 0 Testing is important i 0 We discussedJUnit 3 0 JUnit 4 is quite different RTFM 0 Use assert ltyour boolean test heregt O WLL be looking for ster here Clean code 0 DeathBox spec ambiguity 0 String containing an integer 0 Does 6abc live or die n HThelnterface worldview 0 Java supports programming by interfaces 0 Idea don t hardcode concrete classes into your code 0 Instead refer to everything through interfaces 0 Why l The Interface worIdVIew Design principle Principle of Abstraction Only work with the relevant aspects of a thing ignore stuff that39s not immediater relevant l The Interface worldVIew Design principle Centralized Definition De ne a thing only once in a program use a symbolic name to refer to it later Aka Don t repeat yourself Code examples Interfaces l Interface for Death Box public interface DeathBox gtkgtk gt Attempt to put another object into a DeathBox gtk param o the object to attempt to place in the DeathBox return true if 0 was put into the DeathBox successfully and false if 39you died39 attempting to put it in or were already dead before the latest putlnto attempt gtk public boolean putlntoObject o l Implementation of 0 Implement the interface public class DeathBoxKniss implements DeathBox constructor public DeathBoxKniss dead false function description here public boolean putlntoObject o if dead return false private boolean dead llMoreon Interfaces 1 l O Interfaces only declare functions l O No function de nitions no body 0 They do not allow protectedprivate functions 0 Only legal if the user can call it 0 They do not allow member variables 0 Interfaces themselves have no state 0 Constants ARE allowed tho public static nal llnterfaces as concepts g7 0 Multiple inheritance is illegal in java 0 A class CAN implement multiple interfaces 0 Abstract generic behaviors for example 0 Comparable O Additive 0 Iteration Note use of generic type T here public interface ComparableltTgt int compareToT obj llnterfaces are extensible g7 0 You can add more functionality public interface MyCompareltTgt extends ComparableltTgt boolean isSameT obj 0 You can compose interfaces 0 New interface with properties of multiple 0 Looks like multiple inheritance public interface Z extends XY lAccessing Constants 0 There can be ambiguity with interfaces public interfaceA int vall public interface B extendsA int val2 public class C implements B 0 Which value to we access C c new C cval lAccessing Constants 0 There can be ambiguity with interfaces public interfaceA int vall public interface B extendsA int val2 public class C implements B 0 Which value to we access C c new C cval 2 Acval l IIVVthnte rfaces Separate appearance and behavior Interface how the object looks to programmer Implementation how the object behaves How is this different than inheritance Interfaces allow a clean view of a class Do you write the test for O DeathBox interface or 0 DeathBoxltyournameheregt class 0 How does JUnit affect this
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'