General Coding Flashcards
The STACK is…..
The stack is the block of memory for storing local variables
The HEAP is…
The heap is the block of memory in which OBJECTS reside
What does REST stand for?
Representational State Transfer
How do you run a Psake command from the powershell?
.\packages\psake.4.3.2\tools\psake.ps1 [Command] eg .\packages\psake.4.3.2\tools\psake.p21 RebuildDatabase
What does IIS stand for?
Internet Information Services
What is the S in SOLID?
Single Responsibility
What is the O in SOLID?
Open / Close Principle
What is UPCASTING?
Creating a BASE class reference from a SUBCLASS reference
eg
Cow myCow = new Cow();
Animal animal = cow; //Upcast
//**animal can only use the methods/properties available to Animal but would take anything across from myCow**//
What is DOWNCASTING?
Creating a SUBCLASS reference from a BASE class reference
eg
Animal myAnimal = new Animal();
Cow myCow = (Cow) myAnimal;
What does the ‘as’ operator do?
It performs a DOWNCAST but will return null if the downcast fails
eg
Animal myAnimal = new Animal();
Cow myCow = myAnimal as Cow;
this can be followed with an !=null check to confirm the type
What does the ‘is’ operator do?
It checks whether an object is of a certain type
eg
if (myAnimal is Cow)
{……}
/**Cow would be a type eg Cow myCow = new Cow(); **/
Is GOLD PLATING a GOOD thing or a BAD thing? Why?
It’s viewed as a BAD thing as it represents work / development that was not requested and is therefore wasteful
What is the difference between CONST and READ ONLY?
- CONST must be declared and initialised on compile, READ ONLY can be initialised during the run time, but once the value has been set it can’t be changed
So within an object, you can have different values set for each instance of the object, but any CONST values would be the same across them all.
NB: Both are static
What are the differences between Abstracation and Encapsulation?
Abstraction:
- Abstraction is a concept of hiding mechanism.
- Only showing those parts which are necessary.
- It is a thought process used in design level.
Encapsulation:
- Encapsulation is the implementation of that concept.
- Hiding complexity.
- Here it is the actual process of hiding the ‘mechanics’ of the class.
How do you convert the following the following method so that the CheckUserName method is run to asynchronously?
private void Login(name)
{
if (CheckUserName(name))
{
MessageBox.Show(“Name Ok”);
};
}
private async Task LoginAsync(name)
{
var result = await Task.Run(() => CheckUserName(name));
if (result)
{
MessageBox.Show(“Name Ok”);
}
}