C#-SQL Flashcards
(29 cards)
Test-driven development (TDD)
is a software development process relying on software requirements being converted to test cases before software is fully developed, and tracking all software development by repeatedly testing the software against all test cases. This is as opposed to software being developed first and test cases created later.
- Mantra: Red, Green, Refactor
- Structure: Arrange, Act, Assert
Code Coverage
It is the percentage given to you on how much lines of your code is actually covered by unit testing
* Ex: Lets say you have a total of 200 lines of code and your unit testing only covers 70 lines of code. That means you have 35% code coverage (Fancy math - 70/200*100 = 35%)
SDLC
- Phases of SDLC -> Requirement Analysis, Design, Development, Testing, Deployment, Maintainence
- Waterfall, Bing Bang Model, RAD, Spiral Model, Iterative, Agile (Scrum), TDD
Logging
* The systematically way to record a series of events depending on what exactly you are trying to capture dotnet add package Serilog.Sinks.File 2. create a Logger using LoggerConfiguration class provided by Serilog 3. Start logging!
Testing
- Black-box, white-box testing
- Performance Testing, Load Testing, Smoke testing, Integration Testing, Penetration Testing, Unit Testing.
Unit Testing
is important component of developer testing which is heavily used in TDD.
- In.Net/.Net Core supports multiple frameworks for testing
- MSTest, NUnit, xUnit.
Generally Supported Code Coverage Formats
- Supported code coverage report format types include all test coverage reports we’ve seen in the wild so far, including:
- Most of .xml format types (Cobertura XML, Jacoco XML, etc.)
- Most of .json format types (Erlang JSON, Elm JSON, etc.)
- Most of .txt format types (Lcov TXT, Gcov TXT, Golang Txt)
LINQ
- Language-Integrated Query
- It is a query language that is very similar to our SQL but we can use it in C# or VB
- So like any query langauge, it is incredibly useful for filtering/acquiring/aggregating data
- Very useful documentation click here
Method syntax
(LINQ) It is more like C# in that you use methods to perform the queries
* For simple filtering, I would use method syntaxes
Query syntax
(LINQ) It is more like SQL in that you create a statement-like operation using keywords
* I would use joins with query syntaxes since it is easier to understand
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
SINGLE RESPONSIBILITY PRINCIPLE
~A class should only have one reason to change Every module or class should have RESPONSIBILITY over a single part of the functionality provided by the software, ~responsibility should be entirely ENCAPSULATED By the class (Persistence, Validation, Error Handling, Logging, Notification, Class Selection/Instantiation, Formatting, Parsing, Mapping, etc...)
OPEN CLOSED PRINCIPLE
Software entities should be open for extension but closed for modification
Design & writing of code should be done in a manner that allows new functionality to be added with minimum changes in the existing code
Allows adding of new functionality as new classes keeping as much existing code unchanged
LISKOV SUBSTITUTION PRINCIPLE
Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program
if the program module is using a base class, then the reference base class can be replaced with a derived class without affecting the functionality of the program module
Derived types must be substitutable for their base types
Normalization
Returns a new string whose binary representation is in a particular Unicode normalization form. Arranging and managing data that returns a new string whose binary representation is in a particular Unicode normalization form.
Transaction Control Language
manages transactions whereby multiple statements can be encapsulated as one operation that either entirely succeeds or has no effect at all
BEGIN TRANSACTION, COMMIT, ROLLBACK, SAVE TRANSACTION
DATA DEFINITION LANGUAGE
CREATE, ALTER, DROP , TRUNCATE TABLE
CREATE: This command is used to create the database or its objects (like table, index, function, views, store procedure, and triggers).
DROP: This command is used to delete objects from the database.
ALTER: This is used to alter the structure of the database.
TRUNCATE: This is used to remove all records from a table, including all spaces allocated for the records are removed.
COMMENT: This is used to add comments to the data dictionary.
RENAME: This is used to rename an object existing in the database.
INTERFACE SEGREGATION PRINCIPLE
many client- specific interfaces are better than one general purpose interface
Should NOT enforce clients to implement interfaces that they don’t use, instead of creating one big interface it can be broken down into smaller (multiple) interfaces.
DEPENDENCY INVERSION PRINCIPLE
One should depend on abstractions not concretions
Abstractions should not depend on the details
Details should depend on Abstractions
High level modules should not depend on low-level modules
Details should depend on abstractions. UI => BLL => DAL => DB (DO NOT hard code these modules together.)
DQl – Data Query Language
DQL statements are used for performing queries on the data within schema objects. The purpose of the DQL Command is to get some schema relation based on the query passed to it. We can define DQL as follows it is a component of SQL statement that allows getting data from the database and imposing order upon it. It includes the SELECT statement. This command allows getting the data out of the database to perform operations with it. When a SELECT is fired against a table or tables the result is compiled into a further temporary table, which is displayed or perhaps received by the program i.e. a front-end.
List of DQL:
SELECT: It is used to retrieve data from the database.
DML(Data Manipulation Language):
The SQL commands that deals with the manipulation of data present in the database belong to DML or Data Manipulation Language and this includes most of the SQL statements. It is the component of the SQL statement that controls access to data and to the database. Basically, DCL statements are grouped with DML statements.
List of DML commands:
INSERT : It is used to insert data into a table.
UPDATE: It is used to update existing data within a table.
DELETE : It is used to delete records from a database table.
LOCK: Table control concurrency.
CALL: Call a PL/SQL or JAVA subprogram.
EXPLAIN PLAN: It describes the access path to data.
These SQL commands are mainly categorized into four categories as:
DDL – Data Definition Language
DQl – Data Query Language
DML – Data Manipulation Language
DCL – Data Control Language
DCL (Data Control Language):
DCL (Data Control Language):
DCL includes commands such as GRANT and REVOKE which mainly deal with the rights, permissions, and other controls of the database system.
List of DCL commands:
GRANT: This command gives users access privileges to the database.
REVOKE: This command withdraws the user’s access privileges given by using the GRANT command.
The Singleton design pattern
The Singleton design pattern is used to ensure an application never contains more than a single instance of a given type. It is often considered to be an antipattern, since the pattern’s implementation places the responsibility of enforcing the single instance behavior on the type itself. This violates the Single Responsibility Principle and references to the type’s static Instance property often result in tight coupling.