Infosys Flashcards
Difference between REST and SOAP
REST is Synchronous uses XML, Json, Plain Text, etc., transfer over HTTP, Javascript support is easy, calls services using HTTP request, uses XML AND JSON to send and receive data. Business logic is URIs Also, no error handling. Example of REST documentation is Swagger. Emphasizes stateless communication
SOAP is Asynchronous, uses only XML well documented but has many options with respect to documentation that can be difficult to understand, error handling is built in, transfers over HTTP, SMTP, FTP etc., its business logic is services interfaces. Supports stateless and stateful operations
Default class & default member
class= internal
member=private
What is REST?
Rest stands for Representational State Transfer. It tells you how you should transfer information and communicate with the client. An architectural style that uses Service Oriented Architecture; Restful service pertains to creating a web service. It is compatible with http(s) protocols & can use any messaging format such as .json, xml or a custom format. Its lightweight and consumes less bandwidth
What is AJAX and have you used it in a project before?
Asynchronous JS and XML
Used to grab information only with XML type backend server hence the name
But now updated for the object to also include JSON to be relevant
**This is how we send request and fetch API
What is routing?
[Route(“[controller]”)]
the middleman between the asp.net and the client and handles the http responses and routes the information back to the client
Helps ASP.Net to route the user’s http request for example which controller and which action inside of the controller routing where the http request should go to.
The routing middleware is used to find the appropriate controller and action in the controller to handle the request
Http Life Cycle
Your browser (the client) will send a request (the url you sent)
The server will receive that request & do some processes
Server will send a response (html, css, json, js etc)
Client will receive response for browser to process the response
What is the HTTP response codes?
1xx Informational 2xx Successful status 3xx Redirection 4xx Client errors 5xx Server errors
Http methods (what they do)
GET: request data,
POST: sends data to server (HTML)
PUT: creates a new resource or replaces
DELETE: delete request
What are abstract methods?
~implicitly a virtual method.
~declarations are only permitted in abstract classes
~abstract method declaration provides no actual implementation,
~there is no method body, the method declaration
~ simply ends with a semicolon and there are NO curly braces { } following the signature.
What is Interface?
Complier enforces contracts, & all methods are public abstract, variables are public, static, or final (declaring behaviors for objects) An interface describes what behaviors (verb) A class should have; it provides none of its own
What is a constructor?
is used to initialize the state of an object.
not required to have a return type.
is invoked implicitly.
The compiler provides a default constructor if you don’t have any constructor in a class.
The constructor’s name must be same as the class name.
5 types: Default, Copy, Parameterized, Copy, Static, Private
Give the syntax for attribute routing
The general syntax is {parameter:constraint}
Ex:
[Route(“customers/{customerId}/orders/{orderId}”)]
public Order GetOrderByCustomer(int customerId, int orderId) { … }
Connection differences between ADO.NET and Entity Framework
ADO.Net is directly connected to the data source and gives better performance, entity framework translates the LINQ queries to SQL first and then process the query
How do you connect API to the database?
Through a connection string in our azure server
What is authentication and authorization
Authentication is checking the identity and authorization is the permission levels of access
What are SOLID principles?
Enables us to manage most of the software design problems, intended to make software designs more understandable Single Responsibility: Open Closed Principle Liskov Substitution Principle Interface Segregation Principle Dependency Inversion Principle
SOLID concepts
A class should have only one reason to change, and the responsibility should be encapsulated by the class Open for extension closed for modification means to allow new functionality with minimal changes to existing code Objects are replaceable with instances of subtypes without altering the correctness of the program Separate multiple interfaces are better than one shouldn’t enforce clients to implement interfaces they don’t use Higher level modules shouldn’t depend on low level modules
OOP Pillars
Encapsulation - Wrapping up of the data & data hiding, with use of access modifiers to provide levels of access
Abstraction - Showing only essential features of the program instead on un-necessary details.
Inheritance - Is a way to extend a type so that its properties and behaviors can be extended/branched further.
Polymorphism- Ability to implement inherited properties or methods in different ways across multiple abstractions.
Static/Compile time polymorphism or Dynamic/Runtime polymorphism.
OOP Advantages
~OOPs makes development and maintenance easier whereas in a procedure-oriented programming language it is not easy to manage if code grows as project size increases.
~OOPs provides data hiding whereas in a procedure-oriented programming language a global data can be accessed from anywhere.
What is a constructor?
5 types: Default, Copy, Parameterized, Copy, Static, Private
is used to initialize the state of an object.
not required to have a return type.
is invoked implicitly.
The Java compiler provides a default constructor if you don’t have any constructor in a class.
The constructor’s name must be same as the class name.
What is Interface?
Complier enforces contracts, & all methods are public abstract, variables are public, static, or final (declaring behaviors for objects) An interface describes what behaviors (verb) A class should have; it provides none of its own
What are abstract methods?
~implicitly a virtual method.
~declarations are only permitted in abstract classes
~abstract method declaration provides no actual implementation,
~there is no method body, the method declaration
~ simply ends with a semicolon and there are NO curly braces { } following the signature.
Http methods (what they do)
GET: request data,
POST: sends data to server (HTML)
PUT: creates a new resource or replaces
DELETE: delete request
Give the syntax for attribute routing
The general syntax is {parameter:constraint}
Ex:
[Route(“customers/{customerId}/orders/{orderId}”)]
public Order GetOrderByCustomer(int customerId, int orderId) { … }