Lesson 2 Flashcards
objects
self-contained data structures that consist of properties, methods, and events. Properties specify the data represented by an object (adjective), methods specify an object’s behavior (actions or verbs), and events provide communication between objects.
encapsulation
Hiding the complexity of code inside something.
class (context of object oriented programming)
a class is like the template from which individual objects are created.
another name for object:
instance of a class
method
code blocks containing a series of statements
constructors
used to initialize the data members of the object.
How are objects created?
From the templates defined by classes.
What is the use of properties?
Allow you to access class data in a safe and flexible way.
access modifier
specifies what region of the code will have access to a field.
method’s signature
a method’s name, its parameter list, and the order of data types of the parameters. A method’s signature must be unique within a class.
default constructor
a constructor that takes no arguments
What is the method line format?
access level - return type - method name - parameters in parentheses - followed by a block of code in curly braces.
What are properties?
class members that can be accessed like data fields, but contain code like a method.
types of accessors:
get - used to return the property value.
set - used to assign a new value to the property.
When defining properties, a missing set accessor causes what?
You don’t provide a way to set the value of the property, and it becomes read-only as a result.
When defining properties, a missing get accessor causes what?
You don’t provide a way to get the value of the property, and it becomes write-only as a result.
auto-implemented properties
simplify property declarations
“this” keyword use
accesses members from within constructors, instance methods, and accessors of instance properties.
delegates
special types that are used to encapsulate a method with a specific signature. They’re like an agreement or a contract between a publisher and a subscriber. It determines the signature of the event handler method in the subscriber.
events
a way for a class to notify other classes or objects when something of interest happens.
publisher
the class which sends the notification to the subscriber during an event.
subscriber
the class which receives the notification from the publisher during an event.
two pieces of information needed when defining events:
a delegate that connects the event with its handler method(s), and a class that contains the event data. (Usually derived from the EventArgs class)
What is the purpose of a namespace?
It allows you to organize code and create unique class names.