vendredi 22 février 2008

Veille technologique semaine 8


Pour le point technologique de cette semaine, je vous propose les articles suivants :
  • Toshiba arrêt le HD DVD
  • Blu-ray Disc Java : Java et le Blu Ray : BD - J.
  • la deuxième partie du cours UML 2 avec la notion de composant : pourquoi faire des composants ?
  • un article sur les Domain Specific Language (DSL) : la définition de Marin Fowler et son application avec Java, Groovy et Ruby. On trouve des applications dans JUnit 4.4 pour les assertThat(), dans JMock avec les Expectactions() et le meilleur (pour Java) étant Quaere, une implémentation Java d'un langage de requête à la LINQ de C#.
  • La gestion des interruptions sur les thread Java.
Bonne lecture.


Toshiba Announces Discontinuation of HD DVD Businesses
Toshiba Corporation today announced that it has undertaken a thorough review of
its overall strategy for HD DVD and has decided it will no longer develop, manufacture and
market HD DVD players and recorders.

DVD Blu Ray et Java : BD - J
DVD is about to be replaced by a new format promising far better audio and HDTV video, far greater storage, and an exciting interactivity platform powered by the same Java Platform, Micro Edition (Java ME) technologies already widely deployed for MHP and OCAP digital TV devices. Blu-ray is backed by most of the major consumer electronics companies, PC vendors, and movie studios and promises to have as great an impact on consumers' movie viewing habits as VCRs and DVD players did.
Whereas HD-DVD used ECMAScript for programming interactivity, Blu-ray uses Java. Thus, Java ended up being an integral part of next generation home video.
In the video, Deep Dive: Blu-ray Disc Java, An Interview With Bill Foote, Sun's Blue-ray Disk Java architect explains how Java facilitates the interactivity of Blue-ray Disks, and walk you through a sample application.

Diagrammes de composants
Pourquoi des composants ?
Parmi tous les facteurs qui concourent à la qualité d'un logiciel, nous avons introduit la notion de réutilisabilité comme étant l'aptitude d'un logiciel à être réutilisé, en tout ou en partie, dans de nouvelles applications. Or, la notion de classe, de part sa faible granularité et ses connexions figées (les associations avec les autres classes matérialisent des liens structurels), ne constitue pas une réponse adaptée à la problématique de la réutilisation.
Pour faire face à ce problème, les notions de patrons et de canevas d'applications ont percé dans les années 1990 pour ensuite laisser la place à un concept plus générique et fédérateur :
celui de composant.
La programmation par composants constitue une évolution technologique soutenue par de nombreuses plateformes (composants EJB, CORBA, .Net, WSDL, . . .). Ce type de programmaiton met l'accent sur la réutilisation du composant et l'indépendance de son évolution vis-à-vis des applications qui l'utilisent.
La programmation orientée composant s'intègre très bien dans le contexte de la programmation
orientée objet puisqu'il ne s'agit, finalement, que d'un facteur d'échelle.
En effet, l'utilisation de composants est assimilable à une approche objet, non pas au niveau du code, mais au niveau de l'architecture générale du logiciel.


Domain Specific Language: DLS by Martin Fowler
The basic idea of a domain specific language (DSL) is a computer language that's
targeted to a particular kind of problem, rather than a general purpose language that's
aimed at any kind of software problem.

An Approach to Internal Domain-Specific Languages in Java
Introduction
A domain-specific language (DSL) is commonly described as a computer language targeted at a particular kind of problem and it is not planned to solve problems outside of its domain. DSLs have been formally studied for many years. Until recently, however, internal DSLs have been written into programs only as a happy accident by programmers simply trying to solve their problems in the most readable and concise way possible. Lately, with
the advent of Ruby and other dynamic languages, there has been a growing interest in DSLs amongst programmers. These loosely structured languages offer an approach to DSLs which allow a minimum of grammar and therefore the most direct representation of a particular language.
However, discarding the compiler and the ability to use the most powerful modern IDEs such as Eclipse is a definite disadvantage with this approach. The authors have successfully compromised between the two approaches, and will argue that is quite possible and helpful to approach API design from the DSL orientation in a structured language such as Java. This article describes how it is possible to write domain-specific languages using the Java language and suggests some patterns for constructing them.


Quaere: LINQ Arrives for Java
Lists the features of Quaere:
  • Ability to perform queries against arrays or data structure implementing the Iterable interface.
  • An internal DSL (based on static imports and fluent interfaces) that lets you integrate the query language with regular Java code. No preprocessing or code generation steps are required to use the DSL, simply add a reference to the quaere.jar file (and its dependencies).
  • A large number of querying operators including restriction, selection, projection, set, partitioning, grouping, ordering, quantification, aggregation and conversion operators.
  • Support for lambda expressions.
  • The ability to dynamically define and instantiate anonymous classes.
  • Many new "keywords" for Java 1.5 and later.


Creating Domain Specific Languages with Groovy
Venkat's session provided information about what DSLs are, there characteristics, the types of DSLs (internal vs. external), as well as, the Groovy features for creating and using them. Venkat primarily focused on creating internal DSLs using some of Groovy's built-in features:


Building Domain-Specific Languages in JRuby
Closing out the Java One conference last week was Rob Harrop's presentation "Exploiting JRuby: Building Domain-Specific Languages for the Java Virtual Machine." Domain specific languages (DSLs) have been gaining popularity, as shown on InfoQ with a presentation on an introduction to domain specific languages by Martin Fowler and posts on the debates in the blogsphere, and provide a way to create a custom language for a specific programming or business purpose.




Thread.interrupt()
As it stands, and has been said, stopping threads dead in their tracks was deprecated as it potentially leads to severe problems, the most prevalent being deadlocking. And I concur that the first suggestion is a textbook example of how not to attack this problem.


There is a fairly recent package giving advanced features to deal with concurrency, namely java.util.concurrent and its subpackages. There are far better books and articles out there than I could possibly put together. But it is also a quite advanced topic, and you're perhaps not ready to go there.


Thread.interrupt() is a powerful tool. This works if your thread is blocked on an interruptible operation like Object.wait(). But the easiest way remains to build your libraries/application so that it is easily interruptible. Consider the following (contrived) example:


void copy(Collection source, Collection destination) {
for
(Object o : source) {
if
(Thread.isInterrupted()) break;
destination.add(o);
} }

However, if your thread is blocked on a non-interruptible operation, then there is typically nothing you can do. Perhaps another thread can unblock you by, say, closing a stream you're reading from if the stream so allows. But usually, it's out of your hands.

So, basically, if the code you invoke is not built to handle interruptions, there's nothing you can do about it. Think about this when you go about writing potentially blocking code of your own.
Hope this clears things up for you, Jonathan

PS: The java.nio package supplies classes to work with non-blocking I/O. If you're trying to interrupt a blocking read from an inputstream, consider checking out channels; those can be configured not to block.

Aucun commentaire: