2 Options for software
Change (continuously maintained) or die (thrown away)
Important concepts for accessing the quality of code
coupling and cohesion
coupling
cohesion
-The # and diversity of tasks that a single unit is responsible for
- high cohesion: each unit is responsible for one single logical task
- aim for high
- unit applies to classes, methods and modules (packages)
code duplication Issues
loose coupling
tight coupling
Responsibility Driven Design
Localizing Change
Implicit coupling
Thinking ahead
cohesion applied at different levels
Class level: classes should represent the single, well defined entity
Method level: A method should be responsible for one and only one well defined task
High cohesion
Refactoring
Refactoring & testing
What does an enumerated type definition consist of
-outer wrapper: uses the word “enum” instead of “class”
-body: a list of variable names denoting the set of values that belong to this type. they are always fully capitalized
- can have fields, constructors & methods
public enum CommandWord
{
// A value for each command word, plus one for unrecognized
// commands.
GO, QUIT, HELP, UNKNOWN
}
Enumerated variable names
enumerated types
-