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 28/JAN/2008

Singleton-per-state

--> state attribute for a class(int)
---> only one object is allowed for each state. e.g. process information for each process in a UNIX environment.


Aside

HashMap

-A way of storing objects with respect to a key (i.e. an integer)

Objects: a,b,c
HashMap: h

h.put(a, 100) places the object a with the key 100.

-Say I want to store objects of type MyObject with respect to integers.

-HashMap h = new HashMap();

Singleton-per-state design pattern.

-constructor is private
-private static HashMap stores the instances with respect to status.
-getInstance(int state) is a public static method which checks the HashMap for an instance corresponding to state. If it exists, it is returned, if not, store it in HashMap, return it.

You cannot access non-static attributes from a static method.

No comments: