Designing and Architecting Blazor Applications Flashcards

1
Q

Why Blazor instead of the well known javascript frameworks?

A

Written in c# and razor syntax.
Can leverage existing .net standard nuget packages.
Powerfull tooling.
Fully supported by Microsoft.
Blazor also is likelly to be faster than JS due the fact it runs over web assembly.

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

What does it mean saying that Blazor is make in a “component driven design”?

A

It means the pages are built using different components. Reusable components.

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

What are the main benefits of Blazor?

A

Depenendy Injection, Hosting Options, Standarized Packages, Javascript Interop.

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

What is the role of a service in a MVC project?

A

It sits between the controller and the repository. Useful when some business logic is necessary.

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

When to use parameter dependency injection and when to use constructor dependency injection?

A

Parameter dependency injection is used for components and the constructor (most common) dependency injection is used for services.

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

How to inject a logger into a blazor component?

A

By simply add a inject parameter of the type ILogger

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

What is a Blazor circuit?

A

Is the context of a connection of a user/tab to our blazor server (not applicable to Blazor web assembly).

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

What is a scoped service lifecycle?

A

It means the same instance of the service will be used along in the same Blazor circuit (aka context)

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

What is a blazor route constraint?

A

It allows enforcing a specific param type to a route.

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

How can we monitor page changes in the blazor app?

A

With the LocationChanged event from the RouteManager class

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

What is a razor class library?

A

Allows creating and consuming common components to achieve re-usability. Can be published as a nuget package.

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

Only UI components can be packed in razor class lib ?

A

No… also functional libs can be packed into razor comps.

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

How to create a nuget package out of a razor class lib?

A

By simply selecting “Pack” in visual studio.

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

How to manage user’s state in the app (e.g: grid preferences)?

A

By using local or session storage.

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

What is the local storage?

A

It is owned by the browser and it stores all the tabs… non-secure data… good for keeping user preferences like hidden notifications and etc.

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

What is the session storage?

A

more secure… prevents data be loaded by a different user. scoped to the opened tab, then auto deleted.

17
Q

Are local and session storage truly secure?

A

No. data is still somehow accessible - mitigated by encryption, but still need to be careful.

18
Q

What is the recommended way to interact with the browser storage?

A

ProtectedBrowserStorage nuget package.. is still on Alpha. Need to change the host.cshtml to RenderMode.Server and add the js from the nuget package.

19
Q

what is a common automatically generated API documentation?

A

swashbuckle swagger.

20
Q

What is the correct way of using a HTTPClient in .net core? When was it introduced?

A

Via HTTPClientFactory. Introduced on .net 2.1

21
Q

How http client can be used?

A

By typed HTTP clients and client factory directly.

22
Q

how to instantiate a typed http client?

A

It looks more complicated that it is… all it is needed is a generic Timplementation of tclient… can be done using a simple anonymous method.

23
Q

Does Blazor has its own http client lib?

A

Yes… it simplifies the unmarshalling.

24
Q

what to do when the api expects key value pairs instead of a json (used to be like this in forms)?

A

Define a dictionary of the fields, then use link to create a url encoded string. then do the send async.

25
Q

what is fiddler useful for?

A

To debug web requests in and outside the browser.

26
Q

What to do when the model class gets too big?

A

The model class should be broken down on sub classes. Then the subclasses can be added to the model itself as non-primitive types.

27
Q

Does the data validation work out-of-the-box with nested classes? What about the persistence?

A

No. Persistence works fine. Because the default validation is property validation, not the whole model validation.

28
Q

Does Blazor allow custom validations on property and model levels?

A

Yes. Just inherit from ValidationAttribute and define the classname as the data annotation validation.

29
Q

Does Blazor provide a validation nuget package to handle these nested classes?

A

Yes. Blazor.DataAnnotations.Validation. Via [ValidateComplexType] attribute.

30
Q

How to create a custom validation for a model object?

A

By implementing the IValidatableObject.

31
Q

Is Blazor and .net core open source?

A

Yes. available on github.