Lecture2DesigningClasses

Lecture2DesigningClasses - Designing Classes Nouns and...

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

View Full Document Right Arrow Icon
Designing Classes
Background image of page 1

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

View Full DocumentRight Arrow Icon
Nouns and Verbs Read the description of the problem to be solved and identify nouns and verbs Consider classes that correspond to nouns Consider methods for the classes that correspond to the verbs
Background image of page 2
Designing and Implementing a Class Identify what an object of the class is supposed to do Find names for methods Document the public interface Determine instance variables Determine constructors Implement and Test
Background image of page 3

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

View Full DocumentRight Arrow Icon
Good Design
Background image of page 4
Cohesion and Coupling The public interface of a class is cohesive if all of its features are related to the concept that the class represents.
Background image of page 5

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

View Full DocumentRight Arrow Icon
Cohesion A class should represent a single concept
Background image of page 6
Coupling A class depends on another class if it uses objects of that other class. This demonstrates the concept of coupling.
Background image of page 7

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

View Full DocumentRight Arrow Icon
Rules 1 and 2 Rule 1: A class should represent a single concept from the problem domain such as business, science, or mathematics Rule 2: It is good practice to minimize the coupling (i.e. the dependency) between classes.
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/13/2008 for the course CSC 216 taught by Professor Miller during the Spring '08 term at N.C. State.

Page1 / 18

Lecture2DesigningClasses - Designing Classes Nouns and...

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

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