Logout

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:

sdfsdfsf

JSR Notes:

 

We could create our own way of doing all sorts of things, even things as common as printing a line of code. Much easier to use the pre-made println() method of the out object of the System class. Or we could create our own way to read or write, and buffer in the process to speed up efficiencies, but we choose to use BufferedReader and BufferedWriter.

"Libraries" are groups of code which has been done by others, and is now available for you to use, or in the case of the library analogy, to "borrow". So there is no need to code your own selection sort, or binary search tree etc. It's nice to make your own for learning purposes, and so that you intimately know how they work, but once you get out in the "real world", rather than in an educational setting, you might as well be the most efficient you can be and use pre-made classes and algorithms like the ones mentioned here.)

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

 

When we think of using libraries, sure, we are using libraries that come with Java, such as BufferedReader, but that's not all. Rather it is other libraries not necessarily made by the folks at Sun when they developed Java, but other libraries that were made by "third parties", whether companies or individuals. As the teaching note notes, there are lots of sorts out there that we can just import and use. We will be using "Collections" classes which offer specific implementations of "Abstract Data Types", such as "linked lists" and "binary trees". All of which we can code ourselves, but why bother, when others have already made them and allow others to use them.

So looking at the assessment statement, these are really libraries of "classes", not of "objects". We will import the classes, and make individual object instances from those library classes.