Effective C++ Ed. 3rd: Item 19. Treat Class Design As Type Design

What all you must consider to provide in a class you write? Check the following:
  1. Constructors and Destructor as well as memory allocation and deallocation fuctions.
  2. Object Initialization vs. Object Assignment.
  3. Copy constructor to pass objects by value.
  4. Error checking for object values outside legal range allowed, specially in constructors, assignment operators and "setter" functions.
  5. Declare virtual functions and virtual destructor depending upon: if you want to allow others to inherit this class.
  6. Type Conversion functions and constructors.
  7. Provide required functionality by defining functions and Overloaded operators.
  8. Disallow suitable standard funtions. (COPY CTOR etc.)
  9. Use access specifiers depending upon who will be allowed to access particular members.
  10. What kind of guarantee does the class provide in terms of exception safety, resource usage?
  11. Make your class generic using class template if  required.
  12. Is this class is what you need? Can't this be achieved through a function?
prev | next
Hope this helps
Cheers and try hosting at Linode.
Monish

No comments:

Post a Comment