TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: ALL
from: BENJAMIN L MCGEE
date: 1997-08-13 21:14:00
subject: replies here -[]

I'd like the opinion of the folks in this echo concerning the 
following statement from the book "Black Belt C++..." 
 
`` 
C programmers are faced with two temptations in writing 
constructors: 
 
     o    The temptation to ascribe too much responsibility to 
          the constructor.  The constructor's responsibility is 
          to "make an object out of a bunch of raw bits."  Just 
          that, and no more.  A constructor that has sweeping 
          side effects is normally poor programming practice 
          because constructors can be called by the compiler 
          when you least expect it.  This can introduce exposure 
          to buggy behavior or inefficiency. 
 
     o    The temptation to write a constructor to create an 
          object of a user defined type from just about any 
          other type imaginable.  Conversion by construction is 
          not bad, but it is important to define what sort of 
          conversions make sense up front. 
'' 
 
How would you define "ascribing to much responsibility to the 
constructor?"  Is this to much... 
 
 
manifest::manifest(){ 
     filename = new char[FILENAME_MAX]; 
     while (!select(filename, FILENAME_MAX - 1)); 
     mstreamp = new ifstream(filename); 
} 
 
 
*What color is a chameleon on a mirror? 
 
e-mail:  benjamin.l.mcgee@purgatoire.org 
NET-MAIL: Benjamin L McGee on 1:15/7
--- FLAME v1.1
---------------
* Origin: Purgatoire BBS, 719-846-0140, Trinidad, CO, V.34 (1:15/7)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.