Welcome back to Software Development!
Reading Questions
Reading Questions What are scope modifiers (public/private)
Reading Questions What are scope modifiers (public/private) What are properties (Set/Get)?
Reading Questions What are scope modifiers (public/private) What are properties (Set/Get)? What is an instance (static and new)?
Reading Questions What are scope modifiers (public/private) What are properties (Set/Get)? What is an instance (static and new)? What are instance variables?
Reading Questions What are scope modifiers (public/private) What are properties (Set/Get)? What is an instance (static and new)? What are instance variables? What are filters?
Reading Questions What are scope modifiers (public/private) What are properties (Set/Get)? What is an instance (static and new)? What are instance variables? What are filters?
Reading Questions What are scope modifiers (public/private) What are properties (Set/Get)? What is an instance (static and new)? What are instance variables? What are filters?
Review – Class Members
Review – Class Members Methods
Review – Class Members Methods – class algorithms
Review – Class Members Methods – class algorithms The actual code that does the work – the ‘algorithm’
Review – Class Members Methods – class algorithms Fields The actual code that does the work – the ‘algorithm’ Fields
Review – Class Members Methods – class algorithms The actual code that does the work – the ‘algorithm’ Fields – class variables any method of the class can use
Review – Class Members Methods – class algorithms The actual code that does the work – the ‘algorithm’ Fields – class variables any method of the class can use What the book calls “instance variables”
Review – Class Members Methods – class algorithms The actual code that does the work – the ‘algorithm’ Fields – class variables any method of the class can use What the book calls “instance variables” The data or information the class uses to do its job
Review – Class Members Methods – class algorithms The actual code that does the work – the ‘algorithm’ Fields – class variables any method of the class can use What the book calls “instance variables” The data or information the class uses to do its job Properties
Review – Class Members Methods – class algorithms The actual code that does the work – the ‘algorithm’ Fields – class variables any method of the class can use What the book calls “instance variables” The data or information the class uses to do its job Properties – “smart fields”
Review – Class Members Methods – class algorithms The actual code that does the work – the ‘algorithm’ Fields – class variables any method of the class can use What the book calls “instance variables” The data or information the class uses to do its job Properties – “smart fields” Methods that look like fields…you can use them almost like variables
Review – Class Members Methods – class algorithms The actual code that does the work – the ‘algorithm’ Fields – class variables any method of the class can use What the book calls “instance variables” The data or information the class uses to do its job Properties – “smart fields” Methods that look like fields…you can use them almost like variables They “protect” the class variables (fields)
Review – Class Members Methods – class algorithms The actual code that does the work – the ‘algorithm’ Fields – class variables any method of the class can use What the book calls “instance variables” The data or information the class uses to do its job Properties – “smart fields” Methods that look like fields…you can use them almost like variables They “protect” the class variables (fields)
Review – Class Members Methods – class algorithms The actual code that does the work – the ‘algorithm’ Fields – class variables any method of the class can use What the book calls “instance variables” The data or information the class uses to do its job Properties – “smart fields” Methods that look like fields…you can use them almost like variables They “protect” the class variables (fields)
Scope Exercise
Scope Exercise Follow directions on the sheet
Scope Exercise Follow directions on the sheet You will get a compiler error
Scope Exercise Follow directions on the sheet You will get a compiler error There should only be one!
Scope Exercise Follow directions on the sheet You will get a compiler error There should only be one! It will be about the name ‘b’
Scope Exercise Follow directions on the sheet You will get a compiler error There should only be one! It will be about the name ‘b’ If you get something else, you typed the code in wrong
Scope Exercise Follow directions on the sheet You will get a compiler error There should only be one! It will be about the name ‘b’ If you get something else, you typed the code in wrong You have about 10 minutes…
Scope
Scope ‘Scope’ means the section of code a variable can be used in
Scope ‘Scope’ means the section of code a variable can be used in Defined by the current block
Scope ‘Scope’ means the section of code a variable can be used in Defined by the current block Blocks are marked by the immediate surrounding curly braces
Scope ‘Scope’ means the section of code a variable can be used in Defined by the current block Blocks are marked by the immediate surrounding curly braces Includes all inner blocks
Scope ‘Scope’ means the section of code a variable can be used in Defined by the current block Blocks are marked by the immediate surrounding curly braces Includes all inner blocks Question:
Scope ‘Scope’ means the section of code a variable can be used in Defined by the current block Blocks are marked by the immediate surrounding curly braces Includes all inner blocks Question: Can one method use a variable declared in another method?
Scope ‘Scope’ means the section of code a variable can be used in Defined by the current block Blocks are marked by the immediate surrounding curly braces Includes all inner blocks Question: Can one method use a variable declared in another method? No
Scope ‘Scope’ means the section of code a variable can be used in Defined by the current block Blocks are marked by the immediate surrounding curly braces Includes all inner blocks Question: Can one method use a variable declared in another method? No If we needed to be able to do this, how could we do it?
Scope ‘Scope’ means the section of code a variable can be used in Defined by the current block Blocks are marked by the immediate surrounding curly braces Includes all inner blocks Question: Can one method use a variable declared in another method? No If we needed to be able to do this, how could we do it? Fields
Scope Modifiers
Scope Modifiers public / private
Scope Modifiers public / private public:
Scope Modifiers public / private public: Info anyone can get to
Scope Modifiers public / private public: Info anyone can get to My name…
Scope Modifiers public / private public: private: Info anyone can get to My name… private:
Scope Modifiers public / private public: private: Info anyone can get to My name… private: “PB”… Private Business
Scope Modifiers public / private public: private: Info anyone can get to My name… private: “PB”… Private Business Info only select people can get to
Scope Modifiers public / private public: private: Info anyone can get to My name… private: “PB”… Private Business Info only select people can get to My social security number…
Scope Modifiers
Scope Modifiers They are now called access modifiers
Scope Modifiers They are now called access modifiers They control who can “access” the fields of a class.
Scope Modifiers They are now called access modifiers They control who can “access” the fields of a class. public:
Scope Modifiers They are now called access modifiers They control who can “access” the fields of a class. public: Any code with access to the class can read or change a public field!
Scope Modifiers They are now called access modifiers They control who can “access” the fields of a class. public: Any code with access to the class can read or change a public field! Very dangerous - rarely use this.
Scope Modifiers They are now called access modifiers They control who can “access” the fields of a class. public: Any code with access to the class can read or change a public field! Very dangerous - rarely use this. private:
Scope Modifiers They are now called access modifiers They control who can “access” the fields of a class. public: Any code with access to the class can read or change a public field! Very dangerous - rarely use this. private: Only members of the same class can read or change a private field. Example…
Scope Modifiers They are now called access modifiers They control who can “access” the fields of a class. public: Any code with access to the class can read or change a public field! Very dangerous - rarely use this. private: Only members of the same class can read or change a private field. If we shouldn’t use public, how to we safely let other code access our fields?
Scope Modifiers They are now called access modifiers They control who can “access” the fields of a class. public: Any code with access to the class can read or change a public field! Very dangerous - rarely use this. private: Only members of the same class can read or change a private field. If we shouldn’t use public, how to we safely let other code access our fields? Properties
Scope Modifiers They are now called access modifiers They control who can “access” the fields of a class. public: Any code with access to the class can read or change a public field! Very dangerous - rarely use this. private: Only members of the same class can read or change a private field. If we shouldn’t use public, how to we safely let other code access our fields? Properties – “smart fields” that control reading (Get) and changing (Set)