CPSC 103 Lecture Notes - Lecture 8: Domain Knowledge
CPSC 103 verified notes
8/26View all
Document Summary
In general, you should create a helper function whenever part of a function you are designing seems to be a well-defined subtask. You should create a helper function for the subtask and call the new helper function from your original function. The below rules will help you determine when you need to write a helper function, but always remember the overarching rule of "one task per function": reference: use a helper function at references to other non-primitive data definitions. When you"re at the template step of designing a function and see that the template you"ve copied has a call to another type"s template function, this is a very strong hint that you"ll need to design a helper function. For example, you may be designing a function that takes a list[student]. In the list[student] template, there would be a call to student"s template function since student is a user-defined type.