Send a link to your students to track their progress
32 Terms
1
New cards
Explain MVC architecture? What is an MVC? What does MVC mean? Why do we use it?
MVC is an architecture pattern for building web applications using an Model View Controller Design.
1. The Model represents the data and business logic of the application. 2. The View represents the user interface of the application. It is responsible for displaying the data to the user and receiving input from the user. 3. The Controller acts as an intermediary between the Model and the View. It is responsible for handling user input, updating the Model, and updating the View
The MVC pattern is used in web development for several reasons:
1. **Separation of concerns**: The MVC pattern separates the application into three distinct components, each with its own responsibilities. This makes it easier to manage and maintain the codebase, as changes to one component do not affect the others. 2. **Modularity**: The MVC pattern promotes modularity, making it easier to add or remove functionality from the application. This allows developers to focus on writing clean and efficient code that meets the project requirements. 3. **Scalability**: The MVC pattern is scalable, making it suitable for applications of all sizes. By separating the data, user interface, and application logic into distinct components, developers can easily add new features or scale the application to handle increased traffic. 4. **Testability**: The MVC pattern is highly testable, as each component can be tested independently of the others. This allows developers to write automated tests that ensure the application is functioning correctly and meets the project requirements.
2
New cards
What is the difference between ViewData, ViewBag and TempData?
ViewData & ViewBag are used to pass data from Controller to View.
TempData is used to pass data from Controller to Controller.
ViewData required Typecasting for complex data types ViewBag doesnt require typecasting
3
New cards
What are Areas in MVC?
Areas are a way to divide the modules of large applications in multiple or separated MVC
4
New cards
What is Dapper and why do we use it ?
Dapper is a object-relational mapper (ORM) for the .NET framework.It provides a simple way to map objects to database tables and execute SQL queries.
Dapper is designed to provide fast and simple data access for .NET applications. It is lightweight and easy to use, and it can greatly improve the performance of a .NET application by eliminating the need to write boilerplate code to access data.
BEST ANSWER: Dapper is a micro-ORM (object-relational mapper) for .NET. It provides a simple way to map objects to database tables and execute SQL queries. It is fast and lightweight, and does not require a lot of configuration.
5
New cards
Which classes provided by the .NET framework does Dapper use to communicate with databases?
Dapper uses the SqlConnection and SqlCommand classes in the .NET framework to communicate with databases
6
New cards
What is ASP.NET MVC Core?
It is a open source, cross platform web development framework to develop web application created by Microsoft.
7
New cards
Why do we have wwwroot folder?
It is a folder in MVC Core project where static content like HTML, CSS, JS files are stored.
8
New cards
Importance of appsetting.json?
Appsetting.json helps to store configuration information of your project such as connection strings, version #, etc
9
New cards
What is json format?
Json format means name and value
10
New cards
How to read configurations from appsetting.json?
We use iConfiguration object in the constructor which is dependecy injected. We an say iconfiguration object, then curly brackets configuration["ConnString"]
11
New cards
What is the use of Middleware? How to implement?
Middleware helps to execute preprocessing logic before the controller is executed.
For Example: a middleware component may be used to authenticate users before allowing them to access a particular application or service.
12
New cards
What does startup.cs file do? ConfigureServices vs Configure Method?
Startup.cs helps us to configure DI and Middleware. Startup.cs has two methods: ConfigureServices and Configure Method.
ConfigureServices: helps to configure the DI Configure Method: helps to add the Middleware
13
New cards
What is the SOLID design Principle and why is important? What do each of the principle stand for and why are each principle important?
The SOLID design principle is a set of five principles for object-oriented programming that help to make code more flexible, reliable, and easier to maintain. The principles are as follows:
1. Single Responsibility Principle (SRP): A class should have only one responsibility or job to do. This principle is important because it helps to keep classes focused and easy to maintain. 2. Open/Closed Principle (OCP): Classes should be open for extension but closed for modification. In doing so, we stop ourselves from modifying existing code and causing potential new bugs in an otherwise happy application.
Of course, the one exception to the rule is when fixing bugs in existing code. 3. Liskov Substitution Principle (LSP): Simply put, if class *A* is a subtype of class *B*, we should be able to replace *B* with *A* without disrupting the behavior of our program.
4. Interface Segregation Principle (ISP): larger interfaces should be split into smaller ones. By doing so, we can ensure that implementing classes only need to be concerned about the methods that are of interest to them. 5. Dependency Inversion Principle (DIP): The principle of dependency inversion refers to the decoupling of software modules. This way, instead of high-level modules depending on low-level modules, both will depend on abstractions. This principle is important because it helps to make code more flexible and easier to maintain.
14
New cards
\ What is dependency injection? Why do we use it? How is it implemented?
**What is dependency injection?**
Dependency Injection (DI) is a technique used to manage dependencies between objects in software. It involves passing dependencies into an object rather than allowing the object to create them itself, allowing for more loosely coupled component, making the code more modular, flexible, and testable.
**How is it implemented?**
Dependency injection can be implemented in various ways, such as constructor injection, setter injection, and interface injection. In constructor injection, the dependencies are passed to the object through its constructor. In setter injection, the dependencies are set through setter methods. In interface injection, the object implements an interface that defines the methods for setting the dependencies.
15
New cards
How do you secure an API?
To secure an API, you can implement various measures such as using authentication and authorization mechanisms, encrypting sensitive data, using HTTPS protocol, validating user input, and implementing rate limiting to prevent DDoS attacks. Additionally, you can also use firewalls, intrusion detection systems, and regularly update your software to patch any security vulnerabilities.
16
New cards
Open/Closed Principle
Classes should be open for extension but closed for modification. In doing so, we stop ourselves from modifying existing code and causing potential new bugs in an otherwise happy application.
Of course, the one exception to the rule is when fixing bugs in existing code.
17
New cards
Single responsibility principle
Single responsibility principle. As we might expect, this principle states that a class should only have one responsibility. Furthermore, it should only have one reason to change. A class that has multiple responsibilities is often harder to work with because it can become complex and difficult to understand.
How does this principle help us to build better software? Let's see a few of its benefits:
1. Testing – A class with one responsibility will have far fewer test cases. 2. Lower coupling – Less functionality in a single class will have fewer dependencies. 3. Organization – Smaller, well-organized classes are easier to search than monolithic ones.
For example :
We have a Book Class. We want to add a print method but instead of adding it to the Book class, which violates the principle, we make a new class that only deals with printing the text in the book
18
New cards
Interface Segregation Principle (ISP):
Interface Segregation Principle (ISP): larger interfaces should be split into smaller ones. By doing so, we can ensure that implementing classes only need to be concerned about the methods that are of interest to them.
19
New cards
Liskov Substitution Principle (LSP):
Simply put, if class *A* is a subtype of class *B*, we should be able to replace *B* with *A* without disrupting the behavior of our program.
Example would be you have an interface class Car with a void accelerate and turnEngine method :
You have a MotorCar class that extends from Car which can implement these two methods. No problem here
However, throwing an ElectricCar into the mix would change the behavior of the program because it doesnt have an engine
One possible solution would be to rework our model into interfaces that take into account the engine-less state of our *Car*.
20
New cards
What is an API? How would you set up an API and what are the specific calls you can make on it?
An API (Application Programming Interface) is a set of protocols, routines, and tools for building software applications. It defines how different software components should interact with each other, allowing developers to create applications that can communicate with other software systems or services. To set up an API, you need to define the endpoints, methods, and parameters that will be used to interact with the API. Specific calls that can be made on an API depend on the API's design and functionality. Some common API calls include GET (retrieve data), POST (create new data), PUT (update existing data), and DELETE (remove data).
21
New cards
What is JSON? Why is it important?
JSON stands for JavaScript Object Notation. It is a lightweight data interchange format that is easy for humans to read and write, and easy for machines to parse and generate. JSON is important because it is widely used for data exchange between web applications and servers, and it has become the standard format for APIs. It is also supported by many programming languages and is a popular choice for storing and transmitting data.
22
New cards
What is a stack vs queue?
Stack and queue refer to how data is compiled in a data structure.
Stack refers to Last-in-First-out (LIFI). In programming, a stack is commonly used to store information about the state of a program, such as the call stack in a recursive function, or to implement undo/redo functionality in an application.
Queue refers to First-in-First-Out(FIFI). In programming, a queue is commonly used to manage tasks that need to be processed in the order they were received, such as processing user requests in a web application.
23
New cards
What is value type vs reference type?
A value type is a type of data that directly contains its own value, and it is stored in memory on the stack. Examples of value types include integers, floats, and booleans. Value types are passed by value, meaning that when they are assigned or passed to a method, a copy of their value is created.
\ A reference type, on the other hand, is a type of data that contains a reference to its value, which is stored in memory on the heap. Examples of reference types include strings, arrays, and objects. Reference types are passed by reference, meaning that when they are assigned or passed to a method, a reference to the original value is used instead of creating a copy.
24
New cards
What is .NET?
.NET is a software framework developed by Microsoft that includes a runtime environment, a set of libraries, and development tools for building and running applications on Windows, macOS, and Linux. The .NET framework provides a common language runtime (CLR), which enables the execution of code written in different programming languages, including C#.
25
New cards
What is OOP? What are the main concepts behind it?
Object-Oriented Programming is a programming concept that organizes code into objects that interact with each other to accomplish tasks. The main concepts behind OOP are encapsulation, inheritance, polymorphism, and abstraction.
Encapsulation refers to the practice of hiding the implementation details of an object's properties and methods from the outside world. Inheritance allows objects to inherit properties and methods from a parent class, while polymorphism enables objects to take on multiple forms or behaviors, depending on the context in which they are used. Abstraction involves identifying the essential features of an object or concept and ignoring the details that are not relevant to the current context.
26
New cards
What are OOPs advantages and weaknesses?
OOP has several advantages, including modularity, reusability, flexibility, and scalability. It allows you to break down complex problems into smaller, more manageable parts, encouraging code reuse and adaptability to different types of applications and programming languages. OOP can also be used to build scalable applications that can handle large amounts of data and traffic.
\ However, OOP can also have some weaknesses. It can be more complex than other programming paradigms, especially for beginners, and can add additional overhead to your code, which can slow down performance in some cases. Overuse of inheritance can lead to tight coupling between classes, making your code more difficult to maintain and modify. It is not suitable for small applications. Since a majority of OOPS require planning and designing (setting up base classes, using abstraction/encapsulation), it does not make sense to spend so much time for a smaller application.
27
New cards
What is Stack vs Heap?
The stack and heap are two regions of memory that are used for different purposes.
\ Think of the stack as a pile of plates. When you add a new plate to the pile, it goes on top of the previous plate. When you remove a plate, you take the top plate off the pile. This is similar to how the stack works in memory.
The stack is used to store information about the current state of the program. This includes things like local variables, function parameters, and return addresses. When a function is called, a new stack frame is created to hold the function's local variables and parameters. When the function returns, the stack frame is removed and the program returns to the previous state.
\ Think of the heap as a big box of Legos. When you want to build something, you take out the Legos you need and put them together to create your object. This is similar to how the heap works in memory.
In programming, the heap is used to store objects and data structures that are created at runtime. When you create an object, memory is allocated on the heap to hold the object's data. The object reference that is returned points to the location of the object on the heap.
28
New cards
What is an API? What is RESTful Api?
An API (Application Programming Interface) is a set of protocols, routines, and tools for building software applications. APIs define how software components should interact with each other, allowing different applications to communicate and exchange data.
\ A RESTful API follows REST principles for building scalable and maintainable web services. RESTful APIs use HTTP methods (such as GET, POST, PUT, and DELETE) to perform operations on resources (such as data objects or files) that are identified by URIs (Uniform Resource Identifiers)
29
New cards
How do you secure an API? How do you call and test an API?
To secure an API, we can use authentication and authorization mechanisms to ensure that only authorized users can access the API and that they can only access the resources they are authorized to access. We can also use encryption to protect data transmitted over the API and rate limiting to prevent excessive API usage.
To call, you typically need to send an HTTP request to the API endpoint which would be a URL, The request can be any HTTP Method like get post, update or delete. To test an API, we can use API testing tools such as Postman to send requests to the API and verify the responses.
30
New cards
What is Basic Authentication in API?
Basic authentication is a simple authentication scheme used by web APIs to authenticate users. In basic authentication, the user's credentials (i.e., username and password) are sent in plain text as part of the HTTP request headers. The server then verifies the credentials and either grants or denies access to the requested resource.
31
New cards
What is DRY Principle?
The DRY principle is a software development principle that encourages developers to avoid duplicating code or logic in multiple places within a system. Instead, developers should create reusable components or functions that can be used throughout the system. By following the DRY principle, code becomes simpler, easier to understand, and more maintainable,
32
New cards
How do you unit test?
In C#, there are different frameworks you can use for testing such as NUnit, MSUnit, or xUnit.
\ You create a test project, write the test methods that test the functionality of the code I want to test, The test runner will execute each test method and report the results. It helps to ensure that code is working correctly and can be modified or refactored with confidence.