home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / diverses / text_cla / c_2_cpp.txt < prev    next >
Encoding:
Text File  |  1992-05-12  |  4.2 KB  |  123 lines

  1.  
  2.  
  3.          General Steps in Converting C application to C++ 
  4.  
  5.                    John Tal - Feb 12, 1992 
  6.  
  7.  
  8.  
  9.         1.  Create Class Defintion 
  10.  
  11.         1.1  Identify Private And Protected Members 
  12.  
  13.         Identify all variables which are passed through functions 
  14.         but are really private to the class.  These include: 
  15.  
  16.                 o  Work Areas 
  17.                 o  Head Pointers 
  18.                 o  Counters 
  19.  
  20.         Place these in the private or protected class sections. 
  21.  
  22.          
  23.         1.2  Install Public Access To Private Members 
  24.  
  25.         Identify all private or protected class member variables 
  26.         which interact with the application.  All reading or writing 
  27.         of non-public members should be accomplished by a public 
  28.         class member function.  There should be NO access to non-public 
  29.         members by the application. 
  30.  
  31.         1.3  Identify Non-Public Functions 
  32.  
  33.         All functions which are not directly called by the application 
  34.         should be private or protected. 
  35.  
  36.         1.4  Modify Class Function Prototypes 
  37.  
  38.         Remove from all functions parameters which are now embodied 
  39.         by class member data.  This includes the same items as 
  40.         in 1.1. 
  41.  
  42.         1.5  Create Class Constructor And Descructor 
  43.  
  44.         These can be VOID and NULL functions are whatever is required 
  45.         by the class.  All allocated memory should be freed in the 
  46.         destructor. 
  47.  
  48.         1.6  Determine Class Access Within Heirachies 
  49.  
  50.         There will be elementary classes which you will use to build 
  51.         more sophisticated classes through different methods.  Each 
  52.         method will influence the security and general object access 
  53.         to be defined.  It can also be helpful to distinguish between 
  54.         what a class contains and what it does in refining class 
  55.         interfaces. 
  56.  
  57.         1.6.1  Simple Inclusion 
  58.  
  59.         In this case a class is constructed with other classes as 
  60.         members. 
  61.  
  62.         1.6.2  Derived Classes 
  63.  
  64.         This includes the areas of multiple-inheritance and polymorphism. 
  65.         The derived class will inherit the class attributes of its 
  66.         parent class(es). 
  67.  
  68.         1.6.3  Deferentiated Access 
  69.  
  70.         You may discover a situation where you want the application to 
  71.         be unable to access certain class areas but you want another 
  72.         class to be able to access all class areas.  One solution is 
  73.         to use a friend modifier (NOT RECOMMENDED, the friend modifier 
  74.         breaks many object-oriented rules).  The best solution may be 
  75.         to create a server class which will then access others classes 
  76.         for the application. 
  77.  
  78.  
  79.         2   Modify C Source Code 
  80.  
  81.         2.1  Rename Or Copy Code 
  82.  
  83.         Rename or copy the c source files from *.c to whichever 
  84.         extension is used by your C++ compiler (usually *.cpp). 
  85.  
  86.         2.2  Modify Code Comments 
  87.  
  88.         Comments in the source code can be left in the /* style, 
  89.         but for those who work in both C and C++, having native 
  90.         C++ comments in // style makes it easier to switch  
  91.         between languages. 
  92.  
  93.         2.3  Modify Functions 
  94.  
  95.         2.3.1  Modify Function Interface  
  96.  
  97.         Modify function interfaces to no longer pass items such as 
  98.         in 1.1.   
  99.  
  100.         2.3.2  Modify Function Comment Header Block 
  101.  
  102.         Modify comment header block to include security of class 
  103.         member (private, protected, public).  Carefully examine 
  104.         any function who's description includes the words 'and' 
  105.         or 'or'.  These are signs of cohesion problems. 
  106.         (If a function calculates data AND writes it to disk, 
  107.         the function should be broken up into two functions, 
  108.         one to calculate and one to write.) 
  109.  
  110.         2.3.3  Break Up Functions 
  111.  
  112.         Create new functions from those displaying cohesion or 
  113.         coupling problems which can be corrected. 
  114.  
  115.         2.3.4  Create Interface Functions For Class Private Data 
  116.  
  117.         Create functions necessary for an application to read or  
  118.         write (get/set) data which is in private or public  
  119.         class security segments. 
  120.          
  121.  
  122.  
  123.