Sunday, December 10, 2006

Modern Object-Oriented Programming

The most popular object-oriented programming (OOP) languages of C++, Java and C# are very similar to each other and indeed to their progenitors of Smalltalk, Simula, Algol and C. Similarly, the programming skills employed are similar regardless of the development language that has been chosen. Each of the modern languages shares structured programming constructs like if-then-else, for-next loops, or equivalents, and so on, with each other and their older cousins. With each other they share constructs that can be used to build classes, employ polymorphism and specify type safety within the bounds of the domain-specific language (DSL) that extends the base language for the problem domain in which we are working.

That there are so many commonalities between the three modern languages is unsurprising since C++ was the first programming language to cohesively tie together object-oriented concepts and Java copied, sometimes insensitively, from C++. Without doubt C# is a copy of Java with a few extensions along the lines of syntactic sugar (eg. properties and indexers, perhaps itself a workaround for the absence of operator overloading). Even more telling is the fact that Java and C# betray their own origins by adopting the very features that they initially dropped from C++ and had previously been decried by the language designers as bad features. The features that were dropped from Java when otherwise copying C++ syntax include multiple inheritance, operator overloading and templates, otherwise known as generics. C# included operator overloading in its first incarnation as a throw-back to its supposed C++ lineage but copies the Java path, perhaps set by Smalltalk, in disallowing multiple inheritance and generics. These and other features have crept their way into Java and C# however it is arguable whether programmers are more productive, not withstanding the marketting of the respective sponsor organisations for each language.

The exploration of the details behind the key constructs of C++, the equivalent code in Java and C#, the extensions and omissions in those languages, and the revised C++ standard, i.e. C++0x and Technical Report 1 (TR1), following over a decade of stability, are beyond the scope of the present discussion. The points of note are that the languages are very similar and appear, at first glance, then second and third blush, to borrow insensitively from C++, clearly their motivation. Java differs quite markedly in some syntax while maintaining the same class flavour while the more-recent C# seems, to invoke evolutionary atavism, to be a throwback to C++ with a few enriching extensions. All three are, for all intents and purposes, equivalent for purpose of business programming, among others, and being general-purpose programming languages any one can in general implement with relative ease the same solution as in any of the other two.

The building blocks of complex software are groups of components that number several classes grouped together into a library, jar file or assembly. The opposing forces of decoupling and cohesion determine which classes and components to group together into a single unit of release. Robert Martin's Principles of Object-Oriented Design speaks of the Common Closure Principle (CCP) and Common Reuse Principle (CRP) for grouping classes together; the Dependency Inversion Principle (DIP) and Interface Segregation Principle (ISP) for classes to depend on abstractions and client-specific, or narrow, rather than fat interfaces.

Beyond design patterns at a higher level of abstraction one may speak of analysis patterns and enterprise patterns or more generally to speak of application and framework architecture. The elements of architecture include frameworks of reusable components that are idiomatic for each programming language so that C++, Java and C# libraries may be unique in design to take advantage of each language benefits. Examples include OpenGL and Open Scene Graph (OSG) in C++; Spring for Inversion of Control (IoC) or dependency injection in Java; COM+ and Enterprise Services in C#, the natural language of .NET. Other frameworks may be similar or identical for all of these, including Corba-IIOP, SOAP/SOA, ESB and Brokers at a high level; Hibernate persistence framework, xUnit test (i.e. CppUnit, JUnit and NUnit) and logging frameworks (i.e. log4cpp, log4j and log4net) at a lower level.

Similar to analysis patterns that transform into a myriad of design patterns, each of which can be implemented in any language and reflect the customary idiom, Corba-IIOP and DCE-RPC turn up as Corba in C++, RMI-IIOP in Java and .NET Remoting in C#.NET; message queuing WebSphere MQ, Java Message Queue (JMQ) and MSMQ are platform and language independent to a greater and lesser extent. By their nature, integration technologies need to span various technologies and platforms in order to serve their purpose. Adaptive Communications Environment (ACE), TAO Corba ORB (Object Request Broker) in C++; perhaps Internet Communications Engine (ICE) with bindings to these and other platforms is the most cohesive of all. The same can be said for transaction models that seem much alike from IBM CICS, BEA Tuxedo, Java EE, Microsoft MTS/COM+ and .NET Enterprise components.

The modern concept of an application server embodies many of these concepts in various combinations.

0 Comments:

Post a Comment

<< Home