Logout

Home OOP Option Last Next

D.2.7

Describe the advantages of libraries of objects.

 

Teaching Note:

For example, sorts and other complex algorithms and processes do not have to be “re-invented”.

 

Sample Question:

----

Q1. Describe how the use of libraries can facilitate the development of programs like this company’s administration program.

----

Q2. Outline one advantage of using standard library collections.

----

sdfsdfsf

JSR Notes:

The Long Way...

We could create our own way of doing all sorts of things, even things as common - but ultimately complex - as printing a line of code. But for this example, it is obviously much easier to use the pre-made println( ) method of the out object of the System class. Likewise we could create our own way to read or write, and buffer to speed up the process, but we choose to use BufferedReader and BufferedWriter, or perhaps Scanner.

Or The Short Way...

"Libraries" like these examples are groups of code which has been made by others, and are now available for us to use, or in the case of the library analogy, to "borrow". And it's not just common tasks such as printing to the screen or taking keyboard input. There are also freely available classes to do common and complex algorithms. So, for example, there is no need to code your own selection sort, or binary search tree etc.

It's important to make your own such algorithms for learning purposes, so that you intimately know how they work, but once you get out in the "real world", you need to be the most efficient you can be, and use pre-made classes and algorithms like the ones mentioned here.

In fact, we use "libraries" every time we use import in our code - usually though a right-click, and import this or that (as with BufferedReader, or Scanner).

Third Party Libraries

When we think of using libraries, sure, we are using libraries that come with Java, such as Scanner, but that's not all. Rather, it is other libraries not necessarily made by the folks at Sun when they developed Java, but libraries that were made by "third parties", whether companies or individuals. As the teaching note alludes to, there are lots of sorts out there, not just one or a handful, that we can just import and use.

You'll note that focus soon will be our use of pre-programmed "Collections" classes which offer specific implementations of "Abstract Data Types", such as "linked lists" and "binary trees". All of which we could have coded ourselves, but there's no need to bother since others have already made them and allow them to be used.

Libraries of Classes

Just one terminology note to end on; the assessment statement talks of libraries of "objects", but it's better to talk of libraries of "classes". We will usually import the classes, and make individual object instances from those library classes.

 

In Summary, Back to the Assessment Statement:
Describe the advantages of libraries of objects.

Library programs are programs that have already been written, and are likely to be able to be reused in other projects. Development time will be saved since, not only are they alrady developed, but they are tested, and bug-free.