Changes between Initial Version and Version 1 of Dependency/FunctionBlocks


Ignore:
Timestamp:
Mar 20, 2012, 8:36:01 AM (13 years ago)
Author:
manualwiki
Comment:

dep.fb page added

Legend:

Unmodified
Added
Removed
Modified
  • Dependency/FunctionBlocks

    v1 v1  
     1== Function block dependencies == 
     2 
     3=== About function blocks === 
     4In large systems, sets of applications (which themselves consist of several modules) are organised into bigger units; keeping in line with 
     5Ericsson terminology, we shall call these '''function blocks'''.  We also seek dependencies between them, which is conceptually similar to 
     6dependencies between modules: a function block ''FB1'' is dependent on a function block ''FB2'' if a module from ''FB1'' is dependent on one from ''FB2''. \\ 
     7 
     8In the following, we shall presume that all function blocks reside in directory trees, and that all modules contained in the tree are loaded 
     9into the database. \\ 
     10 
     11If we want to sum up what function blocks are, it should be said that they are groups of modules, in which every function block on its own 
     12attains a certain functionality. However, there can be several concepts how exact function blocks can be distinguished. Three ways will be presented. \\ 
     13 
     141. Considering ''every directory'' as a function block is not a far to seek option. The exact ''absolute paths'' of every module manages them into unambiguous units, and between these units module relationships give the basis of the dependency analysis. \\ 
     152. Continuing the absolute path logic, one may come to the point when these absolute paths need to be generalised, or following some kind of structure or concept. The tool provides interface for this request as well, since it is possible to define function blocks by the means of ''regular expressions''. In this way, for example every module in the {{{.*/src/}}} directories can be considered as one block, and connections outside of this function block (for instance, relationship investigation with {{{.*/ebin/}}} directories) can be determined. The default definition of function blocks comes from the ''NetSim'' team which is defined as a regular expression. The default rule can be overridden by redefining the regular expression (exact regexp is given in the TODO reference to ''Defining function blocks with regular expressions'' paragraph). \\ 
     163. To define a function block is to ''list its contents''. The user can define his own function blocks in 3 ways, with defining the exact modules (eg.: {{{module1, module2, module3}}}, placed in three different directories, can a function block), giving the absolute directory path with/without regular expressions (to give it further thought, the exact absolute path is also a regular expression) and giving structure of the names and absolute paths of Erlang source files with regular expressions (example in TODO refernce {{{User defined function blocks}}}} paragraph). 
     17 
     18 
     19== Using function block analysis in {{{ri}}} == 
     20The function {{{ri:fb_relations/1}}} is used for the function block dependency analysis. The argument, which is again a proplist of this function determines the exact examination type. \\ 
     21The Options are the following: 
     22* {{{{command, Command}}}} \\ 
     23  {{{Command = get_rel | is_rel | check_cycle | draw | draw_cycle}}} 
     24  * {{{get_rel}}}  
     25    Displays the relationship between the given function block list. The result is a tuplelist where a tuple represents a relation. 
     26  * {{{is_rel}}} 
     27    Decides whether there is a connection between the two given function blocks. 
     28  * {{{check_cycle}}} 
     29    Checks for cycles in the dependencies between the given function block list. Unless list is given, checks among every function block list. 
     30  * {{{draw}}}  
     31    Prints out the entire graph or creates a subgraph drawing from the given function block list. Output file is {{{fb_relations.dot}}}. 
     32  * {{{draw_cycle}}}  
     33    Prints out a subgraph which contains the cycle(s). Unless cycles exist, prints out the entire graph. Output file is {{{fb_rel_cycles.dot}}}. 
     34* {{{{fb_list, List}}}}, {{{List = [string()] |}}} {{{[{Basename::string(), [Function block::atom()]}]}}} 
     35    Chosen function block lists for further examinations. If no list 
     36    given, then it takes every function block list, which means that 
     37    every absolute path defines a function block. 
     38 
     39* {{{{other, Other}}}} {{{ Other = bool()}}} 
     40     The {{{Other}}} parameter stands whether the category "Other" would be taken into consideration or not ({{{true/false}}}). The default value is true. 
     41 
     42=== Examples === 
     43 
     44* {{{ri:fb_relations([{command, check_cycle}]).}}} 
     45* {{{ri:fb_relations([{command, draw_cycle}]).}}} 
     46* {{{ri:fb_relations([{command, is_rel}, {fb_list,["path_to_dir/subdir", "path_to_dir/subdir/subsubdir"]}]).}}} 
     47* {{{ri:fb_relations([{command, is_rel}, {fb_list,{"path_to_dir", [1, 2]}}]). }}} 
     48 
     49=== Optional ''Other'' category === 
     50Let's think about function blocks in the sense that every directory with its absolute path gives a different function block.  The Other category is a special collector name for those modules which cannot be divided into any function block. Practically this covers those modules which do not have directories (for example, usually erlang). This category can be taken into consideration as a false function block, so 
     51a new option was introduced for eliminating this category. With this the dependencies with ''Other'' category are skipped, the tool takes into consideration only the real connections. 
     52 
     53=== Representation of Function block Dependency Graphs === 
     54 
     55Naturally, it is possible to represent function block relationships with the previously used dot files. Using the {{{command}}} key in the ''Options'' proplist, the desired figure can be gained ({{{draw}}} or {{{draw_cycle}}}). It could be useful to make the standard output messages also available, because function blocks are represented with numbers. However, as a tooltip the proper function block name is provided. 
     56 
     57{{{ >> ri:fb_relations([{command, draw}]). }}} \\ 
     58{{{Earlier results deleted (except .dot files). }}} \\ 
     59{{{Building dependency table... }}} \\ 
     60{{{Creating "/home/RefactorErl/tools/new/tool/dep_files/fb_relations.dot" file... }}} \\ 
     61 
     62---------------------------------------------------------- \\ 
     63{{{Function block 1 is "/home/RefactorErl/test/cyclic/cycles" }}} \\ 
     64{{{Function block 2 is "/home/RefactorErl/test/regexp/common/serv1/ebin"}}} \\ 
     65{{{Function block 3 is "Other"}}} \\ 
     66{{{Function block 4 is "/home/RefactorErl/test/error"}}} \\ 
     67{{{Function block 5 is "/home/RefactorErl/test/cyclic/no_cycle"}}} \\ 
     68{{{Function block 6 is "/home/RefactorErl/test/opaque"}}} \\ 
     69{{{Function block 7 is "/home/RefactorErl/test/regexp/common/serv2/lib/ebin"}}} \\ 
     70------------------------------------------------------------\\ 
     71 
     72 
     73!!! TODO add figure !!! 
     74 
     75Explanation of figure: 
     76* Hexagon nodes (eg.: {{{cycle1, erlang, test2}}}) - representing  function blocks as number (colour: ''black'') 
     77* Dotted edge, normal arrowhead - indicates that a fb calls another fb (colour: ''black'') 
     78* Dotted edge, special arrowhead - cyclic edge (colour: ''red'') 
     79 
     80=== Using function block analysis from the web interface === 
     81The usage of function block analysis is described in !!! TODO add ref.!!! 
     82 
     83=== Defining function blocks with regular expressions === 
     84Function blocks can be filtered by the means of regular expressions. 
     85An interface function, called {{{ri:fb_regexp/1}} is provided and its parameters are the following: 
     86* {{{ {type, Type} }}} \\ 
     87  {{{ Type = list | get_rel | cycle | draw }}} 
     88  * {{{list}}} Prints out every function block which matches the 
     89    basic regular expression. 
     90  * {{{get_rel}}} Decides whether there is a connection between 
     91    the two given function blocks. 
     92  * {{{cycle}}} Checks for cycles in the dependencies between the 
     93    given function block list. 
     94  * {{{ draw }}} Prints out the entire graph or creates a subgraph 
     95    drawing from the given function block list.  Output file is 
     96    {{{fb_relations.dot}}} or can be user defined with the ''dot'' 
     97    key. 
     98 
     99* {{{ {regexp, Value} }}} \\ 
     100  {{{ Value = File::string() | [RegExp::string()] }}} 
     101   
     102  If this option (tuple) is not given, the program works with a basic 
     103  regular expression.  The basic rule: {{{<function block>/common/<service>/ebin}}} or 
     104  {{{<function block>/common/<service>/lib/ebin}}}. \\ 
     105  The regular expression saved for this: 
     106  {{{ (/)[0-9a-zA-Z_./]+/common/[0-9a-zA-Z_.]+/(lib/)?(ebin)$ }}} 
     107   
     108 
     109  * {{{ Value }}} - If the regular expression is given in a file 
     110    then every single regexp has to be defined in a separate line and 
     111    must follow the Perl syntax and semantics as the http://www.erlang.org/doc/man/re.html 
     112    erlang module resembles so. However, the user can give the regular expressions in a list 
     113    as well. If there is an error with a regular expression in the 
     114    file or in the list, it prints out the regexp, the error 
     115    specification, and the position. The most usual regexp is ".*" 
     116    (the Perl syntax does not allow simply "*", because this symbols 
     117    means possible unlimited repetition of characters declared before 
     118    it, and there are no characters declared before it) 
     119 
     120Examples: 
     121*  {{{ri:fb_regexp([{type, draw}, {dot, test.dot}]).}}} 
     122*  {{{ri:fb_regexp([{type, list}, {regexp, "regexp"}]).}}} 
     123*  {{{ri:fb_regexp([{type, list}, {regexp, "^/home/[a-z./]+}]).}}} 
     124 
     125 
     126=== User defined function blocks === 
     127One can make his own function block in the following three ways: 
     1281. Giving the exact modules (with their name) which should be in 
     129  one function block. 
     1302. Regular expressions covering the structure of the directories. 
     1313. By regular expressions covering the structure of the directories 
     132  and the structure of the name of the files. 
     133 
     134Example: 
     135{{{ refusr_fb_regexp:re([{type, list}, {fb, [[cycle1, cycle2],"/home/user/[a-zA-z]*", "/home/user/[a-zA-z./]*/.*_ui.erl"]}]). }}} 
     136 
     137 
     138'''Optimisations''' 
     139 
     140For efficiency and time improving reasons, the result of the queries 
     141are saved into {{{dets}}} tables for the further queries. 
     142 
     143 
     144The results of previous queries are saved into dets tables (in the {{{dep_files}}} directory).  This means that if 
     145the same query is run, the execution time may decreases significantly. 
     146At first run, a digraph is built as in the previous version, only it 
     147is saved later.If there was a whole database dependency check, than the tool works from that dets 
     148table instead of building a new subgraph, which also improves time 
     149efficiency. Due to this, it is strongly advised that if one knows that 
     150a lot of different node queries will be done, a whole check should be 
     151run in the first place.  
     152The saves are available until the 
     153database is unchanged. At the moment the hash value of the database is 
     154changed, the existing dets tables are deleted. The deletion does not 
     155effect the ''.dot'' files, although it is significant to remember 
     156to save them somewhere else from the ''dep_files'' directory, 
     157because the next call for draw function will overwrite the 
     158corresponding ''.dot'' file. This could be prevented by using the 
     159feature, that the user can define his own dot file name and absolute 
     160path.