Monday, September 3, 2012

Interoperability issues when importing COM dll to .NET

Well, Another gotcha. To summarize the problem I was facing, there is a COM component, with its well defined interfaces, integrated into a (C#) .NET project. There is a new version of the component, with few more APIs, and I had to integrate and test the new component. The source code for the COM component was available, and I can't change it as its used by multiple other projects.

For integration purpose, using the type library file (tlb), I created the interop library file using Type library import and when I imported this into the .NET project by Adding a Reference, and perform compilation, failures were reported by the compiler for one of the existing API's. There was a library file created for the earlier version of the dll, and with that the compilation went through, which was puzzling to me, as there was no change in the existing API's. I used ildasm to examine the API's of both the interop libraries. When I compared both of them, there was a difference in parameter between the two for a specific API, and the parameter passed to the API, in the later version seemed weird, but I was left wondering how can there be difference. [ Btw, The parameter troubling me was a double pointer to a BSTR ]

MSDN to the rescue. That's when I  landed on this page, which stated that though the import process usually produces accurate interop assemblies, occassionally there is a need to modify the interop. I edited the interop assembly which was the right thing to do, for me. This page briefly states the procedure to do so, by first creating the MSIL file, editing it and creating the new dll.

I lost a couple of hours, for not being aware of it, hence this post, which hopefully helps someone save some time.

Sunday, January 23, 2011

iPad Review

Here are few initial impressions of iPad ( non 3G version) - my first apple device.

+ Just the right size as a portable device to view pictures, video content and to read e books ; galaxy tab beats this in portability but that has poor experience for reading/videos/browsing and it has poorer touch experience; some might say iPad is a glorified iPod - true but worth it.
+ Battery life - should be more than 10 hours if you are using continuously.
+ Email and browsing - Email app is neat.
+ Some apps which I liked / use frequently :
  • Twitter : split page view of tweets , inline presentation of web contenet , lets you cascade through various tweets / pages / profiles and keeps the linkage so that you can come right back
  • gmail browser app : neat presentation of mail content ; caching support
  • notes : nice utility for some quick notes
  • Vlc : super app to play non mp4 videos - best free app to support various formats ; while one may have to use iTunes to add content vlc allows deletion of content directly
  • Maps : google maps designed for iPad - pretty good !
  • Flipboard : Best reading app ! Newspaper like presentation of feed content , which can be flipped through - can be linked to twitter , fb accounts
  • linkedin, imdb, eyewitnesses, ndtv , BBC, radiosai, & Many others.
+ recently introduced multitasking and grouping features ; however multitasking can lead to some overhead at times

+ another simple feature that many may fail to notice is the ability to take screenshots and store them as images

- iTunes overhead for adding content and no support for USB / microsd; can't transfer photos from my camera without using a computer ; every other tablet released supports usb/sd I guess; will apple consider it as a competitive factor and start supporting the same ? I
seriously doubt it.

- missing camera ; front camera to support video calls for VoIP would have been great - I believe it will be available in the next version ; supporting a back camera would be awkward though due to it's size unlike samsung tab which can be held in one hand and has dual camera ;

# I wonder if touch devices will ever provide as good typing experience as a keyboard ; iPad is better than other touch devices though.. ;

# default version of galaxy tab can act as a phone and is available in India already ; why does apple take a long time before they make their devices available in India ? Aren't they losing a lot of potential customers ?

# I used to think it is over priced but after looking at pricing of other tablets I felt it's reasonable

# Found the missing features compensated via accessories such as camera connector which surely are over priced ; do people buy such stuff ?

will add more comments ..

Wednesday, November 3, 2010

why interface inheritance is better ?

As much as i was convinced about it, i always got confused about this. Some useful links that would clarify :

http://www.javaworld.com/javaworld/jw-08-2003/jw-0801-toolbox.html

Thursday, August 5, 2010

How to determine the OS from JAVA..

http://stackoverflow.com/questions/228477/how-do-i-programmatically-determine-operating-system-in-java

Wednesday, June 16, 2010

Abstract classes in JAVA..

Can abstract classes exist in JAVA without any abstract methods ?

The answer is yes. It made me curious as to why it was made technically possible in JAVA, while in C++ it is not the case [An abstract class must contain at least one pure virtual function ].

While it is a rare thing to happen and such a design should always be questioned to see if it is the right thing to do, one specific case where it is justified could be :

The abstract class partially implements an interface, with the intention that its subclasses must complete the interface. To take a slightly contrived motoring analogy, a Chassis class may partially implement a Vehicle interface and provide a set of core methods from which a range of concrete Vehicle types are extended. Chassis is not a viable implementation of a Vehicle in its own right, so a concrete Car subclass would have to implement interface methods for functional wheels, engine and bodywork.

from http://www.codestyle.org/java/faq-Abstract.shtml#whynoabstract !

Sunday, June 13, 2010

Tail Recursion..

Was going through http://saicharan.in/blog/2010/05/binary-search-tree/ when I landed on tail recursion concept.

Have seen code like this before, but have not really noticed the difference between recursive and tail recursive code.

Tail Recursive code brings in lot of efficiency by drastically reducing the amount of stack space used. look up http://en.wikipedia.org/wiki/Tail_recursion !

Thursday, June 10, 2010

Garbage Collector in C++..

Why isn't there a garbage collector in C++, or why hasn't been added... this sure makes a interesting topic to know more about - here i found a fair explanation on the subject.

http://stackoverflow.com/questions/147130/why-doesnt-c-have-a-garbage-collector

Wednesday, June 9, 2010

Floating Point Arithmatic..

Did you ever face something like this : X, and Y are two floating point numbers. You print their values and they are exactly same. and then you write a simple logic like this..

if(x!=y) {

printf("x and y are not equal) ;

}

and it prints that x and y are not equal ;-) Apparantly it happens often. and if you wondered why
the following links might help you.

Its all got to do with floating point numbers..

http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm

http://stackoverflow.com/questions/588004/is-javascripts-math-broken

http://dlc.sun.com/pdf/800-7895/800-7895.pdf

Tuesday, June 8, 2010

what is serialVersionUID ?

Everytime you write a class that implements serializable interface the IDE shows a warning asking to add serialversionUID, I wondered why couple of times but looked it up to find the reasons..

Below is a good link that explains why... the point to note is serialVersionUID is an exception to the rule that “static fields don’t get serialized”

http://www.javablogging.com/what-is-serialversionuid/

Monday, May 24, 2010

Memory leaks in JAVA..

Whenever question was asked about Memory management in JAVA (vs) Memory management in C++, the only thing I knew of is that

- in C++, memory leaks can occur and programmer needs to take care of them by writing cleanup code. and there is also a problem of dangling pointers.
- Clearly in JAVA, garbage collector takes care of memory management, in the sense, it cleans up all the objects to which no references are left. Clearly problem of dangling pointers is addressed. But Is it the same case with Memory leaks ?

There is more to memory leaks in JAVA - some good links.

http://www.ibm.com/developerworks/rational/library/05/0816_GuptaPalanki/

http://jb2works.com/memoryleak/index.html

http://jb2works.com/memoryleak/topfive.html

Sunday, April 25, 2010

System.getproperty()

From http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html

System.getproperty() gets the system property specified by the key, also there is a System.getproperty(String key, String def) where default value can be specified. Helps while setting constants in JAVA program with some default values.

Friday, October 30, 2009

Innovation - Technology Driven (or) Market Driven.

This was a topic of debate at a symposium held in my company. After attending the debate and listening to various points of view - wanted to put together some perspectives on the topic -

Innovation – Market Driven or Technology Driven – or Both – should I say? Innovation is all about finding and exploiting the intersections between unmet needs, enabling solutions (e.g. technology) and marketplace opportunities. But If I have to take a stand and I say Every Innovation is fundamentally driven by markets and is guided by an inherent need. Sometimes the need is explicit and other times it may be latent. The iPod is an example of innovation from the market side by observing that portable electronic devices such as cameras, and phones were on a rapid path of miniaturization with ever increasing functionality. This observation allowed direct entry of innovation from market side, since there was little question that a much smaller portable music player was needed. A huge market for the product is the driving factor behind most of the companies.
Markets are the backbones for pragmatic implementation of the ideas conceived in distinguished laboratories across the planet. Take the example of our very own GE MAC 400. ECG machines existed before. But this product came out as a result of an identified need for an affordable & accessible ECG machine in Indian rural market. Technology played a major role in MAC 400. But no-one thought about the technology of MAC-400 until it was driven by the need in indian rural market place. The disruptive innovation from Tata – Nano car came from Ratan Tata’s observation of people, in families, traveling precariously on motorcycles and scooters in rural India. The vehicle is the result of innovation of ideas, price and most importantly, people, which translates to markets!!
The ultimate goal of any innovation is to create value in the minds of customers. Deep understanding of customers and their needs will help in searching for strategic innovation opportunities. This will act as a 'creative fuel' for the innovation efforts. With this fuel, it will become easier for companies to see potential technologies and solutions through a clearer lens and increase the change of creating really big ideas. PDA was highly innovative product, which flopped when it was first introduced by Apple, Tandy and Motorola. These companies did not choose the right target customer to get market moving, nor did they understand how these customers would get the best value out of the innovation. Palm introduced essentially the same product but, by studying how their customers would use it, the company was able to market a feature with strong customer appeal. Their version of PDA sold millions.
When a company approaches product development from a customer perspective it helps them identify strategic opportunities in the marketplace. Examples: Shampoo sachets came about when the founder of Cavincare observed Indian rural(bottom-of-pyramid) customers using only small doses of shampoos, hair-oil on an ad-hoc, sporadic basis. As there are rampant power cuts in rural india – Nokia realized the benefit of having a torch built into a mobile phone and it’s 1100 model incorporates a torch.
Invention is the first occurrence of an idea for a new product or process while innovation is the first attempt to carry it out into practice, whether it leads to societal benefit, or commercialization . Inventions may be driven by technology, but Innovation is invariably driven by market. The innovative product E-Chaupal by ITC brought a lot of benefit to the farmer by direct procurement of agricultural produce, thus fetching farmers more correct and better prices.Tim Berners-Lee invented the World Wide Web. When applied to various unmet and anticipated needs of the marketplace, it brought about a complete paradigm shift in way things happen. It created a new universal space for information sharing, collaboration and commerce. On the contrary, clinical medicine is replete with inventions that never made it to the market place.
"Whether humans will embrace or resist an innovation is the billion-dollar question facing designers of novel products. Fortunes are made and lost on the answer" The answer lies in the market centric approach that companies should take – in fundamentally reshaping or adapting the underlying "inventive" product into a package that truly meets the need of the market"

Tuesday, October 27, 2009

Great Design (Vs) Optimal Design

This was the topic of another debate held at my company, and  here are some of my own thoughts on the topic.

Design As I understand is the process of developing a plan for a product, or a system. That process could be documented as a set of drawings, models or whatever. After the whole debate, it was still not clear to me what is a great design ? I think there are no "Great" designs on paper.

Eiffel tower was definitely "Designed to be great ", and it stood the test of time.. Columbia ( space shuttle ) was also "Designed to be great", but it was a disaster.Though both were designed to be great, everyone today would quote eiffel tower as an example of a great design, and columbia as that of a disastrous one.

The whole point is that design is only a means to an end (product) and until the product is out in the market and turns out (proven) to be great, you can not really judge whether the design of the product was great or not.

Probably another way to think about great design is to look @ it as being the "best design"
Tata "Nano" - a bad example for great design I suppose. No doubt it is a "Great" Idea or concept that Ratan Tata came up. Without the additional attribute of being a "cheap" car that suites the Indian roads, just look at it as a car in itself. It does not match up to the standards set in the car industry. How can we call it's design great or best ? But it is an "optimally" designed car for Indian market and Indian roads. Even to call it "great" for the Indian market, it is not on the Indian roads yet and not proven itself.

Talking of optimal designs.. For all practical purposes most commercial products are designed to be optimal for the current set of requirements (or) anticipated near future requirements and current needs of the people. Windows may be a good example. It is not the best operating system out in the market. it's products are never the best. But when they are released into the market, they are "greatly" optimized for the current needs of the society. That's why there is so much penetration & market share.

Products are optimized for use by a certain set of people (or) for particular domain (or) for a specific user experience (or) for use within a specific country. Optimization is the key ! From a business perspective, optimization can be looked at as the process of maximizing ( profits and efficiency) given a set of constraints. One main constraint for example can be time to market. It is important to reach the market before your competition does so.

As we design our products, we could optimally design them or design them to be the best but from my perspective if you go for the second option, it may take longer time and there is more risk involved.

Thursday, August 27, 2009

Builds and Clearcase...

Builds so far have been the biggest pain point --

Restore resouce...

The component that i am part of has multiple modules and i am responsible for coding for only one of the modules. When i do a build of the whole system, it builds all the modules and if one of the modules has problem the build fails. When one of the other modules was creating problem i deleted from my local system and commented those modules in pom.xml..... I forgot about it completely.

About 15 days later when i wanted to build the whole component i took an update of the code using clearcase remote client and then i tried building the code. But build was failing.... !!!

I was not able to figure out the issue for a long time.. but the solution was very simple -- My deleting the other modules code from local machine created discordance between the clearcase view and the clearcase webserver - I had to do a restore resource option in clearcase to clear the discordance. I was aware of such an option, but it either did not occur to me immediately or this is the first instance when i actually used it.

when I built now the build was successful....

more about restore @ https://publib.boulder.ibm.com/infocenter/cchelp/v7r1m0/index.jsp?topic=/com.ibm.rational.clearcase.ccrc.help.doc/topics/u_restore.htm

Thursday, August 20, 2009

Some interesting Stuff ( Ideas !!! )

1. Below listed is a product for indian agricultural market - a product that allows farmers to remotely switch off or on the power supply of motors and also helps them in monitoring motors - this has great application in rural india and the farmers need not walk long distances every day --

http://www.nanoganesh.com/html/Index.html

2. g-speak and g-stalk - check them out @ http ://oblong.com/article/08mMyyzpYMm7kFtv.html

3. Interesting east (vs) west comparison - http://www.slideshare.net/Robertc1970/east-vs-west-162816 - Also check out the poster section under http://www.yangliudesign.com/ and look at discover asia poster :-) Interesting !!

4. Common Sense Rules !!! - Fundooooooooooo idea - an idea that has a lot of application in all the rural places - http://www.qdrum.co.za/

5. Green Innovation - http://news.bbc.co.uk/2/hi/technology/7795492.stm

6. Quickies - http://www.pranavmistry.com/projects/quickies/

7. Gestural interface - look @ http://www.pranavmistry.com/projects/ and look for the six sense project.

More to be added to this list.....

Linux Commands & Related

How to find the command that started a process......

It's easy stuff (again). This was the first thing i tried in the morning - I got up, logged in to my comp, started putty and tried quite a few options to figure out how to do it -- googled it out too --

Example : lets say if i ran a command like "service testservice start" in linux and it started a java process. If i do a ps -ef in the command line it gives me all the java processes running in the system. Now given the pids of these processes is there a way for me to figure out what was which of the pids correspond to "service testservice start" --

well, i tried the following first :

ps -ww -fp
ps -o "%u : %U : %p : %a"
cat /proc/pid/cmdline
ps -aux

but none of them provided the actual solution -- looks like pargs in solaris gives the command directly - but how does it happen in linux ? I got this solution from a friend.

run ps -ef command - it gives the process id and also gives the parent id of the process - now run a "ps ppid" where ppid corresponds to the parent pid - that gives the solution to the problem.

This was to figure out a command that was starting a tomcat process - there are quite a few eurekas about tomcat itself .. will consolidate and put them up, hopefully :)
How to know who all are connected to linux machine and what they are doing :

Is there a way to find out who all are logged into the machine and what they are doing ?? If you are working on a machine that is shared by multiple people and want to know who all are using right now and what they are doing - is there a way ?

w command in linux provides the information. ( http://linux.about.com/library/cmd/blcmdl1_w.htm) Also wall command can be used to send a broadcast message.

List of installed rpm's :a couple of days back i was trying to find the command that provides the list of rpm's installed on a linux box - if you have yum repository in the machine, then the way to do it is : yum list installed would do the job for you.

rpm -qa provides all the information about the rpm's but does not provide the versioning information explicitly - i was looking for version information explicitly - with some help figured out that this is the way it works :

rpm -qa --queryformat "%-30{NAME} %10{DISTRIBUTION} %10{VERSION}\n"

Using netcat and tar for network file transfer

some easy file transfer

http://www.screenage.de/blog/2007/12/30/using-netcat-and-tar-for-network-file-transfer/


HashMap & Arbitary number of arguments in java...

It's simple stuff - HashMap

let's say there is a hashmap of strings in java and given a key you want to retrieve the corresponding value - i thought one could do it just by passing the string -- No it does not work that way -

since the get method takes only an object as a parameter - so typically the way to do would be to get all the keys from the hashmap and the iterate over the keys to get the corresponding values --

Arbitary Number of Arguments in Java

I saw a method with the following signature today - public List getXYZ(String... categories) - was wondering what String... means - it can be used to pass arbitary number of arguments in java - here is the explanation....

http://java.sun.com/docs/books/tutorial/java/javaOO/arguments.html