Changes between Initial Version and Version 1 of RefactoringSteps/MoveRecord


Ignore:
Timestamp:
Feb 17, 2012, 10:28:53 PM (13 years ago)
Author:
manualwiki
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • RefactoringSteps/MoveRecord

    v1 v1  
     1= Move record = 
     2 
     3This transformation moves record definitions between two files. Source and target files can be either modules or header files, the conditions are slightly different in every case. The goal of the transformation is to make the moved record definitions available in every place where they are used. 
     4 
     5Move record example: 
     6 
     7{{{ 
     8%%client.hrl 
     9 
     10-record(conn, {ip, port=80}). 
     11-record(msg, {sender, text}). 
     12}}} 
     13 
     14{{{ 
     15%%messages.hrl 
     16 
     17-record(dmsg, {date, text}). 
     18}}} 
     19 
     20{{{ 
     21%%client.erl 
     22 
     23-include("client.hrl"). 
     24 
     25sendmessage(Msg) -> 
     26   ?SERVER ! #msg{text=Msg}. 
     27}}} 
     28 
     29Result: 
     30 
     31{{{ 
     32%%client.hrl 
     33 
     34-record(conn, {ip, port=80}). 
     35}}} 
     36 
     37{{{ 
     38%%messages.hrl 
     39 
     40-record(dmsg, {date, text}). 
     41-record(msg, {sender, text}). 
     42}}} 
     43 
     44{{{ 
     45%%client.erl 
     46 
     47-include("client.hrl"). 
     48-include("messages.hrl"). 
     49 
     50sendmessage(Msg) -> 
     51   ?SERVER ! #msg{text=Msg}. 
     52 
     53}}} 
     54 
     55== Side conditions == 
     56 
     57 * The names of the records to be moved do not clash with existing record names 
     58  * in the target file, 
     59  * in files that are included in target and 
     60  * in files where the target file is included. 
     61 
     62 * If the user does not specify the records to be moved, the transformation starts an interaction to ask the user to specify records. The user has to select the records to be moved from a checkbox list. 
     63 
     64 * Moving records from a header file to a module file is only permitted if no other modules include the header file and use some of the records to be moved. 
     65 
     66 * If a file inclusion has to be introduced during the transformation, this inclusion must not cause inconsistency at the place of the inclusion. 
     67 
     68 
     69== Transformation steps and compensations == 
     70 
     71 1. The record definitions are removed from the source file. 
     72 
     73 2. If the target is a header file that does not exist, the file is created. 
     74 
     75 3. The record definitions are placed at the end of the target header file, or before the first function of the target module file. 
     76 
     77 4. If a record is moved into a header file, then every module that uses the record is changed to include the target header file. This is not an issue when the target is a module file.