Sunday, September 27, 2009

UNO is Universal Network Objects

UNO is a component model that offers inter-operability between different programming languages, different objects models, different machine architectures, and different processes; either in a LAN or via the Internet. UNO is freely available and currently supports Java, C and C++ (on windows, Linux, and Solaris). A bridge for COM OLE Automation already exists. UNO is developed by the OpenOffice.org community including the Sun Microsystems development labs.

UNO is interface based, as are COM and CORBA. Components implement interfaces compliant to their interface specification. Multiple components communicate only via their interfaces. This allows implementing one component in a different language or to move an implementation to another machine, without modifying the other's components. This gives you huge flexibility and preserves earlier invested efforts.

Each component lives in a Uno Runtime Environment (URE). A URE is identified by the implementation language and the current process. There is no performance overhead for components, that are instantiated within the same URE, e.g., in C++, a call from component A to B is just a virtual call. The calls between components from different UREs are bridged by UNO.



In general, calls are bridged through a single dispatch method. This method is, in general, easy to implement for inter-process bridges or bridges to interpreting languages. There is no generated code for stubs or proxies. All necessary conversions are done by the generic dispatch method. The information about the method signature is retrieved dynamically from a type library. This type library is reused by every bridge, so only the number of entries in the type library grows with a growing number of types. This reduces build time and memory consumption at runtime; nevertheless, bridging is as fast as generated code.

UNO-interfaces are specified in IDL. All UNO-interfaces must be derived from a super interface, that offers acquire, release, and a QueryInterface() method (comparable to COM). The lifetime of UNO-objects is controlled by global reference counting. Exceptions are used for error handling.

UNO guarantees object identity, thread identity, and the sequence of calls.
  •  Object Identity - Two interfaces' references can be compared for equality. UNO guarantees, that the result is correct, no matter whether the result is true or false.
  •  Thread Identity - In UNO every thread is named by a globally unique thread identifier. A thread leaving the process via an inter-process bridge is identified when entering the process, again, some callstack levels higher. The same thread will execute the new call thus guaranteeing that any thread dependent resources stay the same (such as thread local storage, lock of mutexes, etc.).
  •  Sequence of Calls - UNO allows declaring a method one way (or asynchron). Multiple, one way calls are guaranteed to be executed in the same sequence as they were called.

A sequence of one way calls can be transferred and executed extremely fast via an inter-process connection. The UNO inter-process protocol is optimized for low bandwidth connections.

M

The Microsoft code name "M" language is a declarative language for working with data and building domain models. It is used by the "Oslo" Modeling platform. M lets users write down how they want to structure and query their data using a textual syntax that is convenient to both author and reader. M does not mandate how data is stored or accessed, nor does it mandate a specific implementation technology. Rather, M is designed to allow users to write down what they want from their data without having to specify how those requirements are met by a specific technology or platform.

The Oslo Modeling Language, M, is a language for modeling domains using text. A key advantage of modeling in text is ease with which both computers and humans can store and process text. The language feature of M enables information to be represented in a textual form that is tuned for both the problem domain and the target audience. The M language provides simple constructs for describing the shape of a textual language - that shape includes the input syntax as well as the structure and contents of the underlying information. To that end, M acts as both a schema language that can validate that textual input conforms to a given language as well as a transformation language that projects textual input into data structures that are amenable to further processing or storage. 

C# Indexers

Indexers permit instances of a class or struct to be indexed in the same way as arrays. Indexers are similar to properties except that their accessors take parameters. To declare an indexer on a class or struct, use the “this” keyword as shown below:

// Indexer declaration
public int this[int index]    
{
    // get and set accessors
}

The type of an indexer and the type of its parameters must be at least as accessible as the indexer itself. The signature of an indexer consists of the number and types of its formal parameters. It does not include the indexer type or the names of the formal parameters. If you declare more than one indexer in the same class, they must have different signatures. An indexer value is not classified as a variable; therefore, it is not possible to pass an indexer value as a ref or out parameter.

// Using a string as an indexer value
class DayCollection
{
    string[] days = { "Sun", "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat" };

    // This method finds the day or returns -1
    private int GetDay(string testDay)
    {
        int i = 0;
        foreach (string day in days)
        {
            if (day == testDay)
            {
                return i;
            }
            i++;
        }
        return -1;
    }

    // The get accessor returns an integer for a given string
    public int this[string day]
    {
        get
        {
            return (GetDay(day));
        }
    }
}

class Program
{
    static void Main(string[] args)
    {
        DayCollection week = new DayCollection();
        System.Console.WriteLine(week["Fri"]);
        System.Console.WriteLine(week["Made-up Day"]);
    }
}

*  Indexers enable objects to be indexed in a similar way to arrays.
*  A get accessor returns a value. A set accessor assigns a value.
*  The “this” keyword is used to define the indexers.
*  The value keyword is used to define the value being assigned by the set indexer.
*  Indexers do not have to be indexed by an integer value; it is up to you how to define the specific look-up mechanism.
*  Indexers can be overloaded.
*  Indexers can have more than one formal parameter, for example, when accessing a two-dimensional array.

There are two main ways in which the security and reliability of indexers can be improved:
*  Always ensure that your code performs range and type checks when setting and retrieving values from any buffer or array accessed by the indexers.
*  Set the accessibility of the get and set accessors to be as restrictive as is reasonable. This is important for the set accessor in particular.

GAC is Global Assembly Cache

Each computer where the CLR (common language runtime) is installed has a machine-wide code cache called the “Global Assembly Cache”. The global assembly cache stores assemblies specifically designated to be shared by several applications on the computer.

You should share assemblies by installing them into the global assembly cache only when you need to. As a general guideline, keep assembly dependencies private, and locate assemblies in the application directory unless sharing an assembly is explicitly required. In addition, it is not necessary to install assemblies into the global assembly cache to make them accessible to COM interop or unmanaged code.

There are several reasons why you might want to install an assembly into the global assembly cache:
*  Shared location - Assemblies that should be used by applications can be put in the global assembly cache.
E.g. If all applications should use an assembly located in the global assembly cache, a version policy statement can be added to the Machine.config file that redirects references to the assembly.
*  File security - Administrators often protect the SYSTEMROOT directory using an Access Control List (ACL) to control write and execute access. Because the global assembly cache is installed in the SYSTEMROOT directory, it inherits that directory's ACL. It is recommended that only users with Administrator privileges be allowed to delete files from the global assembly cache. 
*  Side-by-side versioning - Multiple copies of assemblies with the same name but different version information can be maintained in the global assembly cache.
*  Additional search location - The common language runtime checks the global assembly cache for an assembly that matches the assembly request before probing or using the codebase information in a configuration file. 

There are several ways to deploy an assembly into the global assembly cache:
*  Use an installer designed to work with the global assembly cache. This is the preferred option for installing assemblies into the global assembly cache.
*  Use a developer tool called the Global Assembly Cache tool (Gacutil.exe), provided by the Windows Software Development Kit (SDK).
*  Use Windows Explorer to drag assemblies into the cache. 

Assemblies deployed in the global assembly cache must have a strong name. When an assembly is added to the global assembly cache, integrity checks are performed on all files that make up the assembly. The cache performs these integrity checks to ensure that an assembly has not been tampered with, e.g. when a file has changed but the manifest does not reflect the change.

To view a list of the assemblies in the global assembly cache, type the following command at the command prompt - gacutil -l


DLR is Dynamic Language Runtime



The Dynamic Language Runtime (DLR) from Microsoft is an ongoing effort to bring a set of services that run on top of the Common Language Runtime (CLR) and provides language services for several different dynamic languages. These services include:
*  A dynamic type system, to be shared by all languages utilizing the DLR services 
*  Dynamic method dispatch 
*  Dynamic code generation 
*  Hosting API

The DLR will be used to implement dynamic languages like Python and Ruby on the .NET Framework. The DLR services are currently used in the development versions of IronRuby, a .NET implementation of the Ruby language, and the upcoming IronPython 2.0.Microsoft plans to use the DLR for the upcoming Visual Basic .NET 10.0 (VBx) and Managed JScript (ECMAScript 3.0).

By having several dynamic language implementations share a common underlying system, it should be easier to let these implementations interact with one another. For example, it should be possible to use libraries from any dynamic language in any other dynamic language. In addition, the hosting API allows interoperability with statically typed CLI languages like C#.

The Dynamic Language Runtime is built on the idea that it is possible to implement language specificities on top of a generic language-agnostic abstract syntax tree, whose nodes correspond to a specific functionality that is common to many dynamic languages. This architecture is backed by the idea that the number of elementary language constructs that would have to be implemented on the generic stack should be inherently limited. The DLR dynamically generates code corresponding to the functionality expressed by these nodes. The compiler for any dynamic language implemented on top of the DLR has to generate DLR abstract trees, and hand it over to the DLR libraries.

The DLR provides dynamically-updated DynamicSite objects that cache the task of binding methods to objects. Since in dynamic languages, the type of an object, as well as the members it contains, can change during a program lifetime, a method invocation must check the method list to see if the invocation is a valid one. DynamicSite objects represent and cache the state of the object and its methods; any update to the object is reflected in the DynamicSite objects as well. DLR routes all method invocations via the DynamicSite objects, which then performs a fast lookup and binding of the method with the actual implementation.

Flex

Adobe Flex can be used to create engaging, cross-platform rich Internet applications. Flex is a highly productive, free open source framework for building and maintaining expressive web applications that deploy consistently on all major browsers, desktops, and operating systems. While Flex applications can be built using only the free Flex SDK, developers can use Adobe® Flex® Builder 3 software to dramatically accelerate development.


Traditional application programmers found it challenging to adapt to the animation metaphor upon which the Flash Platform was originally designed. Flex seeks to minimize this problem by providing a workflow and programming model that is familiar to these developers. MXML, an XML-based markup language, offers a way to build and lay out graphic user interfaces. Interactivity is achieved through the use of ActionScript, the core language of Flash Player that is based on the ECMAScript standard.


The Flex SDK comes with a set of user interface components including buttons, list boxes, trees, data grids, several text controls, and various layout containers. Charts and graphs are available as an add-on. Other features like web services, drag and drop, modal dialogs, animation effects, application states, form validation, and other interactions round out the application framework.


In a multi-tiered model, Flex applications serve as the presentation tier. Unlike page-based HTML applications, Flex applications provide a stateful client where significant changes to the view don't require loading a new page. Similarly, Flex and Flash Player provide many useful ways to send and load data to and from server-side components without requiring the client to reload the view. Though this functionality offered advantages over HTML and JavaScript development in the past, the increased support for XMLHttpRequest in major browsers has made asynchronous data loading a common practice in HTML-based development as well.


Technologies that are commonly compared to Flex include OpenLaszlo, Ajax, XUL, JavaFX and Windows Presentation Foundation technologies such as Silverlight.
Ref: http://www.adobe.com/devnet/flex/


To view a few sample applications created using rich UI with Flex, visit:
http://examples.adobe.com/flex2/inproduct/sdk/restaurant/finder.html
http://blogs.ilog.com/elixir/2009/01/30/factbook2/
http://examples.adobe.com/flex2/inproduct/sdk/flexstore/flexstore.html

Cloud Computing

Cloud computing refers to the use of Internet ("cloud") based computer technology for a variety of services. It is a style of computing in which dynamically scalable and often virtualized resources are provided as a service over the Internet. Users need not have knowledge of, expertise in, or control over the technology infrastructure "in the cloud" that supports them.


The concept incorporates software as a service (SaaS), Web 2.0 and other recent, well-known technology trends, in which the common theme is reliance on the Internet for satisfying the computing needs of the users. E.g. Google Apps which provide common business applications online that are accessed from a web browser, while the software and data are stored on the servers.


The majority of cloud computing infrastructure consists of reliable services delivered through data centers and built on servers with different levels of virtualization technologies. The services are accessible anywhere in the world, with The Cloud appearing as a single point of access for all the computing needs of consumers. Commercial offerings need to meet the quality of service requirements of customers and typically offer service level agreements. Open standards and open source software are also critical to the growth of cloud computing.


As customers generally do not own the infrastructure, they merely access or rent, they can avoid capital expenditure and consume resources as a service, paying instead for what they use. Many cloud-computing offerings have adopted the utility computing model, which is analogous to how traditional utilities like electricity are consumed, while others are billed on a subscription basis. Sharing "perishable and intangible" computing power among multiple tenants can improve utilization rates, as servers are not left idle, which can reduce costs significantly while increasing the speed of application development. A side effect of this approach is that "computer capacity rises dramatically" as customers do not have to engineer for peak loads.


Providers including Amazon, Google and Yahoo exemplify the use of cloud computing. Recently, Microsoft has introduced its new Cloud Computing service as a part of Windows Azure. These services can be accessed through Microsoft Visual Studio by installing the Windows Azure SDK and Windows Azure Tools for Visual Studio 2008.
Ref: http://www.microsoft.com/downloads/details.aspx?familyid=80e3eabf-0507-4560-aeb6-d31e9a70a0a6&displaylang=en
http://www.microsoft.com/downloads/details.aspx?FamilyID=8e90b639-1ef0-4e21-bb73-fc22662911bc&displaylang=en

F# (Pronounced as F Sharp)



Microsoft pronounces F# as its succinct, type-inferred, expressive, efficient functional and object-oriented language for the .NET platform. F# is developed as a research programming language to provide the much sought-after combination of type safety, succinctness, performance, expressivity and scripting, with all the advantages of running on a high-quality, well-supported modern runtime system. This combination has been so successful that the language is now being transitioned towards a fully supported language on the .NET platform. Some of the reasons for this move are that F# gives you:
*  Succinct, type-inferred functional programming, 
*  Interactive scripting like Python and other languages, 
*  Foundations for an interactive data visualization environment, 
*  Combination of type inference and safety, like that of ML, 
*  A cross-compiling core shared with the popular Objective Caml language, 
*  A performance profile like that of C#, 
*  Easy access to the entire range of powerful .NET libraries and database tools, 
*  A foundational simplicity with similar roots to Scheme, 
*  Option of a top-rate Visual Studio integration, which is usable with the freely available Visual Studio 2008 Shell 
*  Experience of a first-class team of language researchers with a track record of delivering high-quality implementations, 
*  Speed of native code execution on the concurrent, portable, and distributed .NET Framework.

F# was developed as a pragmatically-oriented variant of ML that shares a core language with Objective Caml. Unlike other scripting languages it executes at or near the speed of C# and C++, making use of the performance that comes through strong typing. Unlike many type-inferred, statically-typed languages it also supports many dynamic language techniques, such as property discovery and reflection where needed. F# includes extensions for working across languages and for object-oriented programming and it works seamlessly with other .NET programming languages and tools.

Ref: http://research.microsoft.com/en-us/um/people/curtisvv/fsharp_default.aspx

BoundsChecker

DevPartner for Visual C++ detects and analyzes runtime errors, pinpoints performance bottlenecks and verifies test coverage in order to increase code quality and reduce development and testing time through increased productivity. The tool suite integrates seamlessly with Visual Studio for maximum usability within the development environment. BoundsChecker is a memory checking tool used for C++ software development with Microsoft Visual C++. It is part of the DevPartner for Visual C++ BoundsChecker Suite.


BoundsChecker’s error detection technology provides developers with a clear, detailed analysis of programming errors in unmanaged Visual C++ code. It automatically monitors the runtime behavior of the code—how it accesses memory, how it calls APIs and how it uses COM interfaces and methods. Without any special compilation or build steps, developers and testers can automatically locate errors in static, stack and heap memory, and can detect and diagnose memory and resource leaks. This technology enables Visual C++ native application developers to:
*   Locate a large variety of memory and resource problems including leaks, overrun errors and pointer problems;
*   Rapidly sort errors and leaks by size, frequency and type to identify and prioritize critical problems;
*   Check for errors in any native application or component, including proprietary and third-party components and libraries—even when the original source code is unavailable;
*   Detect thread deadlocks, potential deadlocks and other synchronization problems;
*   Locate incorrect usage or failed API calls in any native application component, DLL or EXE, including Win32, ActiveX, DirectX, ODBC, Winsock, Internet APIs and more.


Ref: http://www.compuware.com/products/devpartner/visualc.htm

Aspect Oriented Programming (AOP)


Aspect-oriented programming (AOP) is a programming paradigm that increases modularity by allowing the separation of cross-cutting concerns, forming a basis for aspect-oriented software development. This involves breaking down a program into distinct parts (concerns). All programming paradigms support some level of grouping and encapsulation of concerns into separate, independent entities by providing abstractions (e.g. procedures, modules, classes, methods) that can be used to implement, abstract and compose these concerns. But some concerns defy these forms of implementation and are called crosscutting concerns because they "cut across" multiple abstractions in a program.

Logging is a common example of a crosscutting concern because a logging strategy necessarily affects every single logged part of the system. Logging thereby crosscuts all logged classes and methods.

All AOP implementations have some crosscutting expressions that encapsulate each concern in one place. The difference between implementations lies in the power, safety, and usability of the constructs provided. AspectJ has a number of such expressions and encapsulates them in a special class, an aspect. For example, an aspect can alter the behavior of the base code (the non-aspect part of a program) by applying advice (additional behavior) at various join points (points in a program) specified in a quantification or query called a pointcut (that detects whether a given join point matches). An aspect can also make binary-compatible structural changes to other classes, like adding members or parents.

AOP allows the programmer to express cross-cutting concerns in stand-alone modules called aspects. Aspects can contain advice (code joined to specified points in the program) and inter-type declarations (structural members added to other classes). For example, a security module can include advice that performs a security check before accessing a bank account. The pointcut defines the times (join points) that a bank account can be accessed, and the code in the advice body defines how the security check is implemented. That way, both the check and the places can be maintained in one place. Further, a good pointcut can anticipate later program changes, so if another developer creates a new method to access the bank account, the advice will apply to the new method when it executes.

The following are some standard terminology used in Aspect-oriented programming:

* Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.

* Advice: This is the additional code that you want to apply to your existing model. In our example, this is the logging code that we want to apply whenever the thread enters or exits a method.

* Pointcut: This is the term given to the point of execution in the application at which cross-cutting concern needs to be applied. In our example, a pointcut is reached when the thread enters a method, and another pointcut is reached when the thread exits the method.

* Aspect: The combination of the pointcut and the advice is termed an aspect. In the example below, we add a logging aspect to our application by defining a pointcut and giving the correct advice.