Unit 5: Writing Classes

Unit 5: Writing Classes

This unit will pull together information from all previous units to create new, user-defined reference data types in the form of classes. The ability to accurately model real-world entities in a computer program is a large part of what makes computer science so powerful. This unit focuses on identifying appropriate behaviors and attributes of real-world entities and organizing these into classes. Students will build on what they learn in this unit to represent relationships between classes through hierarchies, which appear in Unit 9. The creation of computer programs can have extensive impacts on societies, economies, and cultures. The legal and ethical concerns that come with programs and the responsibilities of programmers are also addressed in this unit.


ESSENTIAL QUESTIONS

Modularity [MOD]

How can using a model of traffic patterns improve travel time?

Variables [VAR]

How can programs be written to protect your bank account balance from being inadvertently changed?

Impact of Computing [IOC]

What responsibility do programmers have for the consequences of programs they create, whether intentional or not?


BIG IDEAS

+ The makeup of a class, including whether attributes are public or private

+ Setting an object’s attributes using constructors

+ Using comments to describe the functionality of code

+ Defining behaviors of an object using non-void, void, and static methods

+ Where variables can be used in program code

+ Breaking problems into smaller parts by creating methods to solve individual subproblems

+ Intellectual property and ethical concerns in programming


UNIT TOPICS & ACTIVITIES

5.1: Anatomy of a Class

Lab: The BIG Three

5.2: Constructors

Lab: Constructor Construction

5.3: Documentation with Comments

Lab: Reasons for Readability

5.4: Accessor Methods

Lab: Dynamic Duo - Part 1

5.5: Mutator Methods

5.6: Writing Methods

5.7: static Variables and Methods


Link to Brainscapes

SKILLS ADDRESSED


Program Design and Algorithm Development

1.A: Determine an appropriate program design to solve a problem or accomplish a task (not assessed).

1.B: Determine code that would be used to complete code segments.

1.C: Determine code that would be used to interact with completed program code.

Code Implementation

3.B: Write program code to define a new type by creating a class.

Code Testing

4.B: Identify errors in program code.

Documentation

5.A: Describe the behavior of a given segment of program code

5.B: Explain why a code segment will not compile or work as intended.

5.D: Describe the initial conditions that must be met for a program segment to work as intended or described.