General Flashcards
What is a method vs. a function?
A function is a piece of code that is called by name. All information in a function is explicitly passed to it.
A method is a function that is associated with an object. In addition to whatever is passed to it, it can access members of that object.
What is locality of reference?
It deals with the same storage locations being frequently accessed. Two main types: spatial and temporal.
Temporal: Once an address has been referenced, it is likely to be reference again soon. Think caching.
Spatial: Addresses near an address that was referenced might also be likely to be referenced. Think traversing an array.
Describe the differences between an Interface and an Abstract Class
An interface declares a set of related methods (an API) outside of any class. Very useful for languages without multiple-inheritence. It’s effectively an abstract class with no members or method definitions. Generally for unrelated classes that require the same set of methods.
An abstract class is an incomplete class definition that can declare methods and members, but does not define all of them. It can inherit from another class and be inherited. Generally for a set of classes that share an “is a” relationship with the base (abstract) class.
API
Application Programming Interface
Virtual Method
Allow a single method call to invoke different method definitions based on the class of the object (used in polymorphism). Nonstatic Java methods are ALWAYS virtual. In C#, they're only virtual when they're DECLARED to be virtual.
Polymorphism
The capability to provide multiple implementations of an action and to select the correct implementation based on the surround context. (Overriding).
When might you have an abstract class that implements an interface?
Maybe you want to give the option of default implementations to a class that implements the interface. It can inherit the abstract class and only implement one or two of the functions from the interface, since the rest may be defined in the abstract class.
Lazy Loading
Waiting until an object is needed before instantiating it.
What are properties in C#?
Treated like members, but with built-in accessor/mutator methods. Exposes getting and setting without exposing implementation / verification.
ADO.NET vs OLEDB
Both are APIs to connect to databases.
ActiveX Data Objects DB works with MS-based dbs like SQL Server.
Object Linking and Embedding dbs is supported by many dbs, not just MS-based. OLE can also access MS-based dbs, but it’s not optimized for them like ADO.
Modular Programming
Separating the functionality of your code into modules that aren’t dependent on each other.