Welcome

Welcome to my blog.


I will be updating this blog with lecture notes and miscellaneous information for:

CSE 1030 : Winter Term
Prof. A. Eckford, Section-Z: MWF at 10:30 in R S137



Feel free to leave me a message or send me an e-mail at producap@yorku.ca.

Here is a link for MyMail, Hotmail, G-mail, and PRISM login.

On that note, you must have a PRISM account in order to write the lab tests.

If you have not created a PRISM account yet (e.g., if you received transfer credit for 1020), see the lab monitor in CSEB 1006 as soon as possible.

I will also leave the blog open to comments, etc. much like the CSE forums.

Thanks for visiting.

Phil.

Monday, February 4, 2008

CSE Lecture 4/FEB/08

Note: See the previous lectures notes for the majority of this lectures contents.

Defensive Copying and Privacy Leaks

Composition: external interference with the inner workings of the class are undersirable.

Aggregates: external changes are OK.

The method of Copy Constructors (previous lectures) is called defensive copying.

CSE Lecture 1/FEB/08

Collections

-A collection is an aggregate(or composition) in which more than one of each type is allowed.
-The number required is not known in advance.
e.g. Portfolio --> collection of Investments

-We have already seen HashMap from SingletonPerState

Collection Constructors

-Best way: create an empty collection object in the constructor.
-Also, provide a public add() method for loading objects into the collection. This method generally returns a boolean: false if it fails, true otherwise.

Collection Objects - 3 Types

Lists - objects in order, duplicates are OK
Sets - order does not matter, duplicates are not allowed.
Maps - objects are associated with keys.

See code for Portfolio

Iterators and Iterable

-Iterator and Iterable are interfaces.
-A class implementing an interface must implement all the methods specified in the interface exactly. This means the same return type, same name (case-sensitive), same number, order, and types of paramters.


--> MyClass implements MyInterface

public class MyClass implements MyInterface
{
.
.
.
}

The Iterator interface allows a method to take some action on each element in a collection. It contains a method that returns the collection's Iterator --> repackaging the collection for iterator operations.

See Rest of Portfolio code including getValue() method.