Title: Comp 110 Style
1Comp 110Style
- Instructor Sasa Junuzovic
2Interfaces and More Style
- Define contracts between our users and
implementers - Optional they may not be used
- Good style to use them
- Will study additional elements of style in this
chapter
3Two Ways of Doing the BMI Spreadsheet
- ABMISpreadsheet is one way to implement the
spreadsheet user-interface - Let us create AnotherBMISpreadsheet to illustrate
another way - Difference is in number of variables used
4BMI Spreadsheet
5ABMISpreadsheet
ABMISpreadsheet Instance
weight
height
writes
reads
reads
writes
reads
getWeight()
setWeight()
getHeight()
setHeight()
getBMI()
calls
calls
calls
calls
new weight
new height
weight
height
ObjectEditor
6AnotherBMISpreadsheet
AnotherBMISpreadsheet Instance
weight
height
bmi
writes
reads
reads
reads
writes
getWeight()
setWeight()
getHeight()
setHeight()
getBMI()
calls
calls
calls
calls
new weight
new height
weight
height
ObjectEditor
7Methods that Change
ABMISpreadsheet Instance
weight
height
bmi
writes
reads
writes
setWeight()
setHeight()
getBMI()
calls
calls
new weight
new height
ObjectEditor
8setWeight()
ABMISpreadsheet Instance
weight
bmi
writes
setWeight()
public void setWeight(double newWeight) weight
newWeight bmi weight / (heightheight)
calls
new weight
ObjectEditor
9setHeight()
ABMISpreadsheet Instance
height
bmi
writes
setHeight()
public void setHeight(double newHeight) height
newHeight bmi weight / (heightheight)
calls
new height
ObjectEditor
10getBMI()
ABMISpreadsheet Instance
bmi
reads
getBMI()
public double getBMI() return bmi
ObjectEditor
11Complete Code
public class AnotherBMISpreadsheet double
height, weight, bmi public double
getHeight() return height
public void setHeight(double newHeight)
height newHeight bmi
weight/(heightheight) public double
getWeight() return weight
public void setWeight(double newWeight)
weight newWeight bmi
weight/(heightheight) public double
getBMI() return bmi
12Graphical Algorithm
ABMISpreadsheet Instance
weight
height
bmi
writes
reads
reads
reads
writes
getWeight()
setWeight()
getHeight()
setHeight()
getBMI()
calls
calls
calls
calls
new weight
new height
weight
height
ObjectEditor
13English Algorithm
- Declare three instance variables
- weight, height and, bmi
- Define three getter methods return values of the
three instance variables - Define two setter methods to change weight and
height - The setter methods assign new weight and height
values and compute and assign new BMI value to bmi
14Algorithm
- Description of solution to a problem
- Can be in any language
- graphical
- natural or programming language
- natural programming language (pseudo code)
- Can describe solution to various levels of detail
15Stepwise Refinement
Natural Language
- Declare three instance variables
- weight, height and, bmi
- Define three getter methods return values of the
three instance variables - Define two setter methods to change weight and
height - The setter methods assign new weight and height
values and compute and assign new BMI value to bmi
Programming Language
public void setWeight(double newWeight) weight
newWeight bmi weight/(heightheight)
16ObjectEditor User Interface?
public class AnotherBMISpreadsheet double
height, weight, bmi public double
getHeight() return height
public void setHeight(double newHeight)
height newHeight bmi
weight/(heightheight) public double
getWeight() return weight
public void setWeight(double newWeight)
weight newWeight bmi
weight/(heightheight) public double
getBMI() return bmi
17ObjectEditor User Interfaces
18Similarities in the Two Classes
public class AnotherBMISpreadsheet double
height, weight, bmi public double
getHeight() return height
public void setHeight(double
newHeight) height newHeight
bmi weight/(heightheight) public
double getWeight() return weight
public void setWeight(double
newWeight) weight newWeight
bmi weight/(heightheight) public
double getBMI() return bmi
public class ABMISpreadsheet double
height public double getHeight()
return height public void
setHeight(double newHeight)
height newHeight double
weight public double getWeight()
return weight public void
setWeight(double newWeight)
weight newWeight public double
getBMI() return weight/(heightheight)
19Real-World Analogy
implements
manufactures
Corvette Specification
implements
manufactures
20Interface
21Implementing an Interface
Contract
public class AnotherBMISpreadsheet implements
BMISpreadsheet double height, weight, bmi
public double getHeight() return
height public void setHeight (double
newHeight) height newHeight
bmi weight/(heightheight)
Parameter names never matter to Java
22Interface
ABMISpreadsheet
implements
instance of
BMISpreadsheet
ABMISpreadsheet instance
ABMISpreadsheet instance
implements
AnotherBMISpreadsheet
instance of
AnotherBMISpreadsheet instance
AnotherBMISpreadsheet instance
23Using Interfaces to Classify
ABMISpreadsheet
implements
instance of
BMISpreadsheet
BMISpreadsheet instance
BMISpreadsheet instance
implements
AnotherBMISpreadsheet
instance of
BMISpreadsheet instance
BMISpreadsheet instance
24Using Car Specifications to Classify
Corvette
implements
manufactures
Corvette
Corvette Specification
implements
Corvette
manufactures
Corvette
25Cannot Instantiate Specification
- Cannot order a car from a specification
- Must order from factory
- A car defined by Corvette specification ordered
from factory implementing the specification - Cannot instantiate interface
- Must instantiate class
- BMISpreadsheet instance created by instantiating
class implementing interface
26Interface as a Syntactic Specification
public class ABMISpreadsheet implements
BMISpreadsheet double height public
double getHeight() return height
public void setHeight(double newHeight)
height newHeight double
weight public double getWeight()
return weight public void
setWeight(double newWeight) weight
newWeight public double getBMI()
return weight/(heightheight)
27Interface as a Syntactic Specification
public class ABMISpreadsheet implements
BMISpreadsheet double height public
double getHeight() return height
public void setHeight(double newHeight)
height newHeight double
weight public double getWeight()
return weight public void
setWeight(double newWeight) weight
newWeight public double getBMI()
return 13450
Syntactic Contract
Bombay Market Index
28Interface Required
- Define interfaces for
- All classes (that are instantiated)
- Some are not
- Include all public methods
29Differences in the Two Classes
public class AnotherBMISpreadsheet double
height, weight, bmi public double
getHeight() return height
public void setHeight(double
newHeight) height newHeight
bmi weight/(heightheight) public
double getWeight() return weight
public void setWeight(double
newWeight) weight newWeight
bmi weight/(heightheight) public
double getBMI() return bmi
public class ABMISpreadsheet double
height public double getHeight()
return height public void
setHeight(double newHeight)
height newHeight double
weight public double getWeight()
return weight public void
setWeight(double newWeight)
weight newWeight public double
getBMI() return weight/(heightheight)
30ABMISpreadsheet vs. AnotherBMISpreadsheet
- ABMISpreadsheet uses less space (variables)
- Getter methods of AnotherBMISpreadhseet are
faster - Setter methods of ABMISpreadsheet are faster
- Usually getter methods are called more often that
setter methods - e.g. when ObjectEditor refresh command is
executed - Typically AnotherBMISpreadsheet will be faster,
overall
31Time-Space Tradeoff
Time
Space
32Time-Space Tradeoff
Space
Time
Time Miser
Space Miser
33Relating Interface and Class Names
Class Name
- ABMISpreadsheet -
ASpaceEfficientBMISpreadsheet -
SpaceEfficientBMISpreadsheet
Impl - BMISpreadsheetImpl
- BMISpreadsheetSpaceEfficientImpl
Interface Name
Interface - ABMISpreadsheetInterface
34Programming Style The Art of Programming
- Science of programming
- Does the program work correctly?
- Art programming
- Does the program follow good style rules?
- Good style rules make it easier to
- Get the program working correctly
- Change the program
35Writing Style
- To the point
- Avoid repetition
- Good flow
- Illustrate ideas
There is more than one way to write a document
that conveys some facts e.g. the influence of
BMI on health
36Programming Style The Art of Programming
- Define interfaces
- Make programs efficient
- Space vs. time
- Comment program
- Use appropriate identifier names
- Use named constants
- Variables vs. names
- Constants vs. magic numbers
- Avoid code repetition
- Give least privilege
- No public instance variables
- Implementation independent constants in
interfaces - Initialize variables
- Independent code in separate method
There is more than one way to write a program
that correctly meets its specification e.g.
implement the BMI user-interface
37Programming Style The Art of Programming
?
Use Interfaces
?
Efficiency
Comment Program
Avoid Code Repetition
Giving Least Privilege
Use Named Constants
38Comments
Single line comments
double bmi //computed by setWeight and setHeight
Arbitrary comments
/ This version recalculates the bmi when
weight or height change, not when getBMI is
called / public class AnotherBMISpreadsheet
/ recompute dependent properties / bmi
weight / (height height)
39JavaDoc Conventions
/ This version recalculates the bmi when weight
or height change, not when getBMI is
called / public class AnotherBMISpreadsheet
/ This version recalculates the bmi when
weight or height change, not when getBMI is
called / public class AnotherBMISpreadsheet
You should use this convention
40Removing Debugging Code
System.out.println(newHeight) /debugging
statement /
/ System.out.println(newHeight)
/debugging statement / /
/ System.out.println(newHeight) //
debugging statement /
41What to Comment?
- Any code fragment needing explanation
- Class
- Top-level algorithm, author, date modified
- Variable declaration
- Purpose, where used, how its value is computed
- Method declaration
- params, return value, algorithm, author, date
modified - Statement sequence
- Explanation
- Debugging code
Summarizing vs. Elaborating Comments?
42What to Comment?
double w // weight
Bad variable name
double weight // weight
Redundant
double weight
Self-commenting
double bmi // computed by setWeight and setHeight
Useful comment
43JavaDoc Tags
JavaDoc tags
/ _at_author Prasun Dewan _at_param newWeight
the new value of the property, weight. sets
new values of the variables, weight and bmi
/ public void setWeight (double newWeight)
/ _at_author Prasun Dewan _at_return the value
of the variable, weight / public double
getWeight ()
44Commenting Interfaces
Implementation independent comments
/ _at_param newWeight the new value of the
property, weight / public void setWeight
(double newWeight)
/ _at_return the value of the variable, weight
/ public double getWeight ()
Commenting both interface and implementation?
45Programming Style The Art of Programming
?
Use Interfaces
?
Efficiency
?
Comment Program
Avoid Code Repetition
Giving Least Privilege
Use Named Constants
46Improving the Style
public class AnotherBMISpreadsheet implements
BMISpreadsheet double height, weight, bmi
public double getHeight() return
height public void setHeight(double
newHeight) height newHeight
bmi weight/(heightheight) public
double getWeight() return weight
public void setWeight(double newWeight)
weight newWeight bmi
weight/(heightheight) public double
getBMI() return bmi
Code repetition
Assuming ABMICalculator does not exist
47Improving the Style (Edit)
public class AnotherBMISpreadsheet implements
BMISpreadsheet double height, weight, bmi
public void setHeight(double newHeight)
height newHeight bmi
calculateBMI() public void
setWeight(double newWeight) weight
newWeight bmi calculateBMI()
public double getBMI() return bmi
double calculateBMI() return
weight/(heightheight)
48Re-using Code
public class AnotherBMISpreadsheet implements
BMISpreadsheet double height, weight, bmi
public double getHeight() return
height public void setHeight(double
newHeight) height newHeight
bmi calculateBMI() public double
getWeight() return weight
public void setWeight(double newWeight)
weight newWeight bmi
calculateBMI() double calculateBMI()
return weight/(heightheight)
.
49Changing Re-used Code Once
public class AnotherBMISpreadsheet implements
BMISpreadsheet double height, weight, bmi
public void setHeight(double newHeight)
height newHeight bmi
calculateBMI() public double
getWeight() return weight
public void setWeight(double newWeight)
weight newWeight bmi
calculateBMI() double calculateBMI()
return (weight/2.2)/(height
2.54/100height2.54/100)
Declaring vs. calling methods?
50Programming Style The Art of Programming
?
Use Interfaces
?
Efficiency
?
Comment Program
?
Avoid Code Repetition
Giving Least Privilege
Use Named Constants
51Only Public Methods in Interface
public class AnotherBMISpreadsheet implements
BMISpreadsheet double height, weight, bmi
public double getHeight() return
height public void setHeight(double
newHeight) height newHeight
bmi calculateBMI() double
calculateBMI() () return
(weight/2.2)/(height 2.54/100height2.54/100)
Not in interface
52Principle of Least Privilege
- Do not give a user of some code more rights than
it needs - Code is easier to change
- Need to learn less to use code
- Less likelihood of accidental or malicious
damage to program - Like hiding engine details from car driver
ABMICalculator User
ABMICalculator
ObjectEditor
getWeight()
setWeight()
getHeight()
setHeight()
getBMI()
computeBMI()
53Improving the Style
?
Use Interfaces
?
Efficiency
?
Comment Program
?
Avoid Code Repetition
?
Giving Least Privilege
Use Named Constants
54Improving the Style
public class AnotherBMISpreadsheet implements
BMISpreadsheet double height, weight, bmi
public double getHeight() return
height public void setHeight(double
newHeight) height newHeight
bmi calculateBMI() double
calculateBMI() () return
(weight/2.2)/(height 2.54/100height2.54/100)
Magic numbers
55Improving the Style
public class AnotherBMISpreadsheet implements
BMISpreadsheet double height, weight, bmi
public double getHeight() return
height public void setHeight(double
newHeight) height newHeight
bmi calculateBMI() double
calculateBMI() () return
(weight/LBS_IN_KG) /
(heightCMS_IN_INCH/100heightCMS_IN_INCH/100)
Named constants
56Declaring Named Constants
public class AnotherBMISpreadsheet implements
BMISpreadsheet double height, weight, bmi
... final double LBS_IN_KG 2.2
final double CMS_IN_INCH 2.54 double
calculateBMI() return
(weight/LBS_IN_KG) /
(heightCMS_IN_INCH/100heightCMS_IN_INCH/100)
Un-initializing declaration
Initializing declaration
57More on Variables vs. Named Constants
public class AnotherBMISpreadsheet implements
BMISpreadsheet double height, weight, bmi
... double lbsInKg 2.2 double
cmsInInch 2.54 double calculateBMI()
return (weight/lbsInKg) /
(heightcmsInInch/100heightcmsInInch/100)
58Accidental or Malicious Modification
Violating least privilege
public class AnotherBMISpreadsheet implements
BMISpreadsheet double height, weight, bmi
... double lbsInKg 2.2 double
cmsInInch 2.54 double calculateBMI()
lbsInKg 22 return
(weight/lbsInKg) /
(heightcmsInInch/100heightcmsInInch/100)
59Literals vs. Named Constants vs. Variables
- Use constants for program values that do not
change - Use named constants for magic numbers
60More Code Repetition
public class AnotherBMISpreadsheet implements
BMISpreadsheet double height, weight, bmi
... final double LBS_IN_KG 2.2
final double CMS_IN_INCH 2.54 double
calculateBMI() return
(weight/LBS_IN_KG) /
(heightCMS_IN_INCH/100heightCMS_IN_INCH/100)
Within same method and has the same value
61Removing Code Repetition (Edit)
public class AnotherBMISpreadsheet implements
BMISpreadsheet double height, weight, bmi
... final double LBS_IN_KG 2.2
final double CMS_IN_INCH 2.54 double
calculateBMI() double heightInMeters
heightCMS_IN_INCH/100 return
(weight/LBS_IN_KG) /
(heightInMetersheightInMeters)
62Removing Code Repetition
public class AnotherBMISpreadsheet implements
BMISpreadsheet double height, weight, bmi
... final double LBS_IN_KG 2.2
final double CMS_IN_INCH 2.54 double
calculateBMI() double heightInMeters
heightCMS_IN_INCH/100 return
(weight/LBS_IN_KG) /
(heightInMetersheightInMeters)
63Local vs. Global Variable
public class AnotherBMISpreadsheet implements
BMISpreadsheet double height, weight, bmi
double heightInMeters heightCMS_IN_INCH/100
... final double LBS_IN_KG 2.2
final double CMS_IN_INCH 2.54 double
calculateBMI() return
(weight/LBS_IN_KG) /
(heightInMetersheightInMeters)
64Local vs. Global Variable
public class AnotherBMISpreadsheet implements
BMISpreadsheet double height, weight, bmi
double heightInMeters heightCMS_IN_INCH/100
... final double LBS_IN_KG 2.2
final double CMS_IN_INCH 2.54 public
void setHeight(double newHeight)
heightInMeters newHeight bmi
calculateBMI() double
calculateBMI() return
(weight/LBS_IN_KG) /
(heightInMetersheightInMeters)
Violating least privilege
65scope
height scope
public class AnotherBMISpreadsheet implements
BMISpreadsheet double height, weight, bmi
public void setHeight(double newHeight)
height newHeight bmi
calculateBMI() public double
getWeight() return weight
public void setWeight(double newWeight)
weight newWeight bmi
weight/(heightheight) double
calculateBMI () double heightInMetres
heightCMS_IN_INCH/100 return
(weight/LBS_IN_KG) / (heightInMetresheightInMetre
s)
Not a scope
heightInMeters scope
66Scope of Public Items
getWeight() scope
public class AnotherBMISpreadsheet implements
BMISpreadsheet double height, weight, bmi
public double getWeight()
return weight
ObjectEditor
ABMISpreadsheet
67Identifier Scope
- Region of code where the identifier is visible
- Arbitrary scopes not possible
- Least Privilege Make scope as small as possible
68Scope
public class AnotherBMISpreadsheet implements
BMISpreadsheet double height, weight, bmi
public void setHeight(double newHeight)
height newHeight bmi
calculateBMI() public double
getWeight() return weight
public void setWeight(double newWeight)
weight newWeight bmi
weight/(heightheight) double
calculateBMI() () double heightInMetres
heightCMS_IN_INCH/100 return
(weight/LBS_IN_KG) / (heightInMetresheightInMetre
s)
heightInMeters scope
69Initializing Declaration
public class AnotherBMISpreadsheet implements
BMISpreadsheet double height, weight, bmi
final double LBS_IN_KG 2.2 final
double CMS_IN_INCH 2.54 double
calculateBMI() () double heightInMetres
heightCMS_IN_INCH/100 return
(weight/LBS_IN_KG) / (heightInMetresheightInMetre
s)
70Un-initializing Declaration
public class AnotherBMISpreadsheet implements
BMISpreadsheet double height, weight, bmi
final double LBS_IN_KG 2.2 final
double CMS_IN_INCH 2.54 double
calculateBMI() () double
heightInMetres heightInMeters
heightCMS_IN_INCH/100 return
(weight/LBS_IN_KG) / (heightInMetresheightInMetre
s)
71Un-initialized Variable
public class AnotherBMISpreadsheet implements
BMISpreadsheet double height, weight, bmi
final double LBS_IN_KG 2.2 final
double CMS_IN_INCH 2.54 double
calculateBMI() () double
heightInMetres return (weight/LBS_IN_KG)
/ (heightInMetresheightInMetres)
72Initializing All Variables
public class AnotherBMISpreadsheet implements
BMISpreadsheet double height, weight, bmi
final double LBS_IN_KG 2.2 final
double CMS_IN_INCH 2.54 double
calculateBMI() () double
heightInMetres return (weight/LBS_IN_KG)
/ (heightInMetresheightInMetres)
73Initializing All Variables (Edit)
public class AnotherBMISpreadsheet implements
BMISpreadsheet double height 60, weight
70, bmi getBMI() final double
LBS_IN_KG 2.2 final double CMS_IN_INCH
2.54 double calculateBMI() ()
double heightInMetres heightCMS_IN_INCH/100
return (weight/LBS_IN_KG) /
(heightInMetresheightInMetres)
74Initializing All Variables
public class AnotherBMISpreadsheet implements
BMISpreadsheet double height 70, weight
160, bmi calculateBMI() final double
LBS_IN_KG 2.2 final double CMS_IN_INCH
2.54 double calculateBMI() ()
double heightInMetres heightCMS_IN_INCH/100
return (weight/LBS_IN_KG) /
(heightInMetresheightInMetres)
75Printing Properties
public class ABMISpreadsheet implements
BMISpreadsheet double height public
double getHeight() return height
public void setHeight(double newHeight)
height newHeight double
weight public double getWeight()
return weight public void
setWeight(double newWeight) weight
newWeight public double getBMI()
return weight/(heightheight)
76Printing Properties (Edit)
public class ABMISpreadsheet implements
BMISpreadsheet double height
public void setHeight(double newHeight)
System.out.println(Height newHeight)
height newHeight double weight
public void setWeight(double newWeight)
weight newWeight public
double getBMI() return
weight/(heightheight)
77Printing Properties
public class ABMISpreadsheet implements
BMISpreadsheet double height
public void setHeight(double newHeight)
System.out.println(Weight weight)
System.out.println(Height height)
double bmi getBMI() System.out.println(
BMI bmi) height newHeight
double weight public void
setWeight(double newWeight) weight
newWeight public double getBMI()
return weight/(heightheight)
78Less Cluttered Code (Edit)
public class ABMISpreadsheet implements
BMISpreadsheet double height
public void setHeight(double newHeight)
System.out.println(Weight weight)
System.out.println(Height height)
double bmi getBMI() System.out.println(
BMI bmi) height newHeight
double weight public void
setWeight(double newWeight) weight
newWeight public double getBMI()
return weight/(heightheight)
79Less Cluttered Code
public class ABMISpreadsheet implements
BMISpreadsheet double height
public void setHeight(double newHeight)
System.out.println(Weight weight)
System.out.println(Height height)
System.out.println(BMI getBMI())
height newHeight double weight
public void setWeight(double newWeight)
weight newWeight public double
getBMI() return weight/(heightheight)
80Removing Duplication
public class ABMISpreadsheet implements
BMISpreadsheet double height
public void setHeight(double newHeight)
System.out.println(Weight weight)
System.out.println(Height height)
System.out.println(BMI getBMI())
height newHeight double weight
public void setWeight(double newWeight)
System.out.println(Weight weight)
System.out.println(Height height)
System.out.println(BMI getBMI())
weight newWeight public double
getBMI() return weight/(heightheight)
81Removing Duplication (Edit)
public class ABMISpreadsheet implements
BMISpreadsheet double height
public void setHeight(double newHeight)
printProperties() height newHeight
double weight public void
setWeight(double newWeight)
printProperties() weight newWeight
public double getBMI() return
weight/(heightheight) void
printProperties() System.out.println(W
eight weight) System.out.println(He
ight height) System.out.println(BMI
getBMI())
82Removing Duplication
public class ABMISpreadsheet implements
BMISpreadsheet double height
public void setHeight(double newHeight)
printProperties() height newHeight
double weight public void
setWeight(double newWeight)
printProperties() weight newWeight
void printProperties()
System.out.println(Weight weight)
System.out.println(Height height)
System.out.println(BMI getBMI())
83Separation of Concerns
public class ABMISpreadsheet implements
BMISpreadsheet double height
public void setHeight(double newHeight)
printProperties() height newHeight
double weight public void
setWeight(double newWeight)
printProperties() weight newWeight
void printProperties()
System.out.println(Weight weight)
System.out.println(Height height)
System.out.println(BMI getBMI())
Less cluttered
84Independent Code Method
- Separate method for
- Any independent piece of code
- Even if it is not duplicated
- If it is more than one line
public void setWeight(double newWeight)
System.out.println(Weight weight)
weight newWeight
public void setWeight(double newWeight)
printWeight() weight newWeight
85Printing BMI in getBMI()
public class ABMISpreadsheet implements
BMISpreadsheet double height
public double getBMI()
printProperties() return
weight/(heightheight) void
printProperties() System.out.println(We
ight weight) System.out.println(Hei
ght height) System.out.println(BMI
getBMI())
getBMI() never terminates
Recursive, calls itself indirectly
Infinite recursion
Avoid recursion for now
86Non-public Instance Variables
public class ABMISpreadsheet implements
BMISpreadsheet double height, weight, bmi
87Making Instance Variables Public
public class ABMISpreadsheet implements
BMISpreadsheet public double height,
weight, bmi
Other classes
88Hard to Change
public class ABMISpreadsheet implements
BMISpreadsheet public double height,
weight
Other classes
89Consistency Constraints Violated
Inconsistent values
90Preconditions Cannot be Enforced
More on this later
91Encapsulation Principle
- Do not make instance variables public
- Expose them through public methods
92Public Constants
Inconsistent value cannot be stored
public final double CMS_IN_INCH 2.54
public interface BMISpreadsheet public
final double CMS_IN_INCH 2.54
Implementation independent
ABMISpreadsheet
AnotherBMISpreadsheet
93Principle
- Declare implementation-independent named
constants in interfaces - implementing classes can access them
94(No Transcript)
95Extra Slides
96Stepwise Refinement
Natural Language
- Declare two instance variables
- weight and height
- Define a getter method that computes the value of
BMI and returns it
Programming Language
public double getBMI() return
weight/(heightheight)
97Real-World Analogy
implements
manufactures
Corvette Specification
implements
manufactures