Presentation is loading. Please wait.

Presentation is loading. Please wait.

Source Code Inspection and Software Reuse

Similar presentations


Presentation on theme: "Source Code Inspection and Software Reuse"— Presentation transcript:

1 Source Code Inspection and Software Reuse
Chapter 7 – Digging into source code Coder To Developer - Mike Gunderloy Respected Professor: Dr. James Fawcett Presented By: Ghanashyam N

2 Digging Into Source Code
Looking more deeply at available code can clarify several details that are not immediately evident regarding this code’s functioning Code inspection helps us use existing code efficiently Seeing how someone else solved a particular problem can be very helpful in producing more elegant and efficient code

3 .NET Fundamentals All .NET code is executed by the CLR
Each of the .NET language compilers (C#, VB .NET, Managed C++ etc.) convert source code into MSIL (and Metadata) CLR understands only MSIL code and knows nothing about the .NET language that was used to generate this MSIL code

4 .NET Code Is Open There are several utilities (Ildasm, .NET Reflector etc.) that allow you to work on MSIL code directly Thus it is possible to find out quite a bit about .NET code for a library or an application even if its source code is not available

5 .NET Code Is Open All the code for .NET FCL is present in the form of MSIL (and Metadata) on any machine that has .NET installed Thus it is possible to look more closely at the implementation of the .NET FCL Looking at code for the .NET FCL can prove extremely useful especially when the documentation for a certain FCL class or method is obscure

6 Using Ildasm The .NET Framework SDK comes with a tool named Ildasm that allows you to work directly with MSIL code It displays MSIL code in a somewhat human readable format Ildasm’s output cannot be easily deciphered even though it is much more readable than MSIL itself

7 Using Ildasm Ildasm Start Menu ► Programs ► Microsoft Visual Studio .NET 2003 ► Visual Studio .NET Tools ► Visual Studio .NET 2003 Command Prompt Type ‘ildasm’ on command prompt and press enter

8

9

10

11 Using .NET Reflector .NET Reflector is available at
It is much easier to use than Ildasm since it displays the source code that was used to generate a supplied .NET assembly It also has many useful features like decompilation to either C# or VB .NET and display of call trees for any selected method

12

13

14

15

16

17

18 Reflection | Obfuscation
MSIL, Metadata and Reflection make it possible to do a deep analysis of any .NET application or library, even without source code Obfuscation aims at protecting intellectual property by taking source code and automatically changing it to make it difficult to understand Obfuscators typically change class names, member names etc. in the source code to make it very difficult to decipher the assembly generated using this code

19 Some Obfuscators Demanor for .NET Salamander Dotfuscator Species .NET
Salamander Dotfuscator Species .NET

20 Experimenting With Code
There are times when you need to actually run the code to gain a complete understanding of its functioning But writing a complete VS .NET solution to test the behavior of a simple component is a lot of work

21 Experimenting With Code
Snippet Compiler An IDE that allows you to write code to exercise some small piece of code with minimal overhead Supports C# and VB .NET Supports Winforms and ASP .NET Modest set of features Gets code up and running quickly

22

23 Software Reuse Try to avoid “reinventing the wheel”
Try and find code that you don’t have to write There is an astonishing amount of free, high-quality, reusable code out there

24 Software Reuse Make full use of the .NET FCL
Code for most of the common programming tasks already exists in the FCL Hashtables, queues etc. – System.Collections Event log, performance counters – System.Diagnostics WMI – System.Management XML – System.XML Sending SMTP mail – System.Web.Mail Reqular Expressions – System.Text.RegularExpressions

25 Software Reuse Some Libraries SQLXML Library
Add-on XML functionality for Microsoft SQL Server 2003 WSE (Web Services Enhancements) Set of implementations of web services specifications such as WS-Security, WS-Routing, WS-Referral etc.

26 Software Reuse Some Libraries Logidex .NET Library
Add-in to VS .NET that lets you locate and download .NET patterns and sample code from within Visual Studio .NET

27 Software Reuse More sources of free code The Code Project
GotDotNet User Samples

28 Evaluating Code Using FxCop http://www.gotdotnet.com/team/fxcop
A code analysis tool that checks .NET managed code assemblies for conformance to the Microsoft .NET Framework Design Guidelines Can check conformance for third party libraries as well as own classes

29

30 Thank You


Download ppt "Source Code Inspection and Software Reuse"

Similar presentations


Ads by Google