technical Qs Flashcards
What is an instance in object-oriented programming?
An instance is an object that is an instance of a class or type
An instance is an object that is an instance of a class or type
Class / Static Method: ClassName.MethodName( )
Instance Method: instanceOfAClass.MethodName()
For example) repo.GetAllProducts(); An instance method applies to an instance of the class (i.e. an object) whereas a class method applies to the class itself. In C# a class method is marked static. Methods and properties not marked static are instance methods.
When should you add an index to a database column? What is the cost of a database index?
When you want to read from the database faster. The cost is that it takes more time to write information to the database
Explain REST / RESTful Services:
Representational State Transfer – is a language-independent architecture that provides interoperability between computer systems on the Internet. It utilizes a stateless protocol aiming for fast performance and reliability. POST, GET, PUT, DELETE
What is fault tolerance?
enables a system to continue operating properly in the event of the failure of (or one or more faults within) some of its components
Explain what an ORM does?
Object Relational Mapper – is a software abstractor that is used to access a relational database from an object-oriented language.
We’ve used Dapper in this class
Difference between a Class and an Abstract Class?
An abstract class is intended to be a base class of other classes. It acts as a template for its derived classes.
Abstract classes have the following features: - An abstract class cannot be instantiated. - An abstract class may contain abstract methods and accessors. - A non-abstract class derived from an abstract class must include actual implementations of all inherited abstract methods and accessors.
What is C#?
C# is a strongly and statically typed object-oriented programming language
Explain what a Class is in C#:
A class is a user-defined blueprint or prototype from which objects are created
What are the 4 pillars of object-oriented programming?
Inheritance - In OOP, inheritance is the concept that a child class or type can inherit functionality from its parent. You can think of inheritance as a parent/child relationship.
Polymorphism - In OOP, polymorphism is the concept that two or more different classes/types with differing implementations can be referenced or called in a similar fashion.
Encapsulation - In OOP, encapsulation is the concept that a class or type will only expose the functionality necessary to accomplish a given goal, hiding or encapsulating any remaining functionality. A good real world example of encapsulation is a car. A car may have a great deal of moving parts, such as the engine, brakes, and the transmission, but all of that is hidden under the hood. What is exposed to the driver is the bare essentials for driving, such as a steering wheel, gas pedal, and brake pedal.
WE WANT TO BE ABLE TO SWAP PIECES OUT, MAKE TESTING EASIER, THIS IS WHY WE USE INTERFACES, AddTransient()
Abstraction - In OOP, abstraction is the concept that software should be built in abstract sections that can be combined together into a cohesive whole, as opposed to building code where everything is tightly coupled and difficult to break apart.
Think of a swiss army knife vs. a chisel
A swiss army knife can be used for a bunch of tasks, but its ability to perform is less than optimal for each one of those tasks.
A chisel does one thing; and it does it well.
Putting things that a computer will do into concepts that a human can understand – convey in naming! method names, etc. People reading your code can understand and intuit your code
What is a Delegate?
A delegate is a type that represents references to methods with a particular parameter list and return type. When you instantiate a delegate, you can associate its instance with any method with a compatible signature and return type.
What is .NET Core?
.NET Core is a free and open-source, managed computer software framework
Difference between constant and readonly
Constant variables are declared and initialized at compile time. The value can’t be changed afterward. Read-only is used only when we want to assign the value at run time.
Constants
Constants are static by default
They must have a value at compilation-time (you can have e.g. 3.14 * 2, but cannot call methods)
Could be declared within functions
Are copied into every assembly that uses them (every assembly gets a local copy of values)
Can be used in attributes
Readonly instance fields
Must have set value, by the time constructor exits
Are evaluated when instance is created
Static readonly fields Are evaluated when code execution hits class reference (when new instance is created or a static method is executed) Must have an evaluated value by the time the static constructor is done It's not recommended to put ThreadStaticAttribute on these (static constructors will be executed in one thread only and will set the value for its thread; all other threads will have this value uninitialized)
Example of polymorphism
think of a base class called Animal that has a method called animalSound(). Derived classes of Animals could be Pigs, Cats, Dogs, Birds - And they also have their own implementation of an animal sound (the pig oinks, and the cat meows, etc.):
What is a Namespace?
Namespaces are used to provide a “named space” in which your application resides. They’re used especially to provide the C# compiler a context for all the named information in your program, such as variable names.