Homework
Homework
It is a virtual machine that executes managed code, code that is executed by the CLR (Common Language
Runtime) and that has been compiled from C# or VB .Net.
It works as follows:
1. you make a program in C# or VB .Net and compile it, this is translated to CIL (Common Intermediate
Language).
2. Subsequently, the program is assembled to bytecode to generate a CLI (Common Language Infrastructure)
assembly file that can be .exe or .dll.
3. You run the program (or use the DLL) and this is executed by the .Net framework CLR (Common Language
Runtime), not by the operating system directly, for this reason it is called "Managed Code".
4. The .Net Framework CLR, by means of the JIT compiler (Just In Time Compiler), is in charge of compiling
this managed code in intermediate language to native machine language assembler, so that it can be
executed by the CPU.
The CIL (Common Intermediate Language) is the language understood by the .Net Framework.
4. What is a delegate?
It is a definition of a method, it encapsulates certain arguments and return type. It allows to pass a method
as an argument of a function, as long as it respects the definition.
5. What is LINQ?
It is a standardization for querying data and converting it into objects, regardless of the source. It is a query
manager for databases, xml and enumerable collections using a single language.
6. How does LINQ work?
Internally it constructs the correct query (in the case of databases) or generates the corresponding
operations on the collections or parses the xml and returns the corresponding data. It encapsulates all these
behaviors and provides a single implementation, so that we can use the same queries, the same language,
regardless of the underlying data source.
7. What is deferred execution and immediate execution in LINQ?
Deferred execution is encapsulating the query definition, but not executing it until runtime data is used.
Immediate execution sends to call the query at the same time of its definition.
By default, the executions are deferred, but we can make them immediate by calling ".ToList()" for example,
in this way, it will be executed and will return a list of objects at the moment we define it.
8. What is an object and a class?
An object is an instance of a class and a class is a template to create objects, it is the definition of an object,
the description of its characteristics and operations, its properties and methods. An object has identity
because its characteristics have values.
9. What is inheritance, polyformism and encapsulation?
Inheritance is the ability to reuse definitions from one class in another, it is the ability to base one class on
another.
Polyformism is being able to declare the same method within a class with different arguments or different
return type.
Encapsulation is being able to expose only the methods, property and arguments necessary to use the
operations of a class, while its detailed implementation remains private, hidden from other objects.
21. What is the difference between encrypting a password and hashing it?
Hashing (MD5 or SHA1, for example) cannot be decrypted, to validate the password we must have the
password in plain text, hash it and compare it against the stored one. An encrypted password, if we have the
keys and we know the encryption algorithm (like Triple-DES for example) we can obtain the password in
plain text from the encrypted password.
- What's a delegate ?
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 its instance with any method with a compatible
signature and return type. You can invoke (or call) the method through the delegate instance
- Have you work with events on ?
An event is a notification sent by an object to signal the occurrence of an action. ... In C#, an event is an
encapsulated delegate. It is dependent on the delegate. The delegate defines the signature for the event
handler method of the subscriber class
- Do you know what linq is ?
- What does the 'where' clause works ?
Entity Framework
- Do you know Lazy loading is when working with entity framework ?
is the process whereby an entity or collection of entities is automatically loaded from the database the first
time that a property referring to the entity/entities is accessed. Lazy loading means delaying the loading of
related data, until you specifically request for it. what lazy loading
- What would approaches would you use to generate a database for a new project using entity framework ?
It could be Code First or Database First.
I would use Code First
- When would you use each one of then ?
Code First modeling workflow targets a database that doesn't exist and Code First will create it. It can also be
used if you have an empty database and then Code First will add new tables to it. Code First allows you to
define your model using C# or VB.Net classes..
Database First allows you to reverse engineer a model from an existing database. The model is stored in an
EDMX file (. edmx extension) and can be viewed and edited in the Entity Framework Designer. The classes
that you interact with in your application are automatically generated from the EDMX file
- What is a migration ?
Migrations provide a way to control schema changes in the DB and Entity Framework Core Migrations
updates the database schema instead of creating a new database
ASP.NET Core
- Have you work with .NET Core ?
Builder Patterns
Permite producir diferentes tipos y representaciones de un objeto utilizando el mismo código de
construcción. Se utiliza para la creación etapa por etapa de un objeto complejo combinando objetos simples.
La creación final de objetos depende de las etapas del proceso creativo, pero es independiente de otros
objetos.
Factory Method
Proporciona una interfaz para crear objetos en una superclase, pero permite que las subclases alteren el tipo
de objetos que se crearán. Proporciona instanciación de objetos implícita a través de interfaces comunes
Prototype
Permite copiar objetos existentes sin hacer que su código dependa de sus clases. Se utiliza para restringir las
operaciones de memoria / base de datos manteniendo la modificación al mínimo utilizando copias de
objetos.
Singleton
Este patrón de diseño restringe la creación de instancias de una clase a un único objeto.
Patrones estructurales
Facilitan soluciones y estándares eficientes con respecto a las composiciones de clase y las estructuras de
objetos. El concepto de herencia se utiliza para componer interfaces y definir formas de componer objetos
para obtener nuevas funcionalidades.
Adapter
Se utiliza para vincular dos interfaces que no son compatibles y utilizan sus funcionalidades. El adaptador
permite que las clases trabajen juntas de otra manera que no podrían al ser interfaces incompatibles.
Bridge
En este patrón hay una alteración estructural en las clases principales y de implementador de interfaz sin
tener ningún efecto entre ellas. Estas dos clases pueden desarrollarse de manera independiente y solo se
conectan utilizando una interfaz como puente.
Decorator
Este patrón restringe la alteración de la estructura del objeto mientras se le agrega una nueva funcionalidad.
La clase inicial permanece inalterada mientras que una clase decorator proporciona capacidades adicionales.
Proxy
Se utiliza para crear objetos que pueden representar funciones de otras clases u objetos y la interfaz se
utiliza para acceder a estas funcionalidades
Interpreter
Se utiliza para evaluar el lenguaje o la expresión al crear una interfaz que indique el contexto para la
interpretación.
Iterator
Su utilidad es proporcionar acceso secuencial a un número de elementos presentes dentro de un objeto de
colección sin realizar ningún intercambio de información relevante.
Mediator
Este patrón proporciona una comunicación fácil a través de su clase que permite la comunicación para varias
clases.
Strategy
Permite definir una familia de algoritmos, poner cada uno de ellos en una clase separada y hacer que sus
objetos sean intercambiables.
Template method
Se usa con componentes que tienen similitud donde se puede implementar una plantilla del código para
probar ambos componentes. El código se puede cambiar con pequeñas modificaciones.
Visitor
El propósito de un patrón Visitor es definir una nueva operación sin introducir las
modificaciones a una estructura de objeto existente.
S: Principio de responsabilidad única
Como su propio nombre indica, establece que una clase, componente o microservicio debe ser
responsable de una sola cosa (el tan aclamado término “decoupled” en inglés). Si por el contrario,
una clase tiene varias responsabilidades, esto implica que el cambio en una responsabilidad
provocará la modificación en otra responsabilidad.
O: Principio abierto/cerrado
Establece que las entidades software (clases, módulos y funciones) deberían estar abiertos para su
extensión, pero cerrados para su modificación.
Declara que una subclase debe ser sustituible por su superclase, y si al hacer esto, el programa
falla, estaremos violando este principio.
Este principio establece que los clientes no deberían verse forzados a depender de interfaces que
no usan.
Los módulos de alto nivel no deberían depender de módulos de bajo nivel. Ambos deberían
depender de abstracciones.
Las abstracciones no deberían depender de detalles. Los detalles deberían depender de
abstracciones.