Study FSP Flashcards
Polymorphism
It means that different objects can be used in the same way.
Example: Imagine a base class called Animal with a method called Speak(). A Dog class and a Cat class both inherit from Animal and each has its own version of Speak(). When you call Speak() on an animal, the correct version (bark or meow) is used.
Abstraction
Abstraction is about hiding complex details and showing only the important parts.
Example: You can think of a Vehicle where you only see the basic controls (start, stop) without knowing how the engine works inside.
Value Type
These are simple data types (like numbers or small structures) that hold their value directly. For example, an int variable stores a number directly.
Reference Type
These types (like classes and arrays) store a reference to the data, not the data itself. Imagine it as an address that tells you where the data is kept in memory.
Class
Is a reference type. It supports inheritance (one class can be based on another) and is stored in a shared area of memory (heap).
Struct
Is a value type. It is often used for small, simple pieces of data and is stored directly (on the stack).
Array
Has a fixed size, meaning once you create it, you cannot change its length.
List
Can grow or shrink as you add or remove items, and it has many helpful methods (like adding or removing items).
Interface
It only tells what methods a class should have but doesn’t include any code.
Abstract class
Can have some code already written (and can include data) while still requiring some methods to be implemented by its child classes.
Boxing
Converting a simple type (like an int) into an object so it can be used as a reference type.
Unboxing
Getting the simple type back from the object.
Generics
Generics let you create classes or methods that can work with any data type.
Example: List can be a list of integers (List) or strings (List) without writing separate classes for each type.
Extension Methods
This feature lets you add new methods to an existing type without changing its original code.
Example: You can add a method ToTitleCase() to the string type so that you can call it like this:
“hello world”.ToTitleCase();
This new method might change the string to “Hello World”.
Delegate and Types of Delegates
A delegate is like a pointer to a method, allowing you to pass methods as parameters.
Single-cast delegate
Points to one method.
Multicast delegate
Can point to several methods.
Reflection
Reflection lets you look at the details of your code while it is running.
Example: You can ask a class “What properties do you have?” and get the answer even if you did not write that information explicitly.
IEnumerable
It’s used to iterate through a collection (like a list or array) in memory.
It works with any data that is already loaded.
It does not support database operations directly.
Executes queries immediately (when the loop starts).
List<int> numbers = new List<int> { 1, 2, 3, 4 };
IEnumerable<int> even = numbers.Where(n => n % 2 == 0);</int></int></int>
IQueryable
It’s designed for querying data from a database (like with Entity Framework).
It builds an expression tree and translates it into a SQL query.
Executes the query only when you use the data (e.g., with ToList()).
More efficient for database queries because the filter happens on the server, not in memory.
IQueryable<User> users = dbContext.Users.Where(u => u.Age > 18);</User>
Parallel Programming
Runs several tasks at the same time, often on different CPU cores, to finish work faster.
Async Programming
Lets your program do other things while waiting for a long task (like reading a file or a web call).
POST
Usually used to create a new resource (like adding a new record).
PUT
Used to update an existing resource completely.
PATCH
Only changes part of a resource.
Usage of [FromBody] in a Controller
Gets data sent in the request body (often in JSON format)
Usage of [FromQuery] in a Controller
Gets data from the URL’s query string (after the ? symbol).
Usage of [FromRoute] in a Controller
Gets data from the URL path itself.
Steps to Register a Service using Dependency Injection
Create an interface (contract) and its implementation (the class).
In your configuration (often in Startup.cs or Program.cs), add the service to the container using methods like AddTransient, AddScoped, or AddSingleton.
Scoped
A new instance is created every time the service is requested.
Transient
A single instance is used for each request from the client.
Singleton
Only one instance is created and shared throughout the whole application.
Claims and Claims in JSON Web Token (JWT)
Claims are pieces of information about a user (like user name, email, or roles) that are stored in a token. They help the system decide what the user can or cannot do.
Action Filters
These are special classes that run code before or after an action (a method in a controller) is executed. They are useful for tasks like logging, security, or error handling.
Multiple DbContext in Entity Framework:
Yes, you can have more than one DbContext. This might be useful if you need to work with different databases or separate parts of your application.
Navigation Properties in Entity Framework
They are properties that create a link between different entities (tables). For example, an Order entity might have a navigation property to a Customer entity.
Include
Helps you load related data along with your main data. Loads one level of related data.
ThenInclude
Helps you load related data along with your main data. Loads further details from the already included data.
AsNoTracking
This method tells Entity Framework not to track changes to the data. It makes reading data faster when you do not plan to update it.
Lazy Loading in Entity Framework:
This is when related data is only loaded when you try to use it for the first time, rather than loading everything at once.
Unit testing tools
Common tools for testing in .NET include MSTest, NUnit, and xUnit. These tools help you run tests to check if your code works correctly.
Constraints in SQL
Constraints are rules you set on your database tables to ensure data is correct. Examples include:
PRIMARY KEY: Unique identifier for each row.
FOREIGN KEY: Ensures that a value matches a value in another table.
UNIQUE: No duplicate values are allowed.
NOT NULL: A field must have a value.
Index
An index helps the database find data faster, like an index in a book.
Clustered Index
Determines how data is physically stored in the table. There can be only one per table.
Unclustered Index
A separate structure that points to the data’s location. You can have many nonclustered indexes per table.
Creating an Identity Column
When you create a table, you can make a column automatically add a new number for each new row using the IDENTITY property. Example:
CREATE TABLE Users (
UserID INT IDENTITY(1,1) PRIMARY KEY,
UserName NVARCHAR(100)
);
Cross Join
This join creates every combination of rows from two tables. It pairs each row from the first table with every row from the second table.
UNION
Combines two sets of results but removes duplicate rows.
UNION ALL
Combines the results and keeps all duplicate rows.
TRUNCATE
Quickly removes all rows from a table and resets identity counters. It does not remove table structure.
DELETE
Removes rows one by one and can remove only specific rows using a condition.
Stored Procedure
A set of SQL commands that can change data or perform actions. It does not have to return a value.
Function
A set of SQL commands that must return a value and is often used inside queries.
Module
A container that groups related components, services, and code together.
Component
A part of the user interface (UI) that controls what you see on the screen.
Sharing Information Between Components
Using Input and Output properties for parent-child communication.
Creating a shared service that holds data and is available to many components.
Using event emitters or state management tools for more complex data sharing.
Component Lifecycle Hooks
These are special methods that Angular calls at different times in a component’s life. For example:
ngOnInit: Called when the component is created.
ngOnDestroy: Called when the component is removed.
Structural Directives
Change the structure of the HTML of the page by adding or removing elements (for example, *ngIf or *ngFor)
Component directives
Are essentially components that enhance or display parts of the UI.
Pipes and Examples
Pipes are simple functions that transform data in your templates. Examples:
date: Formats a date value.
currency: Formats a number as money.
uppercase: Changes text to uppercase.
One-way and Two-way Data Binding
One-way binding: Data moves from your component to the view (using {{ }} or [property]= “value”).
Two-way binding: Data moves in both directions between the view and the component (using [(ngModel)]).
Service
A service is just a class that contains logic or data you want to share across components.
Provider
A provider tells Angular how to create or deliver an instance of a service.
You register the service as a provider so Angular can inject it where needed.
@Injectable({
providedIn: ‘root’ // Angular auto-registers it globally
})
export class UserService { }
Template-driven Forms
The form is built mostly in the HTML template using Angular directives. It is easier for simple forms.
Reactive Forms:
The form is built in the component class using code, giving you more control and easier testing.
Router Component
This is the part of Angular (often called RouterOutlet) that displays different components based on the URL. It helps create a single-page application with multiple views.
RxJS
RxJS is a library to work with asynchronous data (data that comes in over time) using streams called Observables. It makes handling events and data updates
Jasmine
A framework to write tests for your code.
Karma
A tool to run these tests in real web browsers.
Microservices Architecture Experience
This means working with a system made up of small, independent services that work together. In a microservices system, each service has its own responsibility and communicates with others over APIs.