Design Flashcards

1
Q

In computer programming, a … is a reference that does not protect the referenced object from collection by a garbage collector, unlike a strong reference

A

weak reference.

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

Suppose a tree view in a Windows Forms application displays a complex hierarchical choice of options to the user. If the underlying data is large, keeping the tree in memory is inefficient when the user is involved with something else in the application. We are able to reconstruct the tree once it gets in focus. How would you reference the tree data to allow for optimal memory use.

A

By a weak reference. That would allow garbage collector to eventually reclaim the memory if needed and we would reconstruct it once it comes to be presented, and other parts might be reclaimed if not used to make memory for this one.

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

To prevent need for explicit unregistering of the event handlers, you would you which type of reference to the handler. (prevents memory leaks)

A

Weak reference.

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

Which data structures are mostly using weak references?

A

Symbol tables like weak map. Cache data structures.

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

What letters in the acronym SOLID stand for

A

Single responsibility Open/Closed Liskov substitution Interface segregation Dependency inversion

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

Which property of the software elements the “Open/Closed principle” refers to

A

Every class or other entity should be open for extension but closed for modification. This means that adding new parts of the concept like subtype or concrete implementation should not require change of the source but usage of the language tools to extend the meaning or semantics.

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

What does “interface segregation” refer to?

A

Better to have more independent interfaces than only big one. Better said, client should know only about the interface it needs to do its work and not more.

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