---
# System prepended metadata

title: Interviu

---

# Interviu

## Intrebari - soft skills (prima discutie)
Ce te a facut sa accepti invitatia la interviu si ce cauti la un proiect?
Ce feedback ai primit si te a ajutat?
A trebuit vreodata sa dai feedback "constructiv"?
Ce asteptari ai de la organizatie/manager ca sa te simti motivat si OK ?

- Discuss an instance when you **could not honor a commitment** or had to renege on a promise? How did you notify affected persons? Did they understand?

- Describe a time when you needed to work cooperatively with someone that **did not share the same ideas as you**.Give an example of a time when you had to make an adjustment to your personal style in order to successfully work with a coworker.  

- Ce faci cand **nu stii cum sa rezolvi** o problema?

--------------------------------------------

- Cum esti cu change-uri dinamice in timpul proiectului sau ale sprintului 
- Care sunt asteptarile tale de la manager
- Perspectiva a 2 echipe, una full de seniori, una in care esti seniorul, ce alegi
- In momentul de fata esti in proces de recrutare cu alte firme?
- Cat de mult iti place rolul pe care l-am descris(
e ceva ce iti place/ ceva ce nu iti place)
- ce **nu** ti-ar placea sa gasesti la urmatoarea ta echipa (tehnologie, oameni, etc)
- Key points din cv-ul lui.
- cum e echipa ta, care s rolurile, cum interactionezi cu alte departamente.
- cum te-ar descrie colegii tai?
- de ce pleci?
- ce te motiveaza / ce ti-ar placea sa gasesti la urmatoarea ta echipa?

- ai lucrat vreodata cu persoane dificile? cum ai gestionat?
- cum te tii la curent cu latest technology?
- *[optional/daca e cazul]* cum a fost experienta de mentoring? e o directie in care vrei sa mergi? mentoring, people vs arhitectura, etc
Povestim despre Agile si structura echipelor (business tribes, BA, PO, QA, etc)

## Despre proiecte - prezentare arie/echipe
BPM - tool dezvoltat in house
**BPM Area** - arie tehnica cu urmatoarele proiecte: ...

**NARC**: NET6, arhitectura (idp, gw, microservicii), urmeaza ICHP

**SPAM**: sincronizare a datelor clientilor din RO in global ING repository (via a pub/sub architecture implementata cu Kafka); 
- o impachetam frumos cu tehnologiile (e un mix, avem si .net framework, dar vom avea si .NET6/docker/kubernetes/openshift pentru api de clientsDB); **cozile de mesaje sunt cool** :D 
- SPAM face suport!
- e multicel si SQL dar si **SQL E COOL**


## 0 Others - imbinate cu chestii din CV
- sa povesteasca despre un proiect cap coada - cu deployment, autorizare/autentificare (sa vedem si in zona devops daca are ceva experienta)
- Async aspects:
    - async void 
    - Task vs Thread
    - Task vs ValueTask
    - .Result vs .GetAwaiter().GetResult()
        - Task.GetAwaiter().GetResult() is preferred over Task.Wait and Task.Result because it propagates exceptions rather than wrapping them in an AggregateException. However, all three methods cause the potential for deadlock and thread pool starvation issues. They should all be avoided in favor of async/await.

- CQRS
- what is SOLID. explain inversion of control - why do we need dependency injection?
- REST Apis 
  - GET vs POST 
      - GET requests can be cached
        GET requests remain in the browser history
        GET requests can be bookmarked
        GET requests should never be used when dealing with sensitive data
        GET requests have length restrictions
        GET requests are only used to request data (not modify)
  - are POST requests cache-able? NO. Why? Dupa ce ar putea sa le cachuiasca?
  - **POST vs PUT **(PUT requests are idempotent. That is, calling the same PUT request multiple times will always produce the same result. In contrast, calling a POST request repeatedly have side effects of creating the same resource multiple times.)

- cel mai mare challenge tehnic al tau?
- how do you tackle **performance** issues (web)
- apis vs queues. 


## 1. oop, language

### polymorphism, new vs override
https://dotnetfiddle.net/64tQJn // puse intrebari ca sa ajungem la new si overwrite
https://dotnetfiddle.net/ecIn9B

### Shortcirtcuiting: 
https://dotnetfiddle.net/Fb2vUA
### delegates
https://dotnetfiddle.net/UAiHT4

### ref and value types
https://dotnetfiddle.net/nqirrL
Unde sunt stocate obiectele? 
value types stau pe stack
reference types, arrays, strings - stau pe heap


Ce e string? e reference type sau value type?
Daca string e reference type, de ce se comporta ca un value type? pentru ca **String objects are immutable**: they can't be changed after they've been created. All of the String methods and C# operators that appear to modify a string actually return the results in a new string object. 

![](https://i.imgur.com/UV9E98H.png)


### boxing/unboxing
https://dotnetfiddle.net/UKNifk
For the unboxing of value types to succeed at run time, the item being unboxed must be a reference to an object that was previously created by boxing an instance of that value type.
Attempting to unbox a reference to an incompatible value type causes an InvalidCastException.
![](https://i.imgur.com/lnn91Ks.png)


---------------------
![](https://i.imgur.com/3ghlG0s.png)



### IQueryable:IEnumerable
https://josipmisko.com/posts/c-sharp-iqueryable-vs-ienumerable
```csharp=
var context = new TestEntities();
IEnumerable<Employee> e = context.Employees;
IEnumerable<Employee> d = e.Where(x=>x.Id==1).ToList();

// ce SQL query vedem daca punem un profiler
// ce trebuie modificat ca sa execute filtrul in sql?
// folosim IQUeryable to reduce network traffic
```

## 2. SQL

### editorul vechi
https://www.tutorialrepublic.com/codelab.php?topic=sql&file=select-all
1. Top comenzi in ordinea pretului total, descrescator (id comanda, pret total)
```sql=
SELECT o.order_id,s.shipper_name, SUM(od.units*p.price) as orderTotalPrice
FROM order_details od
inner join orders o on od.order_id=o.order_id
inner join products p on od.product_id=p.product_id
inner join shippers s on o.shipper_id=s.shipper_id
group by o.order_id,s.shipper_name
order by orderTotalPrice desc
;
```
2. Categoriile de produse comandate ordonate descrescator in functie de numarul total de produse comandate pe resepectiva categorie (nume categorie, numar total comenzi)
```sql=
SELECT c.category_name, count(*) as count
FROM order_details od
inner join orders o on od.order_id=o.order_id
inner join products p on od.product_id=p.product_id
inner join categories c on p.category_id=c.category_id
group by c.category_name
order by count desc
;
```
3. Produse care nu au fost comandate niciodata
```sql=
SELECT *
FROM products p
left join order_details od on p.product_id=od.product_id
where order_id is null
;

sau 

SELECT *
FROM products p
where p.product_id not in (select distinct product_id from order_details)
;
```

4. Departamentele cu minim 2 angajati
```sql=
SELECT d.dept_name, count(*)
FROM departments d
inner join employees e on e.dept_id=d.dept_id 
group by d.dept_id
having count(*)>2
```

### AdventureWorks LT
```sql=
-- JOIN, GROUP BY, aggregate functions, HAVING

-- (1) TOP 3 cele mai bine vandute categorii de produse(au fost vandute de mai mult de 5 ori). Denumire categorie, numar de vanzari
select top 3 pc.Name, count(p.ProductCategoryID) as CategoryCount
from [SalesLT].[Product] p
inner join [SalesLT].[ProductCategory] pc on p.ProductCategoryID=pc.ProductCategoryID
inner join SalesLT.SalesOrderDetail sod on sod.ProductID = p.ProductID
group by pc.ProductCategoryID,pc.Name
having count(*)>5
order by CategoryCount desc

-- In ce oras au fost trimise cele mai multe comenzi (numele orasului, numarul de comenzi)
select a.City, count(a.City) as CityCount
from [SalesLT].[SalesOrderHeader] soh
inner join [SalesLT].Address a on soh.[ShipToAddressID] = a.AddressID
group by a.City
order by CityCount desc

-- In ce oras au fost trimise cele mai scumpe vanzari (numele orasului, valoarea comenzii)
select a.City, SUM(soh.SubTotal) as OrderSum
from [SalesLT].[SalesOrderHeader] soh
inner join [SalesLT].Address a on soh.[ShipToAddressID] = a.AddressID
group by a.City
order by OrderSum desc

-- Care sunt top 3 clienti cu cele mai mari discount-uri (nume client, discount)
select top 3 c.FirstName + ' ' + c.LastName, MAX(sod.[UnitPriceDiscount]) as MaxDiscount
from [SalesLT].[SalesOrderDetail] sod
inner join [SalesLT].[SalesOrderHeader] soh on sod.SalesOrderID=soh.SalesOrderID
inner join [SalesLT].[Customer] c on soh.CustomerID=c.CustomerID
group by soh.CustomerID, c.FirstName, c.LastName
order by MaxDiscount desc

-- (2) LEFT JOIN
-- Produse care nu au fost comandate niciodata.

-- Raport cu produsele si pretul minim si maxim de vanzare (Nume produs, pret minim, pret maxim) ordonate dupa fluctuatia de pret cea mai mare
-- daca produsele nu au fost vandute, MinSellPrice si MaxSellPrice sunt 0
-- extra: doar produsele cu marimea intre 38 si 40
select p.Name, min(sod.UnitPrice) as MinSellPrice, max(sod.UnitPrice) as MaxSellPrice
from [SalesLT].[Product] p
inner join [SalesLT].[SalesOrderDetail] sod on sod.ProductID=p.ProductID
group by p.ProductID, p.Name
order by max(sod.UnitPrice)-min(sod.UnitPrice) desc

-- (3) O lista cu denumirea produselor si dimensiunea tshirt-size (S,M,L) calculata pe baza campului Size, astfel:
-- daca size <= 38, atunci marimea t-shirt este 'S'
-- daca 38 < size <= 42, atunci marimea t-shirt este 'M'
-- altfel, marimea este 'L'
-- merge si cu tryCast
select [Name], 
case when isnumeric(size) = 1 then 
	case when cast(size as int) <= 38 then 'S'
	when cast(size as int) > 38 and cast(size as int) <= 42 then 'M'
	else 'L'
	end
	when size is null then 'N/A'
else size end as TshirtSize
from [SalesLT].[Product]

```


```sql=
-- MEDIUM
-- (4.1) SELECT de verificare. pentru comanda cu id=71774, afiseaza prin doua selecturi distincte, subtotalul, taxAmt, Freight si TotalDue din [SalesLT].[SalesOrderHeader], cat si produsele comandate din [SalesLT].[SalesOrderDetail] (ProductID, OrderQty, [UnitPriceDiscount] si LineTotal)
select * from [SalesLT].[SalesOrderDetail] where [SalesOrderID]=71774
select [SalesOrderID], SubTotal,[TaxAmt],[Freight],[TotalDue] from [SalesLT].[SalesOrderHeader] where [SalesOrderID]=71774

-- (4.2) UPDATE. modifica cantitatea pentru produsul 836 din orderul 71774 (noul OrderQty sa fie 5)
update  [SalesLT].[SalesOrderDetail] 
set OrderQty=5 where [SalesOrderID]=71774 and [SalesOrderDetailID]=110562


-- scrie un query in care sa verifici daca SUM(SalesOrderDetail.LineTotal) == SalesOrderHeader.SubTotal for each SalesOrderID
select soh.SalesOrderID, soh.SubTotal, SUM(sod.LineTotal)
from [SalesLT].[SalesOrderHeader] soh
inner join [SalesLT].[SalesOrderDetail] sod on sod.SalesOrderID=soh.SalesOrderID
group by soh.SalesOrderID, soh.SubTotal


-- (5) BULK UPDATE
-- corectie camp [SalesLT].[SalesOrderHeader].[SubTotal]
-- Sales subtotal is Computed as SUM(SalesOrderDetail.LineTotal) for the appropriate SalesOrderID.
-- scrie un query prin care sa corectezi valoarea campului SalesOrderHeader.SubTotal
UPDATE soh
SET soh.SubTotal = x.SumOfLineTotals
from 
[SalesLT].[SalesOrderHeader] soh 
inner join (select sod.SalesOrderID, SUM(sod.LineTotal) as SumOfLineTotals from [SalesLT].[SalesOrderDetail] sod group by sod.SalesOrderID) x on soh.SalesOrderID=x.SalesOrderID
```
### Intrebari teorie SQL

- optimizare queries-ce ai folosit(profiler, execution plan). - - index clustered vs nonclustered; ce e fill factor?
- tabele temporare - avantaje/dezavantaje
- tranzactii, transaction isolation level
- Ce sunt CTE-urile , ai folosit, unde? Ce probleme ai intampinat?
- SP-uri vs functions 
- Ce este un trigger? Unde ai folosit? Ce probleme ai intampinat?
- DELETE vs TRUNCATE?

- Q: cum executa sql server in spate queryurile? A: execution plan. Q: Cum poti altera acest plan? A: table hints
*SQL Server table hints are a special type of explicit command that is used to override the default behavior of the SQL Server query optimizer during the T-SQL query execution This is accomplished by enforcing a specific locking method, a specific index or query processing operation, such index seek or table scan, to be used by the SQL Server query optimizer to build the query execution plan.*

- Apropo de table hints, daca vrei sa te asiguri ca nu apar deadlock-uri pe tabel, cu ce poti decora query-ul? hint with(nolock) ; dezavantaje?
- dar daca query-ul dureaza foarte mult - ce verifici? primary keys, index clustered, index non-clustered; cum alegi coloana dupa care faci indexul clustered? de ce?
- tabele temporare - avantaje/dezavantaje
- CTE-uri - exemplu practic?
- ai lucrat cu **tranzactii in SQL**? ce sunt?
- faci un update cu o clauza where si vrei sa stii cate raduri au fost modificate de comanda? ce folosesti ? @@rowcount


The **default transaction isolation level in SQL Server is the READ COMMITTED** isolation level, in which retrieving the changing data will be blocked until these changes are committed. **The WITH (NOLOCK) table hint is used to override the default transaction isolation level** of the table or the tables within the view in a specific query, by allowing the user to retrieve the data without being affected by the locks, on the requested data, due to another process that is changing it. In this way, the query will consume less memory in holding locks against that data. In addition to that, no deadlock will occur against the queries, that are requesting the same data from that table, allowing a higher level of concurrency due to a lower footprint. **In other words, the WITH (NOLOCK) table hint retrieves the rows without waiting for the other queries, that are reading or modifying the same data,** to finish its processing. **This is similar to the READ UNCOMMITTED transaction isolation level**, that allows the query to see the data changes before committing the transaction that is changing it. The transaction isolation level can be set globally at the connection level using the SET TRANSACTION ISOLATION LEVEL

In general, using explicit table hints frequently is considered as a **bad practice** that you should generally avoid. For the NOLOCK table hint specifically, reading uncommitted data that could be rolled back after you have read it can lead to a Dirty read



## 3. Design patterns
### Singleton
radu
### Repository / Unit of Work
The responsibilities of the Unit of Work are to:
- Manage transactions.
- Order the database inserts, deletes, and updates.
- Prevent duplicate updates. Inside a single usage of a Unit of Work object, different parts of the code may mark the same Invoice object as changed, but the Unit of Work class will only issue a single UPDATE command to the database.

## 4. Clean coding / refactoring

https://github.com/trupci/interviu-net/tree/master/WebTest

Un endpoint GET care aduce o lista de rapoarte din baza de date (nume raport, tip raport(reprezentat prin booleeni)). Peste lista din baza, din cod se formeaza url-ul de raport, care contine o serie de parametri encodati intr-un token, in functie de tipul de raport(sursa - eg CrystalReports, ReportServer).
### Cerinte
### 1. Scrie un test pentru controller care sa verifice ca in metoda GetReports se apeleaza metoda GetReports din repository.
Este acest cod testabil?
Daca vreau sa scriu teste - ce modific din cod?


### 2. Apare o noua sursa de date(ExcelReports)
 pentru rapoarte si url-ul pentru aceste tipuri de rapoarte este de felul urmator:
`/ExcelReport?encryptionKey={key}`
unde {key} este citit dintr-un fisier de pe disc.

Remarks:
de folosit dependency injection in constructor la ReportsController - cum se adauga chestii in service provider, ce scopes exista? Ce e SINGLETON - ce avem in vedere cand folosim singleton (memory consumption,thread safety)
3. code smells: se repeta bucata de requestClaims/userclaims
4. daca vreau sa adaug un tip nou de rapoarte pe langa IsCrystal si IsReporting - cum refactorizam? De folosit enum in loc de cele 3 booleane, poate scos un factory pentru acel Url.


## 6. HTTP
1. Ai de implementat un web CHAT.

- endpoint design - verbs, etc
- cum primesti mesajele in timp real? 
- authorization
- logging
- monitoring
- security concerns (attacks, etc)
    - message encryption
    - DDoS (Distributed Denial of Service)
    - 
- caching


trimitere mesaj: POST /message
{message, to, from}
- from luat din identity? cum

primesti mesages: GET/messages
{message, from}

introducem prieteni
GET /friends
Stiind ca sunt perioade in care se trimit foarte multe mesaje(ai spike-uri) - ce fel de infrastructura alegi pentru deployment?
Cum scalezi?




Sa zicem ca nu poti sa trimiti mesaje decat la prietenii tai. Restrictii din UI + restrictii din BE.

Daca trimit mesajul "<script>alert(window.cookies);</script>"

"';DROP TABLE Users;"



Daca unul din endpointuri are timpi mari de raspuns, ce faci? 
Vrei sa adaugi un feature nou, in etape (nu pentru toata lumea in acelasi timp). Cum faci?


## 7. Algoritmica
Se da un sir de caractere format doar din 2 tipuri de caracter: "[", "]", "(", ")". Sa se scrie / descrie un algoritm care valideaza daca sirul de caractere primit la intrare este unul valid. Un string se numeste valid daca fiecare set de paranteze este deschis si inchis corect:
```
Exemplu:

Input: []
Output: OK

Input: [[][]]
Output: OK

Input: [[[]][]]
Output: OK

Input: [[]
Output: NOK

Input: [[][]]]
Output: NOK

Input: ][
Output: NOK

Input: [([)]]]
Output: NOK

Input: [()[]]
Output: NOK

Input: []][[]
Output: NOK

```