Presentation is loading. Please wait.

Presentation is loading. Please wait.

Dependency Analysis Use Cases

Similar presentations


Presentation on theme: "Dependency Analysis Use Cases"— Presentation transcript:

1 Dependency Analysis Use Cases
Jim Fawcett CSE681 – SW Modeling & Analysis Fall 2002

2 Background This presentation is concerned with dependencies between a program’s modules. A module is a relatively small partition of a program’s source code into a cohesive part. A typical module should consist of about 400 source lines of code (SLOC). Obviously some will be smaller, some larger, but this is a good target size Typical project sizes are: Modest size research project – 10,000 sloc  25 modules Modest size commercial product – 500 kslocs  1,250 modules

3 So, What is a Module? Microsoft, in .Net literature, defines a module as an Exe or DLL file, composed of metadata (type and other info) and IL (.Net intermediate language). An assembly is an Exe file and all the DLL files it loads to form an execution image. That is, an assembly is a collection of modules.

4 So, What is a Module – again!
We mean something entirely different! A module is a logical partition of source code into a relatively small, cohesive part. It should contain: Comments that describe its purpose and history A public interface and private implementation A test stub with compilation directives that allow it to be selected for compilation or deselected. We will discuss C# and C++ module examples tonight.

5 Dependency Analysis Uses
Test Plans It is essential to start testing those modules that have no dependencies other than on library code and working reused code. After those are tested we want to test just those depending on already tested code. For this use we want to know what other files a specific file depends on.

6 Dependency Analysis Uses
Maintenance After a project is released to its customers it will be subjected to many maintenance changes. Fix latent errors Add new capabilities For this activity it is important to know what files depend on a specific file. What may break if I make this change? NOTE: this is the inverse relationship of the test case use.

7 Dependency Analysis Uses
Documentation It is often easiest to understand a complex project if we study the top level modules, then study each of the modules it depends on, and so forth. This implies a need for the same type of dependency information as on the previous slide.

8 Dependency Information – C++
In C++ source code: All dependency information is encoded in #include statements. #include <someSystemFile> #include “someProjectFile” It is easy to find files that this file depends on. Just make a list of all the included files. This finds dependencies in documentation order

9 Dependency Information – C#
Dependency information is not directly encoded in C# source code. Dependencies are established by references. In IDE, right-click references in solution explorer and choose add reference references.doc From command line add /r<filelist> switch, e.g., csc /r myLib.dll mySource.cs This information is encoded in the assembly’s metadata. Note that no information about the original source code is used or stored in the assembly metadata.

10 Extracting Dependencies from C# Source
Given a set of source files to search and a specific file: Find all the class and struct declarations in the file, saving their names. Find all the files in the set that use those class and struct names. This finds all the files that depend on this file (Test Plan order).

11 Extracting Dependencies from Project
The project file, e.g., myProj.csproj.txt, is an XML file that encodes, among other things, the source files that this file depends on. We could extract the required dependency information by a simple parsing of this file. This method has the drawback that the project may have been compiled from the command line without a project file. Also, in a typical project workspace there may be several projects. Which project file do we choose to analyze?

12 Display There are two types of dependency orders we have discussed:
Test Plan order – C++ include analysis: Files that this file depends on. Documentation order – C# type analysis: Files that depend on this file. Our Dependency program should be able to display dependencies in either order. Remember that we need to display both direct and indirect source code dependencies.

13 Dependencies dependencies.vsd Pr2CRCs.vsd


Download ppt "Dependency Analysis Use Cases"

Similar presentations


Ads by Google