Software Engineer concepts Flashcards

(79 cards)

1
Q

/Encapsulation in OOP

A
  • Encapsulation is the bundling of data (attributes) and methods (functions) that operate on the data into a single unit called a class. It also involves restricting access to some components, protecting the integrity of the object’s data by using access modifiers such as private, public, and protected.
  • Example: A Car class with private data like speed and public methods like accelerate() and brake().
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

/Abstraction in OOP

A
  • Abstraction hides the complex implementation details of a system and shows only the essential features to the user. The idea is to reduce complexity and allow the programmer to focus on interactions at a high level.
  • Example: You use a method startEngine() in a Car class without needing to know the internal workings of how the engine starts.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

/Inheritance in OOP

A
  • Inheritance allows one class (child or subclass) to inherit properties and methods from another class (parent or superclass). This promotes code reuse and establishes a natural hierarchy between classes.
  • Example: A Sedan class can inherit from a general Car class, thus inheriting properties like speed and methods like drive().
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

/Polymorphism in OOP

A
  • Polymorphism means “many forms” and allows objects of different classes to be treated as objects of a common superclass. There are two types of polymorphism:
  • Compile-time (method overloading): Multiple methods can have the same name but different parameters.
  • Run-time (method overriding): A subclass can provide its own implementation of a method that is already defined in its superclass.
  • Example: A Vehicle class has a method move(). Both Car and Bike inherit move(), but each has its own implementation (overriding it) depending on the type of vehicle.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

/What are the SOLID principles?

A
  1. Single Responsibility Principle (SRP): A class should have only one reason to change. It states that a class should have only one responsibility or purpose. This helps keep classes focused and makes them easier to understand, test, and maintain.
  2. Open-Closed Principle (OCP): Software entities (classes, modules, functions, etc.) should be open for extension but closed for modification. This principle encourages designing modules that can be extended with new functionality without modifying their existing code. This promotes code reuse and minimizes the risk of introducing bugs when making changes.
  3. Liskov Substitution Principle (LSP): Objects of a superclass should be replaceable with objects of their subclasses without affecting the correctness of the program. It ensures that derived classes can be used as substitutes for their base classes without causing unexpected behavior. This principle defines a behavioral contract that derived classes must uphold.
  4. Interface Segregation Principle (ISP): The Interface Segregation Principle (ISP) is a key principle in object-oriented design, advocating for creating specialized interfaces rather than large, general-purpose ones. Clients should not be forced to depend on interfaces they do not use. It promotes the idea of segregating interfaces into smaller and more focused ones, tailored to specific client needs. This prevents clients from being burdened with unnecessary dependencies and provides better flexibility and maintainability.
  5. Dependency Inversion Principle (DIP): High-level modules should not depend on low-level modules. Both should depend on abstractions. Abstractions should not depend on details; details should depend on abstractions. It encourages decoupling and dependency injection, where dependencies are defined through interfaces or abstractions instead of concrete implementations. This improves flexibility, testability, and modularity.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

/what is asynchronous programming

A

Asynchronous programming is a programming paradigm that allows tasks or operations to run independently of the main program flow, without blocking the execution of other tasks. It is particularly useful for operations that can take a long time to complete, such as file I/O, network requests, or database access, enabling the application to remain responsive while those tasks are running in the background.

In asynchronous programming, instead of waiting for a long-running task to finish before proceeding, the program can continue executing other code, and the result of the task is handled when it eventually completes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

/What is IoC - Inversion of Control?

A

Inversion of Control (IoC) is a design principle in software engineering where the flow of control of a program is inverted compared to traditional programming. Instead of the program controlling how objects and services are created and managed, control is “inverted” to a framework or external component. The key idea is that components don’t directly instantiate or manage their dependencies. Instead, those dependencies are provided or “injected” by an external mechanism.

IoC helps in loosely coupling components, making the system more modular, testable, and easier to maintain.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

/What is Dependency Injection?

A

Dependency Injection (DI) is a specific implementation of the IoC principle. It refers to the practice of injecting the dependencies (such as services or objects) that a class needs from the outside rather than the class instantiating them itself. The dependencies are injected via one of three common methods:
* Constructor Injection (most common)
* Property Injection
* Method Injection

DI is a way to implement IoC, where an external component (typically an IoC container) provides the dependencies for a class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

/What is a Docker file, and what does it define?

A

A Docker file is a blueprint that defines the steps to create a Docker image, specifying the base image, dependencies, file transfers, and default commands.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

/What are Docker images, and how are they created?

A

Docker images are read-only snapshots of environments, created using docker build from Docker files.

A Docker image is a file used to execute code in a Docker container. Docker images act as a set of instructions to build a Docker cotainer, such as a template. Docker images also act as the starting point when using Docker. An image is comparable to a snapshot in virtual machine (VM) environments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

/How do containers relate to Docker images?

A

Containers are runtime instances of Docker images, running in isolation with their own filesystem, network, and processes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

/What is Docker’s primary purpose?

A

To simplify the creation of consistent environments and isolate applications from host dependencies.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

/What is one of Docker’s most significant advantages for software development?

A

Fast, lightweight, and portable container environments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

/What is docker-compose.yml file for?

A

The docker-compose.yml file is used to define and manage multi-container Docker applications. It allows you to configure and run multiple Docker containers as a single service. This file is written in YAML format and specifies the services, networks, and volumes required for your application.

Purpose of the docker-compose.yml File
The primary purpose of this file is to define the configuration for all the services that make up your application. This includes specifying the Docker images to use, the ports to expose, environment variables, volumes, and other settings. By using docker-compose, you can easily start, stop, and manage all the services with a single command.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

/What Is OpenAPI?

A

OpenAPI Specification (formerly Swagger Specification) is an API description format for REST APIs. An OpenAPI file allows you to describe your entire API, including:
* Available endpoints (/users) and operations on each endpoint (GET /users, POST /users)
* Operation parameters Input and output for each operation
* Authentication methods
* Contact information, license, terms of use, and other information.

API specifications can be written in YAML or JSON. The format is easy to learn and readable to both humans and machines.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

/What Is Swagger?

A

Swagger is a set of open-source tools built around the OpenAPI Specification that can help you design, build, document, and consume REST APIs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

/What is REST?

A

The Six Guiding Principles of REST are:
1. Uniform Interface
2. Client-Server
3. Stateless
4. Cacheable
5. Layered System
6. Code on Demand (optional)

https://restfulapi.net/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

/What is TCP?

A

TCP stands for Transmission Control Protocol, a communications standard that enables devices and applications to exchange data over a network. TCP is a fundamental part of the internet’s rules and is one of the most commonly used protocols in digital network communications.

TCP works with the Internet Protocol (IP) to ensure that data is delivered reliably.

TCP (Transmission Control Protocol) is an important network protocol that lets two hosts connect and exchange data streams. TCP guarantees the delivery of data and packets in the same order as they were sent.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

/What is HTTP?

A

Hypertext Transfer Protocol (HTTP) is an application-layer protocol for transmitting hypermedia documents, such as HTML. It was designed for communication between web browsers and web servers, but it can also be used for other purposes, such as machine-to-machine communication, programmatic access to APIs, and more.

HTTP is a protocol for fetching resources such as HTML documents. It is the foundation of any data exchange on the Web and it is a client-server protocol, which means requests are initiated by the recipient, usually the Web browser. A complete document is typically constructed from resources such as text content, layout instructions, images, videos, scripts, and more.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

/What is TLS?

A

Transport Layer Security (TLS), formerly known as Secure Sockets Layer (SSL), is a protocol used by applications to communicate securely across a network, preventing tampering with and eavesdropping on email, web browsing, messaging, and other protocols. Both TLS and SSL are client / server protocols that ensure communication privacy by using cryptographic protocols to provide security over a network. When a server and client communicate using TLS, it ensures that no third party can eavesdrop or tamper with any message.

All modern browsers support the TLS protocol, requiring the server to provide a valid digital certificate confirming its identity in order to establish a secure connection. It is possible for both the client and server to mutually authenticate each other, if both parties provide their own individual digital certificates.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

/What is Cache?

A

A cache (web cache or HTTP cache) is a component that stores HTTP responses temporarily so that it can be used for subsequent HTTP requests as long as it meets certain conditions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

/What is a host (network)?

A

A host is a device that can access a network and communicate with other devices on that network.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

/What is the difference between TCP and TLS?

A

The main difference between TCP and TLS is that TCP is responsible for reliable data delivery, while TLS is responsible for encrypting and securing data:

TCP (Transmission Control Protocol)
Responsible for establishing reliable connections and ensuring data is sent and received accurately between devices over a network. TCP is the backbone of internet communication.

TLS (Transport Layer Security)
Responsible for encrypting data during transmission to ensure privacy and security. TLS adds a layer of security on top of TCP, using symmetric and public key encryption, authentication, and message tampering detection.

TLS is an updated, more secure version of SSL, and the terms are often used interchangeably. TLS handshakes occur after a TCP connection has been opened.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

/What is the application layer in the OSI model?

A

The Application Layer of OSI (Open System Interconnection) model, is the top layer in this model and takes care of network communication. The application layer provides the functionality to send and receive data from users. It acts as the interface between the user and the application. The application provides services like file transmission, mail service, and many more.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
/How does PKCE work for SPA?
Sure! Here’s a quick and simple summary of **PKCE for SPAs**: 1. **Generate a Secret**: Your SPA creates a random string (**code verifier**) and a hashed version of it (**code challenge**). 2. **Start Login**: Your SPA sends the **code challenge** (hashed secret) to the login server when redirecting the user to log in. 3. **Get Authorization Code**: After the user logs in, the login server sends an **authorization code** back to your SPA. 4. **Prove It’s Your App**: Your SPA sends the **authorization code** and the original **code verifier** (the random secret) back to the login server to get the **access token**. 5. **Verification**: The login server hashes the **code verifier** and checks if it matches the original **code challenge**. If they match, it gives your SPA the access token. **Why?** It ensures only your app can finish the login process, even if someone steals the authorization code.
26
/How does Client Credentials Grant flow work?
Sure! Here’s a concise summary of the **Client Credentials Grant flow**: 1. **Purpose**: Used for machine-to-machine (M2M) communication where a client app (not a user) needs to access resources. 2. **Setup**: The app registers with the authorization server and gets a **client ID** and **client secret**. 3. **Request Access Token**: - The app sends a POST request to the **token endpoint** with: - `grant_type=client_credentials` - `client_id` and `client_secret` (usually in the Authorization header, Base64-encoded). - Optionally, requested **scopes**. 4. **Token Response**: - If the credentials are valid, the server returns an **access token**. 5. **Access Resources**: - The app uses the token (in the `Authorization: Bearer` header) to access protected APIs. **Why?** It allows secure authentication and authorization for applications that act on their own behalf without user involvement.
27
/What is a WebHook?
A webhook is a **lightweight, event-driven communication that automatically sends data between applications via HTTP**. Triggered by specific events, webhooks automate communication between application programming interfaces (APIs) and can be used to activate workflows, such as in GitOps environments. Because webhooks can connect event sources to automation solutions, they are 1 way to launch event-driven automation to perform IT actions when a specified event occurs.
28
/What is an API Key?
An API key is a **unique identifier used to authenticate and authorize requests made to an Application Programming Interface (API)**. It acts as a passcode that allows applications, users, or systems to access specific features or data offered by the API. API keys are widely used in software development to ensure secure and controlled access to services.
29
/when does the project use appsettings.Development.json, appsettings.local.json and the default appsettings.json?
In an ASP.NET Core project, the configuration files appsettings.json, appsettings.Development.json, and appsettings.local.json are used to manage different settings for various environments. Here's when each file is used: 1. **appsettings.json**: This is the default configuration file that is always loaded, regardless of the environment. It contains the base configuration settings for the application. 2. **appsettings.Development.json**: This file is used when the application is running in the Development environment. It overrides the settings in appsettings.json with development-specific settings. The environment is typically set to Development when running the application locally for development purposes. 3. **appsettings.local.json**: This file is not a standard file used by default in ASP.NET Core. However, it can be used for local overrides. If you want to use this file, you need to explicitly add it to the configuration in your Program.cs or Startup.cs file.
30
/Basic Authentication
Basic Authentication is a method for an HTTP user agent (e.g., a web browser) to provide a username and password when making a request.
31
/HTTP vs HTTPS
**HTTP** HTTP is a stateless system that allows connection on demand. It's good for data transfer, but it doesn't encrypt data, making it vulnerable to attacks. **HTTPS** HTTPS is an extension of HTTP that uses SSL/TLS certificates to encrypt data transferred between a user's browser and a website. This protects users from eavesdroppers and man-in-the-middle (MitM) attacks.
32
/Why does a HTTP request need an Authorization header?
An HTTP request needs an Authorization header to provide credentials for user authentication, allowing a server to verify the identity of the client making the request and grant access to protected resources, essentially acting as a security mechanism to control who can access specific data or functionalities on a website or API.
33
##Lambda expression x => x.property and LINQ queries
``` int[] numbers = { 2, 3, 4, 5 }; var squaredNumbers = numbers.Select(x => x * x); Console.WriteLine(string.Join(" ", squaredNumbers)); // Output: // 4 9 16 25 ```
34
/What is an expression tree?
**They represent code in a tree-like data structure, where each node is an expression (such as a method call, binary operation, or constant value).** They allow you to construct, examine, and execute code dynamically at runtime. Expression trees are particularly useful for creating dynamic code, analyzing code at runtime, and **enabling frameworks like LINQ to SQL and Entity Framework to translate C# code into SQL queries or other operations**. Picture https://dev.to/turalsuleymani/solid-introduction-to-expression-trees-in-c-1c4i
35
##LINQ queries (widely used on List and Dictionary)
``` List numbers1 = [ 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 ]; List numbers2 = [ 15, 14, 11, 13, 19, 18, 16, 17, 12, 10 ]; // Query #4. double average = numbers1.Average(); // Query #5. IEnumerable concatenationQuery = numbers1.Concat(numbers2); ```
36
/Tuples
very interesting way to declare variables. ``` (double, int) t1 = (4.5, 3); Console.WriteLine($"Tuple with elements {t1.Item1} and {t1.Item2}."); // Output: // Tuple with elements 4.5 and 3. (double Sum, int Count) t2 = (4.5, 3); Console.WriteLine($"Sum of {t2.Count} elements is {t2.Sum}."); // Output: // Sum of 3 elements is 4.5. ```
37
/Difference between local.settings.json and appsettings.local.json
local.settings.json is used by the Azure Function projects and appsettings.local.json is for the ASP.NET Core application's local settings.
38
/purpose of launch.settings.json
The launchSettings.json file controls how an ASP.NET Core or .NET Core application is launched and debugged. It's located in the Properties folder of a project. What does it do? Specifies the command to execute, Determines whether to open the browser, Sets environment variables, Defines launch profiles, and Controls how Visual Studio behaves when launching an application.
39
/What is the difference between .NET, .NET Core, ASP.NET, ASP.NET Core?
**1. .NET Framework:** * **What It Is:** Think of the .NET Framework as a big toolbox created by Microsoft around 2002. It's filled with tools and libraries that help developers build various types of applications, like websites and desktop programs, primarily for Windows computers. **2. .NET Core:** * **What It Is:** Introduced in 2016, .NET Core is like a newer, more versatile version of the .NET Framework. It's designed to work not just on Windows, but also on macOS and Linux, making it cross-platform. **3. ASP.NET:** * **What It Is:** ASP.NET is a part of the .NET Framework specifically for building dynamic websites and web services. Imagine it as a set of tools within the .NET Framework toolbox dedicated to web development. **4. ASP.NET Core:** * **What It Is:** ASP.NET Core is the updated, more flexible version of ASP.NET. It's designed to work with .NET Core, meaning it can run on multiple operating systems. It combines features that were previously separate in ASP.NET, like MVC (for building web applications) and Web API (for building web services), into a single framework. **Key Differences Summarized:** ***Platform Compatibility:** * ASP.NET runs only on Windows. * ASP.NET Core can run on Windows, macOS, and Linux. **Performance:** * ASP.NET Core is designed to be faster and more efficient than the traditional ASP.NET. **Modularity:** * ASP.NET Core allows developers to include only the necessary components, making applications lighter and potentially more secure. **Open Source:** * ASP.NET Core is open-source, encouraging community contributions and transparency. In simple terms, if you're starting a new web project and want flexibility, better performance, and cross-platform capabilities, ASP.NET Core with .NET Core is a modern choice. However, for existing projects that are deeply integrated with Windows, the traditional ASP.NET with the .NET Framework might still be in use.
40
/What is nodejs?
**Node.js is a cross-platform, open-source JavaScript runtime environment** that can run on Windows, Linux, Unix, macOS, and more. Node.js runs on the V8 JavaScript engine, and executes JavaScript code outside a web browser. Node.js lets developers use JavaScript to write command line tools and for server-side scripting.
41
/package.json?
The package.json file is the heart of any Node project. It records important metadata about a project which is required before publishing to NPM, and also defines functional attributes of a project that npm uses to install dependencies, run scripts, and identify the entry point to our package.
42
/What is Kiota? What is the kiota-lock.json for?
**Kiota is a command line tool for generating an API client to call any OpenAPI-described API you're interested in.** The goal is to eliminate the need to take a dependency on a different API client library for every API that you need to call. Kiota API clients provide a strongly typed experience with all the features you expect from a high quality API SDK, but without having to learn a new library for every HTTP API. **The kiota-lock.json file is used to capture what the parameters were at the time of generation and can be used to regenerate based on the parameters in the file.**
43
/record vs class
Sure! Here's a concise summary: **`class`**: - Mutable by default. - Equality is reference-based. - Used for general-purpose object-oriented programming. **`record`**: - Immutable by default. - Equality is value-based. - Designed for data models and DTOs. - Supports `with` expressions for creating modified copies. Use `class` for mutable objects and `record` for immutable, value-based data.
44
/What is a factory method?
A factory method is a design pattern used to create objects. Instead of calling a constructor directly, you call a factory method that returns an instance of the object. This method encapsulates the creation logic, which can include complex initialization, validation, or configuration steps. A static method used to create instances of a class or record, encapsulating the creation logic.
45
/What are static methods good for?
1. Static methods are usually useful for operations that don't require any data from an instance of the class (from this) and can perform their intended purpose solely using their arguments. A simple example of this would be a method Point::distance(Point a, Point b); that calculates the distance between two points and don't require an instance. 2. They can be defined within a class as a factory method to create an instace of a class, without needing an existing class instance to be called upon. This is what they call a factory method.
46
/Entity Framework?
**In Microsoft's context, an entity typically refers to an object or a class that represents a table within a database in the Entity Framework. The Entity Framework is an ORM (Object-Relational Mapping) framework provided by Microsoft that allows developers to work with data using object-oriented programming concepts rather than dealing directly with database tables and SQL queries.** An entity class in the Entity Framework often represents a table in a database, where each instance of the class corresponds to a row in that table. These classes are used to define the structure of the data and its relationships. Key characteristics of entities in the Entity Framework include: 1. Properties: Properties of the entity class typically represent columns in the corresponding database table. 1. Navigation Properties: These properties represent relationships between different entities, often reflecting foreign key relationships in the database schema. 1. Attributes or Annotations: Annotations or attributes can be used to provide additional information to the Entity Framework about how the entity maps to the database. Entities in the Entity Framework enable developers to interact with the database using object-oriented techniques, allowing for a more natural and intuitive way to handle data persistence. Developers can perform CRUD (Create, Read, Update, Delete) operations on these entities, and Entity Framework takes care of translating these operations into appropriate SQL queries to interact with the database. ## Footnote https://dev.to/rechidesigns/understand-the-key-difference-between-entity-framework-core-and-entity-framework-2dj0
47
/Entity Framework Core vs Entity Framework?
Comparison: * Entity Framework (EF) refers to the older versions designed for the .NET Framework. * Entity Framework Core (EF Core) is the modern, cross-platform ORM specifically designed for .NET Core and later versions. Both frameworks aim to provide object-relational mapping capabilities, allowing developers to work with databases using object-oriented paradigms, but EF Core is more lightweight, modular, and compatible with the cross-platform (EF Core can work on various platforms, including Windows, Linux, and macOS.).NET Core ecosystem. As of .NET 5 and beyond, EF Core is the recommended ORM for new .NET applications.
48
/What is a delegate?
In C#, 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 the delegate instance with any method that has a compatible signature and return type. You can invoke (or call) the method through the delegate instance. Delegates are used to pass methods as arguments to other methods. Event handlers are essentially methods you invoke through delegates. When you create a custom method, a class such as a Windows control can call your method when a certain event occurs. ## Footnote https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/delegates/
49
/What are anonymous functions?
In C#, an anonymous function is a function without a name, defined using either an anonymous method or a lambda expression. Both constructs enable the creation of inline, unnamed methods that can be assigned to delegates or passed as arguments to higher-order functions.
50
/What is a method's signature?
In programming, a method signature uniquely identifies a method within a class. It typically consists of the method's name and its parameter list, including the number, types, and order of parameters. This allows the compiler or interpreter to distinguish between methods, especially when overloading methods with the same name but different parameters.
51
What is a callback method?
I just met you, And this is crazy, But here's my number (delegate), So if something happens (event), Call me, maybe (callback)?
52
Filters vs Middleware
**Key Differences** **Scope:** * Middleware: Applied globally to all requests. * Filters: Can be applied globally, to specific controllers, or to specific actions. **Use Cases:** * Middleware: Broad concerns that apply to all requests (e.g., authentication, logging). * Filters: Concerns specific to MVC applications (e.g., action execution, result processing). **Execution Order:** * Middleware: Executed in the order registered in Startup.Configure. * Filters: Executed based on their type and the order in which they are applied. **Pipeline Control:** * Middleware: Can short-circuit the request pipeline. * Filters: Can short-circuit the action execution pipeline within MVC actions or Razor Pages.
53
Cross-cutting concerns
Cross-cutting concerns are aspects of a program that affect multiple layers or components of an application. These concerns are not specific to any single part of the application but are used throughout the application. They typically involve functionality that is needed across different modules or layers, such as logging, error handling, authentication, and authorization.
54
Wrapper
In [ASP.NET](http://asp.net/) Core, a "wrapper" typically refers to a design pattern or a technique used to encapsulate and manage the behavior of another component or service. Wrappers can be used to add additional functionality, such as logging, error handling, or caching, without modifying the original component. This concept is often used to adhere to the Single Responsibility Principle and to promote code reuse and separation of concerns.
55
Azure Front Door and Azure CDN
Azure Front Door optimizes web application performance through global routing, load balancing, and security features like a built-in WAF. Azure CDN accelerates content delivery by caching on distributed servers. Both services enhance user experience, but Front Door is ideal for dynamic applications while CDN focuses on static content delivery.
56
``` async Task> HandleDashboardRequest(Func, DateRange, Task> dashboardFunc) { .... return await dashboardFunc(policeArea.Id, dateRange); } ```
**`ActionResult`** * is a type in ASP.NET Core that represents the result of an action method in a controller. It is a generic wrapper that combines two things: * The HTTP Response: It encapsulates the HTTP status code (e.g., 200 OK, 404 Not Found, etc.) and any additional metadata (like headers). * The Response Data (T): It contains the actual data being returned to the client, where T is the type of the data. **`HandleDashboardRequest` Generic method** * The method `HandleDashboardRequest `is a generic method. The `` is a type parameter, meaning the method can work with any type that the caller specifies. For example, T could be a string, a custom object, or any other type. This makes the method flexible and reusable. **`delegate Func, DateRange, Task> dashboardFunc` as a parameter** * This is a delegate (a function pointer) that takes two parameters * It returns a `Task`, meaning it performs an asynchronous operation and resolves to a value of type `T`
57
What does type-safe mean in C#?
C# is primarily a type-safe language, meaning that types can interact only through protocols they define, thereby ensuring each type’s internal consistency. For instance, C# prevents you from interacting with a string type as though it were an integer type. More specifically, C# supports static typing, meaning that the language enforces type safety at compile time. This is in addition to dynamic type safety, which the .NET CLR enforces at runtime. Static typing eliminates a large class of errors before a program is even run. It shifts the burden away from runtime unit tests onto the compiler to verify that all the types in a program fit together correctly. This makes large programs much easier to manage, more predictable, and more robust. Furthermore, static typing allows tools such as IntelliSense in Visual Studio to help you write a program, since it knows for a given variable what type it is, and hence what methods you can call on that variable.
58
What does strongly typed mean in C#?
C# is called a strongly typed language because its type rules (whether enforced statically or dynamically) are very strict. For instance, you cannot call a function that’s designed to accept an integer with a floating-point number, unless you first explicitly convert the floating-point number to an integer. This helps prevent mistakes. Strong typing also plays a role in enabling C# code to run in a sandbox—an environment where every aspect of security is controlled by the host. In a sandbox, it is important that you cannot arbitrarily corrupt the state of an object by bypassing its type rules.
59
Why use Static Classes and Static Members?
Static classes and members are usually used for data or functions that do not change in response to object state, or for utility functions that do not rely on object state at all. One common use of static classes is to hold application-level data, such as configuration settings. Static methods, on the other hand, are often used for utility functions. For example, the Math class in C# is a static class with static methods. To use any method of the Math class, such as Math.Sqrt(), you do not need to create an instance of the Math class.
60
What is a Garbage Collector good?
When a class object is created at runtime, a certain memory space is allocated to it in the heap memory. However, after all the actions related to the object are completed in the program, the memory space allocated to it is a waste as it cannot be used. In this case, garbage collection is very useful as it automatically releases the memory space after it is no longer required.
61
Model View View Model
https://www.geeksforgeeks.org/introduction-to-model-view-view-model-mvvm/
62
Methods and properties that don’t access instance data should be marked as static for the following reasons:
* Clarity and Intent: Marking a method/property as static makes it clear that the method does not depend on instance data and can be called without creating an instance of the class. This improves the readability of the code by clearly conveying the member’s intended use. * Performance: Instance methods/properties in C# require an instance of the class to be called. This means that even if the it doesn’t use any instance data, the runtime still needs to pass a reference to the instance during the call. For static methods and properties, this overhead is avoided, leading to slightly better performance. * Memory Usage: Since instance methods implicitly carry a reference to the instance (the caller object), they can potentially prevent the garbage collector from collecting the instance whem it is not otherwise referenced. Static members do not carry this overhead, potentially reducing memory usage. * Testing: Static members can be easier to test since they do not require an instance of the class. This can simplify unit testing and reduce the amount of boilerplate code needed to set up tests.
63
What is JSON Web Token?
JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. This information can be verified and trusted because it is digitally signed. JWTs can be signed using a secret (with HMAC algorithm) or a public/private key pair using RSA. Let’s explain some concepts of this definition further. * Compact: Because of its size, it can be sent through an URL, POST parameter, or inside an HTTP header. Additionally, due to its size its transmission is fast. * Self-contained: The payload contains all the required information about the user, to avoid querying the database more than once. ## Footnote http://auth0.com/learn/json-web-tokens
64
When should you use JSON Web Tokens?
These are some scenarios where JSON Web Tokens are useful: * **Authentication**: This is the typical scenario for using JWT, once the user is logged in, each subsequent request will include the JWT, allowing the user to access routes, services, and resources that are permitted with that token. Single Sign On is a feature that widely uses JWT nowadays, because of its small overhead and its ability to be easily used among systems of different domains. * **Information Exchange**: JWTs are a good way of securely transmitting information between parties, because as they can be signed, for example using a public/private key pair, you can be sure that the sender is who they say they are. Additionally, as the signature is calculated using the header and the payload, you can also verify that the content hasn’t changed. ## Footnote https://auth0.com/learn/json-web-tokens
65
What are assemblies?
Assemblies are a collection of types and resources that are built to work together and form a logical unit of functionality. They usually compose of one or more compiled source code files or modules and therefore, they are considered the building blocks of C# applications.
66
What is SSL termination?
SSL (Secure Sockets Layer) termination, also known as SSL offloading or decryption, is a process where encrypted SSL/TLS data traffic is decrypted at an intermediate point in a network, rather than at the destination server. This decryption is typically performed by a load balancer, proxy server, or other dedicated hardware.
67
What is a reverse proxy?
A reverse proxy is a server that sits in front of web servers and forwards client (e.g. web browser) requests to those web servers. Reverse proxies are typically implemented to help increase security, performance, and reliability. In order to better understand how a reverse proxy works and the benefits it can provide, let’s first define what a proxy server is. A forward proxy, often called a proxy, proxy server, or web proxy, is a server that sits in front of a group of client machines. When those computers make requests to sites and services on the Internet, the proxy server intercepts those requests and then communicates with web servers on behalf of those clients, like a middleman.
68
.sln files
69
How does Attributes work in C#? What is reflection???
They can be applied to a wide range of program elements, collectively known as "attribute targets." This flexibility allows developers to annotate various parts of their code with metadata that can influence behavior at compile-time or runtime. ## Footnote https://dev.to/rasheedmozaffar/introduction-to-attributes-in-c-21gn
70
Two examples of reflection [Attribute.GetCustomAttributes Method](https://learn.microsoft.com/en-us/dotnet/api/system.attribute.getcustomattributes?view=net-9.0) [CustomAttributeExtensions.GetCustomAttribute Method](https://learn.microsoft.com/en-us/dotnet/api/system.reflection.customattributeextensions.getcustomattribute?view=net-9.0)
``` private static void PrintAuthorInfo(System.Type t) { System.Console.WriteLine($"Author information for {t}"); // Using reflection. System.Attribute[] attrs = System.Attribute.GetCustomAttributes(t); // Reflection. // Displaying output. foreach (System.Attribute attr in attrs) { if (attr is AuthorAttribute a) { System.Console.WriteLine($" {a.GetName()}, version {a.Version:f}"); } } } static List GetDisplayNamesPropertyValues() { var typeProperties = typeof(T).GetProperties(); var output = new List(); foreach (var property in typeProperties) { var displayNameAttribute = property.GetCustomAttribute(); var displayName = displayNameAttribute is not null ? displayNameAttribute.DisplayName : property.Name; output.Add(displayName); } return output; } ``` [Attribute.GetCustomAttributes Method](https://learn.microsoft.com/en-us/dotnet/api/system.attribute.getcustomattributes?view=net-9.0) [CustomAttributeExtensions.GetCustomAttribute Method](https://learn.microsoft.com/en-us/dotnet/api/system.reflection.customattributeextensions.getcustomattribute?view=net-9.0) ## Footnote https://learn.microsoft.com/en-us/dotnet/csharp/advanced-topics/reflection-and-attributes/accessing-attributes-by-using-reflection https://dev.to/rasheedmozaffar/introduction-to-attributes-in-c-21gn
71
https://www.geeksforgeeks.org/what-is-the-difference-between-linq-to-sql-and-linq-to-objects/
72
What is Navigation Properties???? What is Include() in EF??
73
SingleAsync() vs FirstOrDefaultAsync()
74
sas uri
75
Reading values from config or appsettings
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-9.0
76
inject a mock class into a test c#
https://code-maze.com/csharp-mock-ioptions/ https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options?view=aspnetcore-9.0 https://learn.microsoft.com/en-us/answers/questions/1275933/ioptions-interface-in-c
77
Github Actions vs Octopus
78
claimsprincipal
79
Offset vs Cursor-Based Pagination