Está en la página 1de 6

Table of Contents

History .................................................................................................................................... 2
Basic Principals ................................................................................................................... 2
Benefits .................................................................................................................................. 4
Missing Data Structures & Comparison with other language ............................. 5
New Data Structure Proposal ......................................................................................... 5
Conclusion ............................................................................................................................. 6
Bibliography ......................................................................................................................... 6



































History

Java is one of the most widely used programming languages in the world. The
TIOBE index ranked Java as the second most popular language after C.
Furthermore, Java is taught in many universities around the world.

The popularity of Java comes from its ease to understand syntax, portability,
garbage collection, efficiency, etc. One of the main, characteristics of the Java
Language is the integration of the Java Collections Framework.

Before Java Collections Framework was introduced (Zukowski 2001, p. 1), there
were only available basic data structures such as arrays, hash tables and vectors.
As a result, many developers use to create their own data structures libraries or
reuse existing ones. The framework was primarily developed by Joshua Bloch
and it was included in JDK 1.2 as the response from Sun Microsystem to the C++
Standard Template Library.

Oracle (2014) defines The Java collections framework as a unified architecture
for representing and manipulating collections, enabling collections to be
manipulated independently of implementation details. Collection can be used
to store, retrieve, and operate data. It includes interfaces (abstract data types),
implementation (implementations of the interfaces) and algorithms (such as
searching and sorting)

Other known Collections Frameworks are the C++ Standard Template Library
(STL) and the Smalltalks collection. However, Oracle (2014) argues that these
collections can be quite difficult to understand and use. Furthermore, the Java
Collections Framework tries to be an easier and elegant solution for the
manipulation of collections.

Sun Microsystems (Long 2010, p. 1) states that the goal of the Java Collections
Framework was to create an API that was small in size and conceptual weight.
It needs to be easy to use, seems familiar to developers and powerful.
Basic Principals

The Java Collections Framework was introduced in Java 1.2 to extend the current
data structures and algorithms available at that time such as Arrays, Vectors and
Hash Tables. Zukowski (2001, p. 118) indicates framework consists of four
interfaces and two implementations for sorting: Collections, List, Set, Map,
SortedSet and SortedMap. Refer to Figure 1.

Sun Microsystem (Long 2010, p. 1) does not consider Map and Sorted Map as an
extension of Collection as they represent mapping instead true Collections.
However, Long (2010) states that these Map and Sorted map are actually true
collection and it is backed up by Set Theory and Mathematicians.

Figure 1: Java Collections Framework

Oracle (2014) defines each part of the collection framework as follows:

1. Collections: This is the root of the Collection Framework. A collection
symbolises a group of objects. This interface is the less used as is more
generic. It serves as a blueprint to another interfaces that implements this
interface.
a. Set: A Set is a collection that cannot hold duplicate elements. It
comes from Set Theory.
i. Sorted Set: Its a Set that orders its elements in ascending
order by default.
b. List: This is an ordered collection where each element can be
accessed by an index.
c. Queue: A collection that holds its elements before manipulating
them. It follows a First In First Out (FIFO) principle. However,
developers can implement other versions of a Queue.
d. Deque: Similar to a Queue but it can be implemented as a Last In
First Out (LIFO)
e. Map: Its a collection that can hold a key value to its elements.
i. Sorted Map: A Map implementation is where its elements
are ordered in ascending order according to their key
values.

The classes that implement these core interfaces can be found in Figure 2. These
implementations have different properties that are defined by the interface that
they implement. For further information about these implementations refer to
the Java API.

Interface
Hash
Table
Resizable
Array
Balanced
Tree
Linked
List
Hash Table +
Linked List
Set
Hash
Set
TreeSet LinkedHashSet
List ArrayList LinkedList
Deque ArrayDeque LinkedList
Map
Hash
Map
TreeMap LinkedHashMap
Collection
Set
Sorted Set
List Queue Deque
Map
Sorted
Map
Figure 2: Classes that implement the Java Collection Interfaces.


Zukowski (2001, p. 119) indicates that some key features of the entire
Collections framework are:
All implementations are unsynchronized.
They provide iteration.
They are serializable and clonable.
They accept null elements.
If an implementation does not support a feature the interface throws an
UnsupportedOperationException.

Barker (2005, p. 879) states that Java 1.5 implemented great new features that
improved the Collection Framework. These new features allow developers to
reuse code, be more efficient and produce better quality software.

New features in Java 1.5:

Generics: Add compile-time type safety to the Framework. Now
developers can specify what type of Data the collection is intended to
contain when declared.
Improved for loop: Improved iteration through the collection.
Autoboxing/unboxing: Inserts primitives into the wrapper classes (such
as integers) when added to the collections.
Benefits

We can argue that the use of the Java Collections Framework has many benefits
for developers. For instance, Oracle (2014) states that the benefits of the
collection frameworks are to:

Reduce programming efforts by providing the most useful data structures
and algorithms.
Increase performance by providing a high performance implementation.
of the data structures and algorithms in the collection.
Provide interoperability between unrelated APIs.
Reduces the effort required to learn APIs by requiring you to learn
multiple ad hoc collection APIs.
Reduces the effort required to design and implement APIs by not
requiring you to produce ad hoc collections APIs.
Fosters software reuse by providing a standard interface for collections
and algorithms with which to manipulate them.

From my experience with the Java Collections Framework, I can argue that these
benefits that Oracle present are valid. Providing the most useful data structures
and algorithms is a great deal for saving time, as there is no longer need to
specify our own implementations. The Framework was implemented with
performance in mind. This allows running applications with speed comparable
to native compile languages for complex applications.

Furthermore, the learning curve for the Java Collections Framework is lower
than the STL for C++. For instance, when I was undertaking Computer
Programming 2, which was taught in C++, I had great difficulty understanding
the STL. However, when studying the Java Collections Framework in Application
Development the Data Structures and Algorithms are much easier to understand,
implement and test. This has made me a supporter of the Java architecture.

Meanwhile, Long (2010, p. 1) states that by using the Java Collections
Framework allows Java developers to be more productive when offering
applications that require the operation, programming of collections.
Missing Data Structures & Comparison with other language

The Java Collection Framework has many data structures that are not
implemented. For instance, some data structures are not available in the
Framework include bags, graphs, tries, multiSet, multiMap, binary trees, binary
search trees, heap, etc., to name a few.

All modern programing languages provide implementations for data structures
and algorithms. For instance, C++ has the Standard Library Template, Python has
Collections. All of this implementation of the data structures and algorithms vary
in performance, complexity usability depending in how the data structures and
algorithms are implemented.

For instance, Zukowski (2001, p. 118) states that while the purpose of the Java
Collections Framework and the C++ STL is similar: to deliver a standard library
for collection classes with their particular languages. The two libraries are
implemented in entirely different ways. The Java framework was intended to be
small, easy to use and easy to understand, with approximately twenty-five
diverse classes and interfaces. STL offers more than 100 implementations. Even
though, you can argue that you can do more with STL, the learning curve is huge
and developers may not be as productive. The Java Collections Framework is
easier to get underway and become productive.
New Data Structure Proposal

For this assignment I would like to propose Bags as new data structure to the
Java Collection Framework.

Bags are collections were its items are not allowed to be removed and items can
be duplicates (Sedgewick & Wayne 2011, p . 124). The purpose of Bags is to
provide a data structure with the ability to collect items and iterate through
them. In addition, the order of the items is not important.

To specify a Bag data structure into the Collections Framework, Oracle (2014)
states in the Java API that a Bag should implement the Collection interface
directly. The basic implementation of this new data structure will support the
following methods: add(), size(), isEmpty() and provide iteration().
Conclusion

The Java Collections Framework was introduced in Java 1.2 to add support to the
most used data structures. It was improved in Java version 1.5 with the addition
of generics, which allows you to specify the data type of the collection when its
declared.

The Java Collection Framework is widely used in the developers community as it
provides a high performance, light way and small functionalities to manipulate
data.

Java is one of the most used programming languages in the world and with the
easy use and capabilities of the Collection Framework it makes an easy choice for
developers to create complex applications.
Bibliography

Barker, J 2005, Beginning Java objects from concepts to code, 2nd edn, Apress,
Berkeley, California.

Long, B 2010 Towards the design of a set-based Java collections framework, ACM
SIGSOFT Software Engineering Notes, vol. 35, no. 5, pp. 1-7.

Oracle 2014, Java Collections Framework Documentation, viewed 4 June 2014,
<http://docs.oracle.com/javase/7/docs/technotes/guides/collections/>

Oracle 2014, The Java Tutorials: Introduction to Collections, viewed 4 June 2014,
<http://docs.oracle.com/javase/tutorial/collections/intro/index.html>

Oracle 2014, The Java Tutorials: Interfaces, viewed 4 June 2014,
<http://docs.oracle.com/javase/tutorial/collections/interfaces/index.html>

Oracle 2014, Java API: Interface Collection, viewed 4 June 2014,
<http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html>

Sedgewick, R & Wayne, K 2011, Algorithms, 4
th
edn, Addison-Wesley, Pearson,
Boston

Zukowski, J & Springerlink 2001, Java Collections, Apress, Berkeley, CA.

También podría gustarte