September 20, 2013

.net Interoperability

All good software design will go for high cohesion and low coupling.

Cohesion ensures that the implementation more specific to functionality and at the same time easier to maintain.
The most effective method of decreasing coupling and increasing cohesion is design by interface.
Example of Low Cohesion:
-------------------
| Staff           |
-------------------
| checkEmail()    |
| sendEmail()     |
| emailValidate() |
| PrintLetter()   |
-------------------
Example of High Cohesion:
----------------------------
| Staff                   |
----------------------------
| -salary                 |
| -emailAddr              |
----------------------------
| setSalary(newSalary)    |
| getSalary()             |
| setEmailAddr(newEmail)  |
| getEmailAddr()          |
----------------------------


Decoupling allows you to change the implementation without affecting other parts of your software.

Loose coupling in general means each component does not depend on the implementation details of other components. Loose coupling enables each component to evolve independently without breaking other depending components.

Tight coupling is when a group of classes are highly dependent on one another.

What about Native Code? The phrase native code is used in two contexts. 

Code that runs under the control of the common language runtime (CLR) is called managed codeand 
code that runs outside the CLR is called unmanaged code
COM, COM+, C++ components, ActiveX components, and Microsoft Win32 API are examples of unmanaged code.
I prefer to say .unmanaged code. for this meaning, because it emphasizes that the code does not get the services of the CLR runtime. For example, Code Access Security in managed code prevents code loaded from another server from performing certain destructive actions. If your application calls out to unmanaged code loaded from another server, you won't get that protection.
Native code is executable code, machine code which the OS can execute on the CPU
As a result, don't just assume that native = unmanaged.
------------------------------------------------------------------------------------------
Managed Code is what Visual Basic .NET and C# compilers create. It compiles to Intermediate Language (IL), not to machine code that could run directly on your computer. The IL is kept in a file called an assembly, along with metadata that describes the classes, methods, and attributes (such as security requirements) of the code you've created. 
Managed code runs in the Common Language Runtime. The runtime offers a wide variety of services to your running code. In the usual course of events, it first loads and verifies the assembly to make sure the IL is okay. Then, just in time, as methods are called, the runtime arranges for them to be compiled to machine code suitable for the machine the assembly is running on, and caches this machine code to be used the next time the method is called. (This is called Just In Time, or JIT compiling, or often just Jitting.)As the assembly runs, the runtime continues to provide services such as security, memory management, threading, and the like. The application is managed by the runtime.
Native code, on the other side, does not depend on anything like this and has total freedom to access any memory area (at least within the process memory space

Interoperability is the ability of a system or a product to work with other systems or products without special effort on the part of the customer.

Interoperability enables you to preserve and take advantage of existing investments in unmanaged code.

scalability - can expand


Language interoperability in .NET: Language interoperability is the ability of code to interact with code that is written by using a different programming languageLanguage interoperability can help maximize code reuse and improve the efficiency of the development process.