Design Patterns and Code Quality Flashcards

1
Q

In a REST API how would you structure the project.

A

Start with SOLID.
Define solid.
Persistence base, and specific implementation.
Service Layer as an abstraction layer between other application logic and the client logic.
client layer which controls the HTTP type logic…

https://java-design-patterns.com/patterns/service-layer/

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

How would you approach error handling in an web application?

A

I would start with the different classes of errors 400, 500 etc…

Then you might want a class or library for specific types of errors. Server unavailable or service internals often means clients can retry and you just want them to bubble up.

Other client errors you would want to be more specific about.

You can catch specific classes of errors in your application and decide how you want to handle them…

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

Define and write a factory pattern?

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

Define and write singleton pattern?

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

What is depdendency injection and why use it?

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

How does dependency injection differ from a singleton?

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

What is the lifetime of objects in an application created by dependency injection?

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