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.

Thursday, January 31, 2008

CSE Lecture 30/JAN/2008

Aggregation

-An aggregate is a class where some of the attributes are themselves objects.
-If all attributes are primitive, the class is not an aggregate.

e.g. public class BankProducts
{
private BankAccount savings;
private BankAccount chequing;
private Loan homeMortgage;
private Loan lineOfCredit;

}

- a composition is an aggregation in which the objects inside the class "live and die" with the object. In effect, it is created when the object is created and destroyed when the object is destroyed.

Aggregate: only holds references to external objects. These objects exist apart from the aggregate.

Composition: locally creates its own objects. Objects are only relevant to the object holding them.

External forces can generally change the value of an object in an aggregate. This is good for an aggregate, bad for a composition.

We don't want external forces messing with the internal structure of a composition.

Aggregate Constructors

-Aggregates keep references to external objects. They don't generally make local copies.

e.g. public class Investment
{

public class Investment(Stock s, int num)
{
this.s = s;
this.num = num;
}

}

Composition Constructor

-Objects in a composition reflect the internal workings of an object.

-Local versions, not accessible from the outside, should be kept.
-Extends the concept of private access type.

public class CompositionWithStock
{

private Stock s;
Public ComparisonWithStock(Stock s, int num)
{ //create a local copy of s and store it
this.s = new Stock(s);
this.num = num
}

No comments: