lecture14

lecture14 - PIC 20A Lecture 14 Class Design Interfaces...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: PIC 20A Lecture 14: Class Design, Interfaces Class Design Guidelines 1. Be sure your class models a single well- defined concept. (Define a class BruinTester instead of defining main in class Bruin.) 2. Stick to the principle of least privilege (Only define non- private accessor and mutator methods if needed. Be stingy with member access.) Class Design Guidelines 3. Only define public members that fit well with the single concept your class models. This makes your class cohesive . 4. Avoid redundant member fields. (eg Having _hits, _atBat, and _avg fields when you can calculate _avg from _hits and _atBats) 5. Use standard Java classes and techniques whenever possible. Avoid hacks . Class Design Guidelines 6. Define constants instead of hard-coding literals in your code. 7. Define private helper methods to keep your method definitions short and to eliminate replicated code. "Don't repeat. Reuse." 8. Be sure to clearly state method preconditions (assumptions on parameter values) and postconditions (what the method does if preconditions are met) in the user documentation. Program Design Guidelines 9. Divide your program into modules (smaller reusable interchangeable classes or methods). 10. Eliminate unnecessary coupling (dependencies) among classes....
View Full Document

This note was uploaded on 04/12/2010 for the course PIC PIC 20A taught by Professor Keithouellette during the Spring '09 term at UCLA.

Page1 / 22

lecture14 - PIC 20A Lecture 14 Class Design Interfaces...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online