Part III Flashcards
(30 cards)
How to turn off lazy loading for navigation property in EF?
By not making it virtual.
How to save changes to whole entity graph in EF?
Compare objects keys to default ones. If default then Context.Entry(object).State is Added else Modified.
How to improve performance of inserting, removing collections in EF?
By using DbSet.AddRange, InsertRange.
How to handle concurrency in EF with rowversion and DB-first?
Add new column of type rowversion (8 bytes incremented number for whole database). In EF diagram set properties of this column concurrency to fixed. Then all update will dheck it.
What’s the information expert principle?
It states that responsibility should be given to a class which contains all the information to handle it i.e. look at the classes and decide.
What are 2 main purposes of controller in GRASP?
To execute a system operation (adding user, adding item to cart), second is providing a layer between UI and domain models.
What flexibility give us the controller in GRASP?
We can change user interface without changing the logic - e.g. change web to terminal.
What are some points to favor composition over inhertiance?
Composition gives you runtime execution. Possible smaller number of classes.
What is indirection in GRASP?
A principle that states that interaction between objects is done via intermediate object to preserve low coupling (e.g. introducing Configuration class not providing config values directly in clients).
What’s the association, composition and aggregation? How to draw them in UML?
Association states that classes uses each other somehow. Composition is a relationship in which child cannot exist without parent (house and room), and in aggregation it can exist independently (car and engine). Composition - filled diamond (by parent), aggregation - empty diamond, association - straight line, may have arrows
What are the main parts of state pattern?
Context and state.
What is covariance?
Returning or assigning more derived types than declared.
What is contravariance?
Assinging or providing parameters of less generic types than declared.
What’s the difference between tier and layer?
Layer is logical, tier is physical.
What are the parts of 3-tier application?
Presentation, application and data.
What are main layers of application?
Presentation, application, business logic, data.
Rules for lazy loading in EF?
In cofiguration: LazyLoadingEnable, ProxyCreationEnabled and particular property should be public virtual
What’s the concurrency model in EF? How to handle it (example).
Optimistic concurrency. A row of type rowversion (timestamp) must be added to tables. It’s incremented each time an operation is done on a row. Then in database designer select this column and set concurrency as fixed. Only then exception about concurrency wil be thrown.
How is .NET Core lifecycle different from .NET Framework?
.NET Core is also build using MsBuild. It is then executed by CoreCRL (on different OS-es) which uses JiT compiler. The process is hosted using dotnet.exe process (it hosts CoreCRL and code) .NET Core can also be prebuilt to native code using AoT.
What is AoT?
Ahead of Time compiler which compiles (currently only UWP). Compiler is called .NET Native. It produces package of native code that is then executed by CoreCRL.
How many CLR instances are there in Windows for .NET Framework?
Separate instance for each .NET process.
How is Xamarin app built?
First MsBuild then Xamarin Compiler which generates IL for Android (dll, exe) which is then executed by Mono Runtime (similar to .NET Core). On IoS Xamarin Compiler generates native code using AOT (ARM language).
How fody works?
It’s IL weaving. It has a MsBuild post build action which modified IL generated code.
What is weaving? What types of weaving are there?
Weaving is adding some additional code to application. It can be done to a source code or to IL code.