Feeds:
Posts
Comments

Last week I was busy with my training on PL/SQL for PSI Data Systems. I was discussing the “PL/SQL Performance tuning with BULK COLLECT” with participants and I demonstrated the performance boost with the example. I would like to share the discussion with this post.

Scenario:  Having a table with 10 million records needs to store into the PL/SQL Table by Index collection using the Cursors. The code snippet is as below.

DECLARE

   time_before BINARY_INTEGER;

   time_after BINARY_INTEGER;

   CURSOR empcur IS SELECT * FROM testemp;

   TYPE emp_table_type IS TABLE OF varchar2(20) INDEX BY BINARY_INTEGER;

   emp_table emp_table_type; 

   idx number := 1;           

BEGIN

   time_before := DBMS_UTILITY.GET_TIME;

   OPEN empcur;

   LOOP

                FETCH empcur INTO emp_table(idx);

                idx := idx + 1;

                EXIT WHEN empcur%NOTFOUND;

   END LOOP;  

   CLOSE empcur;             

 time_after := DBMS_UTILITY.GET_TIME;

                DBMS_OUTPUT.PUT_LINE (round((time_after – time_before)/60));

END;/

 

The above code without any performance trick, it took nearly 5 minutes (in my laptop with normal configuration) to complete.

The reason behind the bad performance is, all we know that in PL/SQL there are two statement executors to execute the program. One is SQL statement executor which executes only SQL statements in the program and the other one is PL/SQL statement executor who will execute procedural instructions.

Whenever a PL/SQL program is executing, a context switching will take place between the two statement executors. Especially if the program is doing some iterative task which contains the combination of SQL and PL/SQL code, it needs frequent context switching which Leeds into performance drawback.

This is what happening in the above code while fetching the records one by one in the loop. For each iteration there is a context switching and this will happens over 10 million times.

To avoid the context switching repeatedly, we need to collect the data at once using the below code.

The same code has been modified with the BULK COLLECT as follows.

DECLARE

   time_before BINARY_INTEGER;

   time_after BINARY_INTEGER;

   CURSOR  empcur IS SELECT * FROM testemp;

   TYPE emp_table_type IS TABLE OF varchar2(20) INDEX BY BINARY_INTEGER;

   emp_table emp_table_type; 

BEGIN

   time_before := DBMS_UTILITY.GET_TIME;

   OPEN empcur;

                FETCH empcur BULK COLLECT INTO emp_table;

   CLOSE empcur;                             

   time_after := DBMS_UTILITY.GET_TIME;

   DBMS_OUTPUT.PUT_LINE (round((time_after – time_before)/60));

END;

/

The above code with BULK COLLECT  took just 1 minute to complete. So we nearly increased 80% of the performance.

Similarly in PL/SQL there are many such tuning tips are there. So keep visit my blog for more tips.

Happy programming.

 

Among thousands, 10 programming languages stand out for their job marketability and wide use. If you’re looking to boost your career or learn something new, start here.

Knowing a handful of programming languages is seen by many as a harbor in a job market storm, solid skills that will be marketable as long as the languages are.

Yet, there is beauty in numbers. While there may be developers who have had riches heaped on them by knowing the right programming language at the right time in the right place, most longtime coders will tell you that periodically learning a new language is an essential part of being a good and successful Web developer.

Below are the selected 10 programming languages that are a bonus for developers to add to their resumes. Even better, theyre great jumping-off points, with loads of job opportunities for younger recruits.

 

1. PHP

·         What it is: An open-source, interpretive, server-side, cross-platform, HTML scripting language, especially well-suited for Web development as it can be embedded into HTML pages.

·         Why you should learn it: Its particularly widely used. “High-speed scripting with caching, augmented with compiled code plug-ins (such as can be done with Perl and PHP) is where the future is. Building Web apps from scratch using C or COBOL is going the way of the dinosaur,” said Duquaine.

 

2. C#

·         What it is: A general-purpose, compiled, object-oriented programming language developed by Microsoft as part of its .NET initiative, it evolved from C and C++

·         Why you should learn it: Its an essential part of the .Net framework. “Learning C#, which is just Java with a different name plate, is critical if you heavily use Microsoft,” said Duquaine.

 

3. AJAX (Asynchronous JavaScript and XML)

·         What it is: Though technically not a programming language, AJAX uses XHTML or HTML, JavaScript and XML to create interactive Web applications.

·         Why you should learn it: Ever since Google Maps put AJAX, well, on the map, the requests for AJAX-knowledgeable pros went through the roof. “The demand for AJAX knowledge is huge because its so damned hard to learn,” said Huckaby. Of note, Microsoft announced recently plans to release a tool named Atlas that will make AJAX easier to implement. “If Microsofts Atlas tool is successful, it would bring the extreme complexity and annoyance of AJAX to the average worker,” said Huckaby.

 

4. JavaScript

·         What it is: Not to be confused with Java, JavaScript is a an object-oriented, scripting programming language that runs in the Web browser on the client side. Its smaller than Java, with a simplified set of commands, easier to code and doesnt have to be compiled.

·         Why you should learn it: Embedded into HTML, its used in millions of Web pages to validate forms, create cookies, detect browsers and improve the design. With its simplicity to learn as well as wide use, its considered a great bang for your educational buck.

 

5. Perl

·         What it is: Perl is an open-source, cross-platform, server-side interpretive programming language used extensively to process text through CGI programs.

·         Why you should learn it: Perls power in processing of piles of text has made it very popular and widely used to write Web server programs for a range of tasks. “Learning some form of scripting language, such as Perl or PHP is critical if you are doing Web apps,” said Duquaine.

 

6. C Programming

·         What it is: A standardized, general-purpose programming language, its one of the most pervasive languages and the basis for several others (such as C++).

·         Why you should learn it: “Learning C is crucial. Once you learn C, making the jump to Java or C# is fairly easy, because a lot of the syntax is common. Also, a lot of C syntax is used in scripting languages,” said Duquaine.

 

7. Ruby and Ruby on Rails

·         What they are: Ruby is a dynamic, object-oriented, open-source programming language; Ruby on Rails is an open-source Web application framework written in Ruby that closely follows the MVC (Model-View-Controller) architecture.

·         Why you should learn it: With a focus on simplicity, productivity and letting the computers do the work, in a few years, its usage has spread quickly. As a bonus, many find it easy to learn.

 

8. Java

·         What it is: An object-oriented programming language developed by James Gosling and colleagues at Sun Microsystems in the early 1990s.

·         Why you should learn it: Hailed by many developers as a “beautiful” language, it is central to the non-.Net programming experience. “Learning Java is critical if you are non-Microsoft,” said Duquaine.

 

9. Python

·         What it is: An interpreted, dynamically object-oriented, open-source programming language that utilizes automatic memory management.

·         Why you should learn it: Designed to be a highly readable, minimalist language, many say it has a sense of humor (spam and eggs, rather than foo and bar), Python is used extensively by Google as well as in academia because of its syntactic simplicity.

 

10. VB.Net (Visual Basic .Net)

·         What it is: An object-oriented language implemented on Microsofts .Net framework.

·        Why you should learn it: Most argue that VB.Net is currently more popular than ever and one of the only “must-learns.” “It is currently dominating in adoption and that is where all the work is,” said Huckaby.

 

To be a “most important” innovation, an innovation has to be an idea that is very widely used and is critically important where it applies. – David A. Wheeler

 

It’s not easy choosing the best innovators in an industry defined by innovation. The nature of software is such that the technologies, systems and products completely refresh every decade or so. The triumphant invention of just 10 years ago is now considered “legacy” or even obsolete. So making a lasting impression in the software business is a tough task indeed.

Following is my list of the top 10 software innovators of all time. Inclusion on this list doesn’t mean the person came up with every idea or wrote every byte of code. Rather, these are the people whose leadership, ideas, designs and products propelled the software industry forward by leaps and bounds. Their innovations affect us greatly even today.

 

10. Dan Bricklin – VisiCalc

Dan Bricklin Dan Bricklin was co-creator of VisiCalc, the first spreadsheet software available for personal computers. He received the Grace Hopper Award in 1981 for VisiCalc. He also founded Trellix, a website software company now owned by Web.com, and is founder and president of Software Garden.

VisiCalc was the first serious, mainstream business program for the IBM personal computer. It signaled the coming shift from large mainframes to small PCs, proving these personal computers could indeed be used for business. Many of the first IBM PCs were purchased just to run VisiCalc. Eventually Lotus 1-2-3 and Microsoft Excel squashed VisiCalc, and unfortunately Bricklin never profited greatly from his invention.

9. Larry Ellison – Oracle

Larry Ellison Larry Ellison founded Oracle in 1977 with $2000 of his own money. Oracle published the first commercially-available relational database and essentially launched the database market. Today, Oracle is the world’s leading supplier of database software and the second largest independent software company with nearly $10 billion in annual revenue. Oracle recently acquired PeopleSoft, Siebel Systems and Hyperion.

Ellison is living proof that business sense is an innate gift, not something to be gleaned from academic textbooks. A college dropout, Ellison is now a multi-billionaire renowned for his business sense, drive and ambition.

8. Shawn Fanning – Napster

Shawn Fanning

In 1998, Shawn Fanning created Napster, the first massively popular peer-to-peer file sharing system. Fanning appeared on the cover of Wired magazine and quickly rose to fame. Napster peaked in 2001 with 26 million users worldwide. However, Napster also became the target of several music industry lawsuits, which ultimately killed the service. Since 2002, Roxio has owned the Napster name, which it used to rebrand its PressPlay music service.

Napster forever changed the entertainment business. By providing an enormous selection of free music to download, it enabled people to obtain just the music hits, effectively demoting the album. Napster also made it easy for music enthusiasts to download songs that were otherwise difficult to obtain, such as older music, unreleased recordings, and concert bootlegs. The music industry is still struggling to recover from the impact of Napster and peer-to-peer file sharing.

7. Chad Hurley and Steve Chen – YouTube

Steve Chen + Chad Hurley

Chad Hurley and Steve Chen founded YouTube, a video sharing website where users can upload, view and share video clips. Google purchased YouTube in 2006 for $1.65 billion in Google stock. In January 2008, nearly 79 million users watched over 3 billion videos on YouTube. Currently YouTube hosts about 83.4 million unique videos and 3.75 million user channels. YouTube consumes more Internet bandwidth today than was used by the entire Internet in 2000.

YouTube has become a global hub of self-expression. It was one of the main factors for Time magazine’s declaration of “you” as the “Person of the Year” in 2006. It allows you to “wrest power from the few and help one another for nothing.” This will “not only change the world, but also change the way the world changes.” You are no longer just receiving the news produced by media, but you are creating your own news and becoming the hero in your own movies.

6. Linus Torvalds – Linux

Linus TorvaldsLinus Torvalds is a Finnish software engineer who initiated development of the Linux kernel. At the time, the GNU Project had created many of the components necessary for a free software operating system but lacked a solid kernel. The result is Linux, the world’s most popular operating system that’s not Windows.

Torvalds wrote about 2% of the Linux kernel himself, which is significant, given there are thousands of contributors to the open source operating system. Today Torvalds is the ultimate authority on what new code is incorporated into the standard Linux kernel. Torvalds owns the “Linux” trademark and manages the non-profit organization Linux International.

5. Marc Andreessen – Netscape

Marc Andreessen Marc Andreessen was the co-author of Mosaic, the first widely-used web browser, and co-founder of Netscape Communications. AOL acquired Netscape in 1999 for $4.2 billion and made Andreessen its Chief Technology Officer. Andreessen was also the co-founder and chairman of software company Opsware (originally Loudcloud) when it was acquired by Hewlett-Packard. Currently he is co-founder of Ning, a company that provides a platform for social-networking websites.

Andreessen was 23 years old when he built the browser that launched the World Wide Web. The Netscape $2 billion IPO in 1995 propelled Andreessen into the spotlight and on the cover of Time magazine. Andreessen became the “poster-boy wunderkind of the Internet bubble generation: young, twenty-something, high-tech, ambitious, and worth millions (or billions) of dollars practically overnight.” (wiki)

4. Larry Page and Sergey Brin – Google

Larry Page and Sergey Brin Larry Page and Sergey Brin, Ph.D. students at Stanford, invented Google in 1996 as a research project. The Google website launched in 1997, and by the end of 1998 it had indexed about 60 million web pages. In 2000, Google began selling advertisements associated with search keywords and launched the pay-per-click model, until then a rarity in advertising. Google launched its IPO in 2004, raising $1.67 billion and giving it a market capitalization of $23 billion, making Page and Brin instant billionaires.

Today Google has a market cap of $180 billion and owns 70% of web searches. Google performs nearly 6 billion web searches each month. Google has also become a verb in popular lexicon. If there’s anything you need to know, you “Google it.”

3. Steve Jobs – Apple, Pixar

Steve JobsSteve Jobs is the CEO, chairman and co-founder of Apple Inc., and is the founder and former CEO of Pixar Animation Studios. In fiscal 2007, Apple had worldwide sales of $24 billion. Apple’s iPod and iTunes dominate the portable and online music markets with nearly 80% market share. The Apple Macintosh owns 8% of the personal computer market and provides an effective counter-weight to the dominance of Microsoft Windows. Pixar led the surge of software-animated feature films, including Toy Story and Finding Nemo, resulting in eight academy awards. The Walt Disney Company purchased Pixar from Jobs in 2006 for $7.4 billion.

Jobs “contributed greatly to the myths of the quirky, individualistic Silicon Valley entrepreneur, emphasizing the importance of design while understanding the crucial role aesthetics play in public appeal. His work driving forward the development of products that are both functional and elegant has earned him a devoted following.” (wiki)

2. Tim Berners-Lee – World Wide Web

Tim Berners Lee Sir Tim Berners-Lee is an English developer who invented the World Wide Web in March 1989. Berners-Lee published the first website on August 6, 1991. The site provided an explanation about what the World Wide Web was, how to use a web browser, and how to set up a web server. Berners-Lee made his idea freely available, with no patent or royalties due. In 1994, Berners-Lee founded the World Wide Web Consortium (W3C) at the Massachusetts Institute of Technology. The W3C declared their standards must be based on royalty-free technology so they can be easily adopted by anyone.

Berners-Lee once said: “I just had to take the hypertext idea and connect it to the Transmission Control Protocol and domain name system ideas and — ta-da! — the World Wide Web.” The World Wide Web is one of the most important communication inventions in history, providing a standard platform for global communications and commerce. Today there are over 100 million websites and 45 billion web pages.

1. Bill Gates – Microsoft

Bill Gates Bill Gates is co-founder and chairman of Microsoft, the world’s largest software company with 79,000 employees in 102 countries and $51 billion in annual sales. More than 90% of personal computers use the Microsoft Windows operating system, and nearly 50% of web servers run Microsoft software. Microsoft also dabbles in cable TV, Internet portals, computer hardware, and gaming with the XBox. Microsoft is currently in process to acquire Yahoo.

Gates, the world’s third richest man, has left Microsoft to become a full-time philanthropist. His Gates Foundation is the largest in the world with an endowment of $38 billion.

Say what you will about Microsoft, but kudos to the man whose company delivered a world-dominant computing platform, offering software entrepreneurs a market 600 million strong and expected to hit a billion by 2010. When there is that much attention and opportunity focused in one place, we will continue to see incredible advances in software and hardware that fuel Moore’s Law and drive our information society.

So who would appear on your list of Top 10 Software Innovators? Please comment below.

Placement & HR Consultants

Name and Information Address
Venturepluz
Venturepluz is one of the fastest growing, most innovative Software and Human Resource consulting firm in the city. They provide a wide range of services to reach their targeted audience and share valuable information focusing on retaining their customers.
http://www.venturepluz.com/
#174,1st Floor, St.John’s Road,
Bangalore – 500 042
Tel:+(91)-(80)- 2551 2524, 6451 1843
HR-One Management Consultants Ltd.
It is one of the finest HR management consultant in Bangalore and having their offices in all the major cities in India. This firm has eight years of experience in this field.
NO.146/3, 1st Floor, Coconut Avenue Road
7th Cross, Malleshwaram
Bangalore – 500 003
Tel:+(91)-(80)- 4143 3800
Rite Choice Consultants Pvt. Ltd.
The firm is well known for providing advisory services on selection of high-caliber professionals at mid, senior & top management positions across functions & industries and a bouquet of HR services.
http://www.ritejobs.com
CITICASA,BasappaRoad, Shanti Nagar
Bangalore – 560 027
Tel:+(91)-(80)- 4124 8800
Fax:+(91)-(80)- 6452 2266
Steering Jobs Pvt. Ltd.
This firm is one of the leading recruitment consultancy firm catering to the Human Resource requirements of a large number of companies in Bangalore and all across south India.
http://www.steeringjobs.com/
44,3rd Floor Church street
Bangalore – 500 001
Tel:+(91)-(80)- 5112 2940, 5112 2941
Team Lease Staffing Solution
Team Lease is one of the well establish staffing solution provider company situated in Bangalore, having good reputation in this region. This company was setup in 2002 and in short span of time they have 70,000 employees in 464 location.
http://www.teamlease.com
26, Palm Grove Road, nn Off. Victoria Road
Bangalore – 560 047
Tel:+(91)-(80)- 2557 5660
Fax:+(91)-(80)- 2557 5661
The Head Hunters India Pvt Ltd
The Head Hunters India is a consultancy firm specialized in recruiting executive personnel with outstanding track records who will create competitive advantage and sustainable value to your organization.
http://www.headhuntersindia.com
201, Brigade corner, 110/73 Kanakpura Road
Jayanagar, 7th Block, Yediyur Circle
Bangalore – 560 082
Tel:+(91)-(80)- 2676 5773, 2676 5739
Fax:+(91)-(80)- 2676 3201
Human Resource Specialists
It is a globally known HR consultancy firm offering quality recruitment and HR services to their clients in India and in abroad.
http://www.hrsindia.com
Global House 3rd Floor, 105 Richmond Road
Bangalore – 560 025
Tel:+(91)-(80)- 2221 6622, 2227 5166
Vruksham Talent Group
Vruksham Talent Group provide professional in the field of IT, Telecom, Networking, Storage, Security & Convergence.
http://www.vruksham.com
Gurudarshan’, #15(33), I Floor
Mahanth’s Layout, Bull Temple Road
Bangalore – 560 019
Tel:+(91)-(80)- 2662 3567, 2660 2862
ABC Consultants Pvt. Ltd.
ABC Consultants is one of the oldest consultancy firm in Bangalore having over 38 years of experience in this field. This firm has grown to be a premier executive search & selection group, a preferred recruitment partner for their clients and a trusted consultant for professionals both in India and overseas.
http://www.abcconsultants.net
The Presidency 2nd Floor, No.1, St. Mark’s Road
Bangalore – 560 001
Tel:+(91)-(80)- 4179 5000
Fax:+(91)-(80)- 2212 2486
Mind Group
Mind Group was established in 1992, they offer quality recruitment services to their clients in India and also in abroad.
http://www.mindgroupsolutions.com
166, 1st Floor, 7th Cross, 2nd Block, Jayanagar
Bangalore – 500 011
Tel:+(91)-(80)- 2656 2911, 2656 2811
Fax:+(91)-(80)- 2656 6397
City Info Service Pvt. Ltd.
City Info is a professionally managed organization, which provides recruitment solution to their clients.
http://www.cityinfoservices.com
102, ‘E’ Wing, Mittal Towers, M. G. Road
Bangalore – 560 001,
Tel:+(91)-(80)- 2532 0401
Fax:+(91)-(80)- 2532 0405
Fairlinks Placements
Fairlinks Placements was setup in 1994, specialized in high value Recruitment and Staffing Solutions.
http://www.fairlinksindia.com
Plot No. 37& 38, Flat No. 2A, Rama Residency
Hospital Road, Shivaji Nagar, OFF Infantry Road
Bangalore – 500 001
Tel:+(91)-(80)- 5113 2192, 5113 0440
Reach Management Consultants Pvt. Ltd.
Setup in 1990, Reach Management Consultants has carefully crafted a niche for itself as a reliable Human Resources Services provider in India.
http://www.reach.co.in
No. 13, 1st Floor, 1st main road, Jayamahal extension
Bangalore – 500 046
Tel:+(91)-(80)- 2343 9970
Genius Consultants Ltd.
Genius Consultants Ltd. was started their business as a recruitment consulting organization in 1993, after that they diversified into Outsourcing of Manpower, Payroll, Employment Verification, HR Consulting, Quality and Environment Consulting.
http://www.geniusconsultant.com
No.829, “Bulsaria House” 10th ‘A’ Main Road
4th Cross, Indira Nagar, 1st Stage
Bangalore – 500 038
Tel:+(91)-(80)- 3057 7795, 3057 7796
CHR Global Pvt. Ltd.
Established in 1980 by some of the well distinguished professionals, the main focus of this firm is Identifying, assessing, counselling, acquiring and measuring talents, skills and knowledge in relation to the business roles and responsibilities.
http://www.chrglobal.com
No. 3787, Ground Floor, 8th Cross, 13th Main
HAL Stage II, Indira Nagar
Bangalore – 560 008
Tel:+(91)-(80)- 4126 3697, 4126 3627
Summit HR
Summit HR is a globally known human resource services firm that delivers a full suite of comprehensive HR and Recruitment Process Outsourcing services to leading companies in United States, Europe and India.
http://www.summithrww.com
74, 1st Across 4th main Domlur, 2nd stage
Bangalore – 500 071
Tel:+(91)-(80)- 2535 4333
Career Graph
Career Graph is a premier talent search firm with over fifteen year of experience, they specialized in international jobs, domestic jobs, recruitment service and job placement services.
74,4th Main,1st ‘ A’ Cross Damiur 2nd Stage
Bangalore – 560 072
5M Consultants
5M Consultants has been in the business of People Consulting and Services for about six years now. The firm is actively consulting with top notch companies providing Staffing Solutions and HR Services.
http://www.5mconsultants.com
Concord Business center, 460/20/1.30th cross
Jayanagar 4th block, Next to Jain temple
Bangalore – 560 011
Tel:+(91)-(80)- 5121 0339, 5121 0480
A.F.Ferguson & Co.
It is a one of the oldest consultancy firm in India, having over 30 years of experience in this region. Specialist in management consultancy services in various functions and sectors, drawing on resources from a large domestic and international network.
http://www.afferguson.com
Deloitte Center Anchorage II 100/2 Richmond Road
Bangalore – 560 025
Tel:+(91)-(80)- 5527 6000
Fax:+(91)-(80)- 5527 6013
A1 Placements
A1 Placements is a career developing organization with more than decade of experience and having their tie up with the leading corporate houses and individual in India and in abroad. They offer quality consultancy services to their clients.
http://www.a1placements.com
92, 3rd Cross Lavelle Road
Bangalore – 560 001
Tel:+(91)-(80)- 2227 1700, 5112 5300
ALP Management Consultants
Alp is a one stop solution provider in the field of HR consultancy, the firm is well experienced and expertise in executive search.
http://www.alpconsultants.com
No. 3, “People Hut”, 12th Main, Palace Road, Vasantnagar
Bangalore – 560 052
Tel:+(91)-(80)- 4111 7800
Associated Recruitment & Management Services Pvt. Ltd.
ARMS is providing integrated Human Resource Management services to its clients around the globe, the firm is well known for their cost-effective and rapid Staffing solutions to address the ever-increasing demand of the qualified professionals.
http://www.armsindia.net
2nd Flor, Sesha Sadan No.13, Cambridge Road
Cambridge Layout Ulsoor
Bangalore – 560 008
Tel:+(91)- 98803 00771
Classic Search Pvt. Ltd.
A recruitment services provider which operates on the principles of integrity and professionalism, setup in 1998. It is one of the reliable, result oriented and professional recruitment firm in Bangalore.
http://www.classicsearchplc.com
“Mount Kailash”, ‘A’ Wing, 2nd Floor
#33/5, Meanee Avenue Road, Ulsoor
Bangalore – 560 042
Tel:+(91)-(80)- 4113 4321, 4113 4325
ESP Consultant India Pvt. Ltd.
ESP Consultant India Pvt. Ltd. is a reliable consultancy in Bangalore and having their offices in Bangalore and Hyderabad is well. The consultants of this firm quickly respond to client needs, offer research base solutions, honest feedback with integrity.
http://www.espconsultant.com
Office no.105, 1st floor, Prestige
Meredian – 1, M.G.Road
Bangalore – 560 001
Tel:+(91)-(80)- 4112 9884, 4112 9885
Ermg Management Consultancy Pvt. Ltd.
ERMG a leading professional executive search and management consultancy group, started in 1995. They provide information and support to MNC organization to recruit the right kind of people to meet the ever-growing challenges of tomorrow.
http://www.ermg-global.com
180, 5th Main, 4th Block West, Jayanagar
Bangalore – 560 011
Tel:+(91)-(80)- 2654 0116, 2634 9351
Steering Jobs Pvt. Ltd.
The firm was setup in 2001, Steering Jobs Pvt. Ltd. is one of the leading recruitment consultancy firm catering to the human resource requirements of a large number of companies in Bangalore and all across south India.
http://www.steeringjobs.com/
44,3rd Floor Church street
Bangalore – 560 001
Tel:+(91)-(80)- 5112 2940, 5112 2941

In this post I address how .Net and COM types can be expressed and manipulated across architectural boundaries. And also, you are exposed to the key .NET-to-COM interoperability issues you are likely to encounter on a day-to-day basis. For example, you investigate a number of ways to build interoperability assemblies (including “primary” interop assemblies), examine core IDL to .NET data type mappings, and understand how key COM data structures (interfaces, co-classes, enumerations) are expressed in terms of .NET. Along the way, you take a more detailed look at the types contained in the System.Runtime.InteropServices namespace. As you might expect, the materials presented here work as the backbone for more advanced topics found in the remainder of the text.

 

A High-Level Overview of .NET-to-COM Interoperability

 

As you know; languages targeting the .NET runtime satisfy each pillar of object-oriented technology. For example, when you build an assembly using a given managed language, you are able to create classes that support any number of constructors, overloaded methods, and overridden members, and implement any optional interfaces. As well, the .NET platform makes use of a runtime garbage collector, which is responsible for freeing an object from the managed heap when it is no longer rooted in a given application.

 

In stark contrast, as you know COM types do not adhere to each and every pillar of OOP in the classic sense of the topic. For example, COM types are not created using class constructors, but rather using the IClassFactory interface. In addition, COM classes are not allowed to define over-loaded methods and cannot function as a base class to other COM types (as COM has no support for classical inheritance). As far as lifetime management of a co-class is concerned, COM does not make use of a garbage-collected heap, but employs a strict reference counting scheme provided courtesy of IUnknown.

 

Given the fact that COM and .NET types have so little in common, you may have deeprooted fears regarding interoperability issues. Ideally, a .NET client should be able to use a COM type with no concern for the mechanics of COM. For example, a managed client should be able to create the COM type using constructor semantics, derive new types from the COM wrapper class (given that .NET supports classic inheritance), and should not be required to obtain or release interface references (given that .NET does not demand the use of interface references). In a nutshell, as far as a .NET client is concerned, manipulating a COM type should look identical to the act of manipulating a native .NET type. For example:

 

// COM classes should appear as .NET types.

MyComClass c = new MyComClass();

c.SomeMethod(”Hello”, 12);

 

Obviously, this cannot be achieved unless you have an intermediary that stands between the .NET client and the existing COM type. In short, what we need is a proxy that is in charge of transparently handling .NET-to-COM communications. To be sure, whenever a .NET application makes use of a legacy COM type, a proxy is created by the .NET runtime. Formally, this proxy is termed a Runtime Callable Wrapper (RCW).

 

In a similar vein, a COM client should be able to make use of a .NET type without concern for the mechanics of .NET. For example, COM clients should be able to activate a .NET class using CoCreateInstance(); directly call the members of IUnknown, IDispatch, and IClassFactory; and should assume the type is maintaining an internal reference count. When unmanaged code communicates with managed .NET types, a different sort of proxy called a COM Callable Wrapper (CCW) is used to translate COM requests into terms of .NET. For the time being, let’s concentrate on the role of the RCW.

 

Understanding the Role of the RCW

 

The RCW is a .NET object that is in charge of marshaling calls between a managed unit of code and a given COM type. While a managed client is making calls to a given COM type, the RCW intercepts each invocation, translates each incoming argument into terms of IDL data types, and invokes the co-class method. Likewise, if the co-class returns any information to the caller (via [out] or [out, retval] IDL parameters) the RCW is responsible for translating the IDL type(s) into the appropriate .NET type(s). As you would hope, there is a fixed set of translation rules used to map between IDL and .NET atoms.

 

In addition to marshaling data types to and fro, the RCW also attempts to fool the .NET client into believing that it is communicating directly with a native .NET type. To do so, the RCW hides a number of low-level COM interfaces from view (IClassFactory, IUnknown, IDispatch, and so forth). Thus, rather than forcing the .NET client to make manual calls to CoCreateInstance(), the client is free to use the activation keyword of its code base (e.g., new, New, and so on). And rather than forcing the managed client to manually call QueryInterface(), AddRef(), or Release(), the client is able to perform simple casting operations to obtain a particular interface and is never required to release interface references.

 

It is important to understand that a single RCW exists for each co-class the client interacts with, regardless of how many interfaces have been obtained from the type. In this way, an RCW is able to correctly manage the identity and reference count of the COM class. For example, assume a C# Windows Forms application has created three co-classes residing in various COM servers. If this is the case, the runtime creates three RCW proxy types to facilitate the communication

 

A given RCW maintains a cache of interface pointers on the COM object it wraps and releases these references when the RCW is no longer used by the caller (and therefore garbage collected). In this way, the managed client is able to simply “new” the COM wrapper and is blissfully unaware of COM interface-based reference counting. Also, given that the RCW will not release the referenced interfaces until it is garbage collected, you can rest assured that a given co-class is alive as long as the .NET client is making use of the related RCW.

 

Understand, of course, that the RCW is responsible for more than simply mapping .NET types into COM atoms. The RCW is also responsible for mapping COM error objects (that is, IErrorInfo, ICreateErrorInfo) into managed exceptions. In this way, if a co-class throws a COM error, the .NET client is able to handle the problem using standard try, catch, and finally keywords. The RCW is also responsible for mapping COM event handling primitives (that is, IConnectionPointContainer, IConnectionPoint) into terms of managed delegates.

 

One question that may pop up at this point is “Where does an RCW come from in the first place?” As you will see, RCWs are .NET class types that are dynamically created by the runtime. The exact look and feel of an RCW will be based on the information contained within a related interop assembly. These assemblies contain metadata that is used specifically to bridge the gap between managed and unmanaged code. The good news is that you are not required to manually create interop assemblies by hand (though you could). Rather, you more typically make use of the tlbimp.exe tool that ships with the .NET SDK or the Visual Studio .NET IDE.

 

Older Posts »