Concepts & Terms Flashcards
Define
Immutability / mutability
Characteristic of reference objects. A ref variable is immutable if, when a second ref variable points to the first, a change to the second WILL NOT change the first.
Immutable objects are easy and inexpensive to copy, because copying only creates a pointer rather than a second object. In the example below, A isn’t changed even when pointer B is modified:
- String A = “Hello”;*
- String B = A;*
- B += “ there!”;*
- Print A, B*
Output:
Hello Hello there!
Define
Lambda expression
An in-line WHERE syntax for an anonymous delegate or method. Lambda expressions are used heavily in LINQ
var evens = Enumerable.Range(1, 100).Where(x => (x % 2) == 0) ToList();
See also: anonymous delegate
Define
Boxing / unboxing
Implicit conversion from one type to another.
foreach(int I in myCollection)
The above statement attempts to convert each object in the collection to an int in order to execute the code in the loop.
- Int x = 30; *
- Object obj = x;* // boxing
- Int y = (int)obj; *// unboxing
Define
MFC
Microsoft Foundation Class
C++ wrapper for the Windows API
Define
ASP Session State
Current progress or state of a user’s web application. While visiting a web site, a user may visit multiple pages and generate values for multiple variables. Maintaining these values while the application is used is maintaining session state.
Define
Singleton
Sole instance of a class. No other instances of that class are allowed (in theory). The singleton is a Design Pattern.
In C#, instantiating a static class achieves this, though there are other ways it can be done, too. For example, MSDN suggests creating a class that creates a single instance of itself, and provides public methods that allow access/reference to that instance. The constructor of that class would also be made private.
- Public class Singleton {*
- Private static Singleton instance;*
- Private Singleton() {}*
- Public static Singleton Instance {*
- Get { if(instance==null) Instance = new Singleton; }*
- Return instance; }*
- }*
Define
WPF
Windows Presentation Foundation .NET technology for rendering Windows applications via DirectX. Utilizes XAML
Define
Delegate
Wrapper for a single method. Allows the passing of a method as a parameter. This allows a single function (if it accepts a delegate) to filter the results depending on how it’s called, without having to hard code the filtering functionality.
Define
Inheritance
When object A inherits from B, A adopts the signature or functionality of B.
Interfaces : A must implement the signature of B, but the functionality of that signature is left up to A.
Objects : A gains the function the functionality of B.
Define
Overload
Provides different signatures for the same method.
- Employee(string Name) {…} *
- Employee(int EmployeeID) {…}*
Define
Type constraint
Associated with Generics; restricts the types the generic can accept when being instantiated. For example, Collection might only want to allow the collection to contain objects that implement the IEnumerable interface.
class Doc doc where T : IEnumerable {…}
Define
Thread Safety
The ability of an object (X) to be accessible to objects (A and B) from different threads, without compromising the functionality or data of X.
Define
Reference type
Variables of less well-defined types (when compared to value types). Stored on the heap. Copying a reference type creates a pointer to the original; changes to the original will be reflected in the copy.
Define
Thread
Functionality executed within a larger process (re. spell checking in MS Word).
Define
Tuple
An “array” containing objects of multiple types.
Where an array is made up of objects of the same type (ie. string), a tuple can contain several different types (ie. string, int, DataTable,etc). Tuples can be simulated by creating an array of Objects, but this violates type safety, making it hard for the developer to know what the array items actually are.
Tuple tuple = new Tuple (1, “cat”, true);