Save
Busy. Please wait.
Log in with Clever
or

show password
Forgot Password?

Don't have an account?  Sign up 
Sign up using Clever
or

Username is available taken
show password


Make sure to remember your password. If you forget it there is no way for StudyStack to send you a reset link. You would need to create a new account.
Your email address is only used to allow you to reset your password. See our Privacy Policy and Terms of Service.


Already a StudyStack user? Log In

Reset Password
Enter the associated with your account, and we'll email you a link to reset your password.
focusNode
Didn't know it?
click below
 
Knew it?
click below
Don't Know
Remaining cards (0)
Know
0:00
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.

  Normal Size     Small Size show me how

Chapter 10

Classes and Objects: A Deeper Look

TermDefinition
Composition A capability that allows a class to have references to objects of other classes as members. The concept that a class can have references to objects of other classes as members. Sometimes called a has-a relationship
Overloaded Constructors Enable objects of a class to be conveniently initialized in different ways. To overload constructors, simply provide multiple constructor declarations with different signatures
1. Constructor Initializer Following the constructor header with the constructor initializer : this (args) invokes the matching overloaded constructor in the same class. Ex: public Time2(Time2 time)... : this(time.Hour, time.Minute, time.second){}
2. Constructor Initializer. Constructor initializers are a popular way to reuse initialization code provided by one of the class's constructors rather than defining similar code in another constructor's body. Every object can access a reference to itself with keyword this
Using Properties When implementing a method of a class, using the class's properties to access the class's private data simplifies code maintenance and reduces the likelihood of errors
Resource Leak When all the references to the object that manages the resource are lost before the resource is explicitly released. When this happens, the app can no longer access the resource to release it
Garbage Collection The Common Language Runtime(CLR) performs automatic memory management by using a garbage collector to reclaim the memory occupied by objects that are no long in use, so the memory can be used for other objects
1. Destructors When there are no more references to an object, the object becomes eligible for destruction.
2. Destructors Every object has a special member, called a destructor, that's invoked by garbage collector to perform termination housekeeping on an object before the garbage collector reclaims the object's memory
Declaring a Constructor A destructor is declared like a parameterless constructor, except that its name is the class name, preceded by a tilde(~), and it has no access modifier in its header.
Eligible for Garbage Collection After the garbage collector calls the object's destructor, the object becomes eligible for garbage collection. The memory for such an object can be reclaimed by the garbage collector
static Variable Used in such cases where only one copy of a particular variable should be shared by all objects of a class. A static variable represents classwide information. The declaration of a static variable begins with the keyword static
Classwide Information When all objects of the class share the same piece of data.
Immutable Cannot be modified after they're created. string objects in C# are immutable
Principle of Least Privilege States that code should be granted the amount of privilege and access needed to accomplish its designated task, but no more. This principle is fundamental to good software engineering
1. readonly C# provides keyword readonly to specify that an instance variable of an object is not modifiable and that any attempt to modify it after the object is constructed is an error.
2. readonly Ex: private readonly int INCREMENT;... declares readonly instance variable INCREMENT of type int. Readonly variables are declared with all capital letters by convention. Readonly variables should be initialized by each of the class's constructors
3. readonly Declaring an instance variable as readonly helps enforce the principle of least privilege. If an instance varible should not be modified after the object is constructed, declare it to be readonly to prevent modification
Information Hiding When a class hides the details of their implementation from their clients
Data Abstraction The concept that the client cares about what functionality a class offers, not about how that functionality is implemented.
Abstract Data Types(ADTs) Captures two notions: a data representation and the operations that can be performed on that data
Queue Abstract Data Type Another ADT is a queue, which is similar to a "waiting line". Clients place items in a queue one at a time via an enqueue operation, then retrieve them one at a time via a dequeue operation. A queue returns items in first-int, first-out(FIFO) order
First-In, First-Out(FIFO) Order The first item inserted in a queue is the first removed
Visual Studio Class View Displays the fields, methods, and properties for all classes in a project
Visual Studio Object Browser Lists all classes in the .NET library. You can use the Object Browser to learn about the functionality provided by a specific class
1. Object Initiallzers Allow you to create an object and initialize its public properties(and public instance variables, if any) in the same statement.
2. Object Initiallzers Can be useful when class doesn't provide appropriate constructor to meet your needs, but does provide properties that you can use to manipulate the class's data. Ex: Time2 atime = new Time2 {Hour = 14, Minute = 30, Second = 12};
ToString Method An object's ToString method can be called implicitly when an object appears in code where a string is needed
Public Services, Public Interfaces The public members of a class
Created by: TimC#Programming
Popular Engineering sets

 

 



Voices

Use these flashcards to help memorize information. Look at the large card and try to recall what is on the other side. Then click the card to flip it. If you knew the answer, click the green Know box. Otherwise, click the red Don't know box.

When you've placed seven or more cards in the Don't know box, click "retry" to try those cards again.

If you've accidentally put the card in the wrong box, just click on the card to take it out of the box.

You can also use your keyboard to move the cards as follows:

If you are logged in to your account, this website will remember which cards you know and don't know so that they are in the same box the next time you log in.

When you need a break, try one of the other activities listed below the flashcards like Matching, Snowman, or Hungry Bug. Although it may feel like you're playing a game, your brain is still making more connections with the information to help you out.

To see how well you know the information, try the Quiz or Test activity.

Pass complete!
"Know" box contains:
Time elapsed:
Retries:
restart all cards