.NET CORE Flashcards
What is Model Binding (ASP.Net) and why is it important?
Model binding is asp.net is essentially the middle man between your incoming http request and your api controller. It is important because it binds the incoming http request with the proper controller action method.
What are the fundamentals that a developer should consider when working to wire up model binding correctly?
Make sure your routing is correct to whatever the name of your specific service is. The correct interface is being provided in the constructor so that when the api controller is instantiated it has the correct methods that need the logic implemented for. Each service needs to have proper error handling so that errors do not get swallowed, meaning the error doesn’t come back in a response. Proper error handling includes multiple catches such as sqlexception, argumentexception, or exception. Have proper null checks in place so you can return an error that specifies if data isn’t passed in.
What are the differences between an API Controller and a “regular/view” Controller in .Net?
API controllers are specialized in returning data. Json without serialization. Normal controllers are used to return views.
When creating a new controller, what class do you inherit from?
The basecontroller or baseAPIcontroller
Describe the main differences or considerations between the JS and C#.
C# is a static typed language meaning it’s type checking at compile and can’t run without you fixing them. JavaScript is dynamically typed so you can attempt to run it even if you have errors. C# also requires you to define the data type of your variables whereas JavaScript doesn’t.
What is the generic name of the library used in .Net that is used to communicate with Databases?
ADO.NET. Namespcaes system.data, system.data.SqlClient,
What are the .Net objects and classes used to communicate and execute commands at the database?
Dbcommand Class.
What is a Null Reference Exception?
A NullReferenceException is thrown when you try to access a member on a type whose value is null. A NullReferenceException typically reflects developer error and is thrown usually when they have forgotten to instantiate a reference type.
What is an MVC View?
Model-View-Controller View is a display using the model class object. It is a software class and contains a template and data form to produce a response for the browser.
What is a Model?
A model represents the shape of data as public properties and business logic as methods. Think of like your USERS or ADDUSERREQUEST.
What are C# extension methods?
A method added to an object after the original object was compiled. The modified object is often a class, a prototype or a type. Example: when you implement an interface and can use the methods in it.
What are Interfaces?
Interfaces are contracts that defines methods or properties that an implementing class must provide implementing logic for.
What is an abstract class and is this different than an interface?
An abstract class allows you to create functionality that subclasses can implement or override. An interface only allows you to define functionality, not implement it. And whereas a class can extend only one abstract class, it can take advantage of multiple interfaces.
Can you create an instance of an abstract class?
No you cannot because it does not have a complete implementation. The purpose of an abstract class is to function as a base for subclasses. it acts like a template or an empty structure you should extend and build on it before use.
What are the principles of object-oriented programming?
Encapsulation - Restricting access to methods and attributes of certain classes (private). Preventing accidental modification of data or unwanted changes. Abstraction - extension of encapsulation, process of selecting data from a larger pool to show only the relevant details to the object. (Only certain data needed to create account on dating app, things such as favorite food or hobbies isn’t needed) Inheritance - the ability for one object to acquire some/all properties of another object. Such as updateUser : addUser Polymorphism - A way to use a class exactly like its parent so there is no confusion with mixing types. Example Testdata has methind add(int a, int b, inc ) returns a + b + C. Another class can take a new version named t = new testdata() then get the method and bring in it’s own parameters. t.add(3 + 5 + 8) returns = 16.