C#-SQL Flashcards

1
Q

Test-driven development (TDD)

A

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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Code Coverage

A

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%)

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

SDLC

A
  • Phases of SDLC -> Requirement Analysis, Design, Development, Testing, Deployment, Maintainence
  • Waterfall, Bing Bang Model, RAD, Spiral Model, Iterative, Agile (Scrum), TDD
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Logging

A
* 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!
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Testing

A
  • Black-box, white-box testing

- Performance Testing, Load Testing, Smoke testing, Integration Testing, Penetration Testing, Unit Testing.

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

Unit Testing

A

is important component of developer testing which is heavily used in TDD.

  • In.Net/.Net Core supports multiple frameworks for testing
  • MSTest, NUnit, xUnit.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Generally Supported Code Coverage Formats

A
  • 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)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

LINQ

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Method syntax

A

(LINQ) It is more like C# in that you use methods to perform the queries
* For simple filtering, I would use method syntaxes

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

Query syntax

A

(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

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

SOLID PRINCIPLES

A
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

SINGLE RESPONSIBILITY PRINCIPLE

A
~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...)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

OPEN CLOSED PRINCIPLE

A

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

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

LISKOV SUBSTITUTION PRINCIPLE

A

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

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

Normalization

A

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.

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

Transaction Control Language

A

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

17
Q

DATA DEFINITION LANGUAGE

A

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.

18
Q

INTERFACE SEGREGATION PRINCIPLE

A

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.

19
Q

DEPENDENCY INVERSION PRINCIPLE

A

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.)

20
Q

DQl – Data Query Language

A

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.

21
Q

DML(Data Manipulation Language):

A

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.

22
Q

These SQL commands are mainly categorized into four categories as:

A

DDL – Data Definition Language
DQl – Data Query Language
DML – Data Manipulation Language
DCL – Data Control Language

23
Q

DCL (Data Control Language):

A

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.

24
Q

The Singleton design pattern

A

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.

25
Q

SINGLETON

A

pattern is one of the best-known patterns in software engineering. Essentially, a singleton is a class which only allows a single instance of itself to be created, and usually gives simple access to that instance. Most commonly, singletons don’t allow any parameters to be specified when creating the instance - as otherwise a second request for an instance but with a different parameter could be problematic! (If the same instance should be accessed for all requests with the same parameter, the factory pattern is more appropriate.) This article deals only with the situation where no parameters are required. Typically a requirement of singletons is that they are created lazily - i.e. that the instance isn’t created until it is first needed.

26
Q

Examples of SINGLETON DESIGN PATTERNS ARE IMPLEMENTED

A

~A single constructor, which is private and parameter less. This prevents other classes from instantiating it (which would be a violation of the pattern). Note that it also prevents subclassing - if a singleton can be subclassed once, it can be subclassed twice, and if each of those subclasses can create an instance, the pattern is violated. The factory pattern can be used if you need a single instance of a base type, but the exact type isn’t known until runtime.

~The class is sealed. This is unnecessary, strictly speaking, due to the above point, but may help the JIT to optimise things more.
A static variable which holds a reference to the single created instance, if any.
A public static means of getting the reference to the single created instance, creating one if necessary.
27
Q

Basic Syntax:

For column alias:

A

SELECT column as alias_name FROM table_name;
column: fields in the table
alias_name: temporary alias name to be used in replacement of original column name
table_name: name of table

28
Q

Basic Syntax:

For table alias

A

SELECT column FROM table_name as alias_name;
column: fields in the table
table_name: name of table
alias_name: temporary alias name to be used in replacement of original table name

29
Q

NULL VS NOT NULL

A

By default all columns accept NULL as a possible value (& their defaults)
can be explicitly marked by putting NULL after the column definitions

good practice to mark NULL OR NOT NULL AFTER COLUMN DEFINITION