Stéphane Ducasse 1
Stéphane Ducasse
stephane.ducasse@inria.fr
http://stephane.ducasse.free.fr/
Elements of Design -
Class ...
S.Ducasse 2
Class Methods - Class InstanceVariables
Classes (Packet class) represents class (Packet).
Class instance varia...
S.Ducasse 3
Class Initialization
How do we know that all the class behavior has been
loaded?
At the end !
Automatically ca...
S.Ducasse 4
Example of class initialization
Magnitude subclass: #Date
instanceVariableNames: 'day year'
classVariableNames...
S.Ducasse 5
Date class>>initialize
Date class>>initialize
"Initialize class variables representing the names of the months...
S.Ducasse 5
Date class>>initialize
Date class>>initialize
"Initialize class variables representing the names of the months...
Upcoming SlideShare
Loading in...5
×

Stoop sed-class initialization

310

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
310
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Stoop sed-class initialization

  1. 1. Stéphane Ducasse 1 Stéphane Ducasse stephane.ducasse@inria.fr http://stephane.ducasse.free.fr/ Elements of Design - Class initialization Class initialization
  2. 2. S.Ducasse 2 Class Methods - Class InstanceVariables Classes (Packet class) represents class (Packet). Class instance variables are instance variables of class They should represent the state of class: number of created instances, number of messages sent, superclasses, subclasses.... Class methods represent class behavior: instance creation, class initialization, counting the number of instances.... If you weaken the second point: class state and behavior can be used to define common properties shared by all the instances
  3. 3. S.Ducasse 3 Class Initialization How do we know that all the class behavior has been loaded? At the end ! Automatically called by the system at load time or explicitly by the programmer. Used to initialize a classVariable, a pool dictionary or class instance variables. ‘Classname initialize’ at the end of the saved files in Squeak In postLoadAction: inVW
  4. 4. S.Ducasse 4 Example of class initialization Magnitude subclass: #Date instanceVariableNames: 'day year' classVariableNames: 'DaysInMonth FirstDayOfMonth MonthNames SecondsInDay WeekDayNames’
  5. 5. S.Ducasse 5 Date class>>initialize Date class>>initialize "Initialize class variables representing the names of the months and days and the number of seconds, days in each month, and first day of each month. " MonthNames := #(January February March April May June July August September October November December ). SecondsInDay := 24 * 60 * 60. DaysInMonth := #(31 28 31 30 31 30 31 31 30 31 30 31 ). FirstDayOfMonth := #(1 32 60 91 121 152 182 213 244 274 305 335 ). WeekDayNames := #(MondayTuesday WednesdayThursday Friday Saturday Sunday )
  6. 6. S.Ducasse 5 Date class>>initialize Date class>>initialize "Initialize class variables representing the names of the months and days and the number of seconds, days in each month, and first day of each month. " MonthNames := #(January February March April May June July August September October November December ). SecondsInDay := 24 * 60 * 60. DaysInMonth := #(31 28 31 30 31 30 31 31 30 31 30 31 ). FirstDayOfMonth := #(1 32 60 91 121 152 182 213 244 274 305 335 ). WeekDayNames := #(MondayTuesday WednesdayThursday Friday Saturday Sunday )
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×