CSC148H1 Lecture Notes - Lecture 2: Object-Oriented Programming, Docstring, Recommender System
katrinasavvy and 38715 others unlocked
1
CSC148H1 Full Course Notes
Verified Note
1 document
Document Summary
We have now introduced all three elements of a class: instance attributes (data) methods (operations) representation invariants (properties) I(cid:374) fa(cid:272)t, the(cid:396)e a(cid:396)e a (cid:449)hole host of su(cid:272)h (cid:395)uestio(cid:374)s (cid:449)hi(cid:272)h (cid:455)ou"ll fa(cid:272)e (cid:449)he(cid:374) desig(cid:374)i(cid:374)g o(cid:271)je(cid:272)t-oriented p(cid:396)og(cid:396)a(cid:373)s, i(cid:374)(cid:272)ludi(cid:374)g (cid:449)hat (cid:455)ou"ll (cid:271)e (cid:449)o(cid:396)ki(cid:374)g o(cid:374) fo(cid:396) assignment 1. To help guide you in this process, we have prepared a class design recipe, which serves an analogous role to the function design recipe from. This is a (cid:396)efe(cid:396)e(cid:374)(cid:272)e do(cid:272)u(cid:373)e(cid:374)t that (cid:455)ou a(cid:396)e(cid:374)"t (cid:396)e(cid:395)ui(cid:396)ed to follo(cid:449) e(cid:454)pli(cid:272)itl(cid:455), (cid:271)ut (cid:449)ill (cid:271)e a helpful way to guide your thinking when designing your own classes. The fundamental themes of the class design recipe are design before coding and information hiding. The relationship between the author and client of a class plays in class design is both powerful and subtle. When we design a class, we must think about how another person would use this class.