Craig’s Musings

Thoughts about software architecture, books and life

...nature speaks...

Dual citizenship and object identity

July 10th, 2005 · 1 Comment · Non-fiction, Random

After finishing The World Is Flat, I picked up Winning The Future: A 21st Century Contract with America by Newt Gingrich, which I received for Father’s Day. (More on The World Is Flat in a separate post–excellent book on timely subject matter!)

I haven’t yet finished Mr. Gingrich’s book about a 21st century contract with America, but Winning The Future: A 21st Century Contract with America is a thought-provoking read. It’s not as substantial as some of the other books I’ve read recently (e.g. The World Is Flat, Men in Black), but it does offer new connections for the more detailed coverage these other books present (e.g. (threat #4) “America’s economic supremacy will yield to China and India because of failing schools and weakening scientific and technological leadership”, the historic balance of our three branches of government–that two branches combined (e.g. legislative and executive) can reign in the third branch (judicial), etc.).

In “Patriotic Immigration” Mr. Gingrich raises the subject of dual citizenship as “one of the most insidious assaults on American exceptionalism.”

Before I continue, I should state up front that I have a brother-in-law who is a dual citizen. He’s just as patriotic as I am. After passing all requirements and becoming a citizen, when he “interviewed” mutual family members, it was clear that in some cases, he knew more facts about America than some of those born in this country. So, up to reading this chapter, I really haven’t viewed dual citizenship in a bad light–I’m not certain that I do now either.

However, when taken to a logical end, dual citizenship can create a detrimental tension between two national, geographical, culture, ideal–identity–concerns. This reminds me of my own brief, prior post about absolutes versus relativism. On the surface, dual citizenship appears harmless, but when pressed all the way to the wall, it may yield an undesirable, if not unacceptable, result.

For whatever reason–probably because of my profession as a software architect–this got me to thinking about object identity. Java, C# and other languages have done away with the potential nightmare of multiple implementation inheritance supported by C++. However these languages prominently support multiple interface inheritance, which still has the potential for creating tenuous object identity. That is, if FooBar implements IFoo and IBar, is a FooBar object’s existence truly independent of its value? Of course, this depends on the function of IFoo and IBar, but my observation is that there are no formal checks in Java or C# to prevent a condition of “dual citizenship” in FooBar. And in the end, FooBar is conflicted, which will force the software above to accommodate, defend against, isolate, coax, placate, attack or ignore (at its peril) the inherent conflict.

Clearly, I’m “in process” on this connection. Thoughts?

Update 12/1/2008: For more of my book reviews and to see what else is in my book library (i.e. just the business-related or software-related non-fiction therein), please visit my Books page.

-Craig
http://craigrandall.net/
@craigsmusings

Tags:

One Comment so far ↓

  • ErikThomas

    Hey Craig:

    Just to defend C++ in a small way, with regard to your “Dual Citizenship” musings–specifically to the “nightmare” of C++ multiple inheritance, I guess that as with anything powerful, one must exercise care when using it. Multiple inheritance in C++, when done correctly is a very elegant OO approach to solving complex problems, but one must exercise the discipline to inherit only pure virtual interfaces. There are several useful design patterns (including Adapter and Stairway To Heaven) that are nicely implemented using multiple inheritance in C++, and there are no major weaknesses in doing it unless you let a 3 year old try it.

    Of course few (if any) experienced C++ developers condone multiple inheritence of implementation, so we agree on that, but we also know that it isn’t needed. Good C++ uses multiple inheritance exactly as Java inherits multiple interfaces. The only (mostly symbolic) difference is that in Java, you use the “interface” keyword which puts cops in your own backyard to prevent adding implementation, whereas in C++, you use pure virtual functions, and refrain from adding any implementation by using personal and organizational discipline. I don’t really see the difference as enough to demonize C++, but that’s just my opinion, and we all know what opinions are like. ;O)

    Of course I sympathize from an organizational point of view why it is beneficial to move away from such a dangerous and complex language as C++ so that we can protect ourselves from misuse of powerful tools, and protect ourselves from lazy or inept developers, and move software development down the continuum towards unskilled (or low-skilled) labor that is more cost effective, e.g., third world Nike shops, etc.

    But I am a hold-out and a hopeless romantic. I want to experience the same sense of satisfaction that an author, painter, or musician experiences when s/he completes a work of art using a very unstructured medium. I will always resist the attempt by MBA mentality to “dumb down” software development to maximize shareholder wealth, because I believe a really good C++ developer can implement great object-oriented designs that comply with all the Agile principles, though it is harder to do and requires a greater level of expertise.

    On the other hand, if I was a language designer, I might take your point of view, because we could (potentially) design languages that prevent the pitfalls of multiple inheritence, mainly because it would be fun to do.

    But when we apply ISP to segregate sets of interfaces that leverage a single implementation but serve multiple clients with slightly different needs, multiple inheritence of pure virtual interface classes using C++ can be a very elegant solution, as can Java or C# using multiple interface inheritence.

    Let me ask you, if C#, Java, and C++ did not allow inheriting more than a single interface, how would you apply the Agile ISP? Is ISP a good or bad principle, or perhaps exists because of the limitations inherent in current mainstream OO languages?

    Just some musings of my own. Thanks for listening, and be gentle in your response! :O)

    Now that I’m back to C++ development I’m kind of charged up by how free I feel and how equipped I am to exceed expectations by applying some of the best lessons I learned from 4 years of Java development–and my newfound interest in Agile principles and some cool new (to me) design patterns–to some pretty challenging legacy C++ code. Incidentally, I just love some of Robert Martin’s C++ examples and I’d almost forgotten how useful destructors are are managing resources!

    Erik

You must log in to post a comment.