Part III Flashcards
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.