background preloader

Object Oriented Programming

Facebook Twitter

Home - Enterprise Integration Patterns. Introduction to the Dependency Mechanism. Dependency management is one of the features of Maven that is best known to users and is one of the areas where Maven excels.

Introduction to the Dependency Mechanism

There is not much difficulty in managing dependencies for a single a project, but when you start getting into dealing with multi-module projects and applications that consist of tens or hundreds of modules this is where Maven can help you a great deal in maintaining a high degree of control and stability. Transitive Dependencies Transitive dependencies are a new feature in Maven 2.0. This allows you to avoid needing to discover and specify the libraries that your own dependencies require, and including them automatically. This feature is facilitated by reading the project files of your dependencies from the remote repositories specified. There is no limit to the number of levels that dependencies can be gathered from, and will only cause a problem if a cyclic dependency is discovered. Dependency Scope There are 6 scopes available: Dependency Management Project A: Inversion of Control Containers and the Dependency Injection pattern.

In the Java community there's been a rush of lightweight containers that help to assemble components from different projects into a cohesive application.

Inversion of Control Containers and the Dependency Injection pattern

Underlying these containers is a common pattern to how they perform the wiring, a concept they refer under the very generic name of "Inversion of Control". In this article I dig into how this pattern works, under the more specific name of "Dependency Injection", and contrast it with the Service Locator alternative. The choice between them is less important than the principle of separating configuration from use.

One of the entertaining things about the enterprise Java world is the huge amount of activity in building alternatives to the mainstream J2EE technologies, much of it happening in open source. A lot of this is a reaction to the heavyweight complexity in the mainstream J2EE world, but much of it is also exploring alternatives and coming up with creative ideas. Components and Services A Naive Example class MovieLister... How to Write an Equality Method in Java. How to Write an Equality Method in Javaby Martin Odersky, Lex Spoon, and Bill VennersJune 1, 2009 Summary This article describes a technique for overriding the equals method that preserves the contract of equals even when subclassses of concrete classes add new fields.

How to Write an Equality Method in Java

In Item 8 of Effective Java1, Josh Bloch describes the difficulty of preserving the equals contract when subclassing as a “fundamental problem of equivalence relations in object-oriented languages.” Bloch writes: There is no way to extend an instantiable class and add a value component while preserving the equals contract, unless you are willing to forgo the benefits of object-oriented abstraction. Chapter 28 of Programming in Scala shows an approach that allows subclasses to extend an instantiable class, add a value component, and nevertheless preserve the equals contract.

Class java.lang.Object defines an equals method, which subclasses may override. These four pitfalls are discussed in the remainder of this section. 1. 2. Meyer. Design Patterns: Elements of Reusable Object-Oriented Software: Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides: 0785342633610: Amazon.com. Patterns of Enterprise Application Architecture: Martin Fowler: 9780321127426: Amazon.com.

Amazon.