Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
arialdomartini committed May 22, 2020
1 parent 367ae8f commit ed136e9
Showing 1 changed file with 97 additions and 28 deletions.
125 changes: 97 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,38 +48,107 @@ Sooner or later I will complete it with the relative answers. Feel free to contr

### [[]](#toc) <a name='patterns'>Questions about Design Patterns:</a>

* Why are global and static objects evil? Can you show it with a code example? [Answer](#why-are-global-and-static-objects-evil-can-you-show-it-with-a-code-example)
* Tell me about Inversion of Control and how it improves the design of code. [Answer](#tell-me-about-inversion-of-control-and-how-it-improves-the-design-of-code)
* The Law of Demeter (the Principle of Least Knowledge) states that each unit should have only limited knowledge about other units and it should only talk to its immediate friends (sometimes stated as "don't talk to strangers"). Would you write code violating this principle, show why it is a bad design and then fix it? [Answer](#user-content-the-law-of-demeter-the-principle-of-least-knowledge-states-that-each-unit-should-have-only-limited-knowledge-about-other-units-and-it-should-only-talk-to-its-immediate-friends-sometimes-stated-as-dont-talk-to-strangers-would-you-write-code-violating-this-principle-show-why-it-is-a-bad-design-and-then-fix-it)
* Active-Record is the design pattern that promotes objects to include functions such as Insert, Update, and Delete, and properties that correspond to the columns in some underlying database table. In your opinion and experience, which are the limits and pitfalls of the this pattern? [Answer](#active-record-is-the-design-pattern-that-promotes-objects-to-include-functions-such-as-insert-update-and-delete-and-properties-that-correspond-to-the-columns-in-some-underlying-database-table-in-your-opinion-and-experience-which-are-the-limits-and-pitfalls-of-the-this-pattern)
* Data-Mapper is a design pattern that promotes the use of a layer of Mappers that moves data between objects and a database while keeping them independent of each other and the mapper itself. On the contrary, in Active-Record objects directly incorporate operations for persisting themselves to a database, and properties corresponding to the underlying database tables. Do you have an opinion on those patterns? When would you use one instead of the other? [Answer](#data-mapper-is-a-design-pattern-that-promotes-the-use-of-a-layer-of-mappers-that-moves-data-between-objects-and-a-database-while-keeping-them-independent-of-each-other-and-the-mapper-itself-on-the-contrary-in-active-record-objects-directly-incorporate-operations-for-persisting-themselves-to-a-database-and-properties-corresponding-to-the-underlying-database-tables-do-you-have-an-opinion-on-those-patterns-when-would-you-use-one-instead-of-the-other)
* Why is it often said that the introduction of `null` is a "billion dollar mistake"? Would you discuss the techniques to avoid it, such as the Null Object Pattern introduced by the GOF book, or Option types? [Answer](#why-is-it-often-said-that-the-introduction-of-null-is-a-billion-dollar-mistake-would-you-discuss-the-techniques-to-avoid-it-such-as-the-null-object-pattern-introduced-by-the-gof-book-or-option-types)
* Many state that, in Object-Oriented Programming, composition is often a better option than inheritance. What's you opinion? [Answer](#many-state-that-in-object-oriented-programming-composition-is-often-a-better-option-than-inheritance-whats-you-opinion)
* What is an Anti-corruption Layer? [Answer](#what-is-an-anti-corruption-layer)
* Singleton is a design pattern that restricts the instantiation of a class to one single object. Writing a Thread-Safe Singleton class is not so obvious. Would you try?
* The ability to change implementation without affecting clients is called Data Abstraction. Produce an example violating this property, then fix it. [Answer](#the-ability-to-change-implementation-without-affecting-clients-is-called-data-abstraction-produce-an-example-violating-this-property-then-fix-it)
* Write a snippet of code violating the Don't Repeat Yourself (DRY) principle. Then, fix it. [Answer](#write-a-snippet-of-code-violating-the-dont-repeat-yourself-dry-principle-then-fix-it)
* How would you deal with Dependency Hell? [Answer](#how-would-you-deal-with-dependency-hell)
* Is goto evil? You may have heard of the famous paper "Go To Statement Considered Harmful" by Edsger Dijkstra, in which he criticized the use of the `goto` statement and advocated structured programming instead. The use of `goto` has always been controversial, so much that even Dijkstra's letter was criticized with articles such as "'GOTO Considered Harmful' Considered Harmful". What's your opinion on the use of `goto`? [Answer](#is-goto-evil-you-may-have-heard-of-the-famous-paper-go-to-statement-considered-harmful-by-edsger-dijkstra-in-which-he-criticized-the-use-of-the-goto-statement-and-advocated-structured-programming-instead-the-use-of-goto-has-always-been-controversial-so-much-that-even-dijkstras-letter-was-criticized-with-articles-such-as-goto-considered-harmful-considered-harmful-whats-your-opinion-on-the-use-of-goto)
* The robustness principle is a general design guideline for software that recommends "*be conservative in what you send, be liberal in what you accept*". It is often reworded as "*be a tolerant reader and a careful writer*". Would you like to discuss the rationale of this principle?
* Separation of Concerns is a design principle for separating a computer program into distinct areas, each one addressing a separate concern. There are a lot of different mechanisms for achieving Separation of Concerns (use of objects, functions, modules, or patterns such as MVC and the like). Would you discuss this topic?
#### Globals are evil
Why are global and static objects evil? Can you show it with a code example? <br/>
[Answer](#why-are-global-and-static-objects-evil-can-you-show-it-with-a-code-example)
<br/>

#### Inversion of Control
Tell me about Inversion of Control and how it improves the design of code.<br/>
[Answer](#tell-me-about-inversion-of-control-and-how-it-improves-the-design-of-code)


#### Law of Demeter
The Law of Demeter (the Principle of Least Knowledge) states that each unit should have only limited knowledge about other units and it should only talk to its immediate friends (sometimes stated as "don't talk to strangers").<br/>
Would you write code violating this principle, show why it is a bad design and then fix it?<br/>
[Answer](#user-content-the-law-of-demeter-the-principle-of-least-knowledge-states-that-each-unit-should-have-only-limited-knowledge-about-other-units-and-it-should-only-talk-to-its-immediate-friends-sometimes-stated-as-dont-talk-to-strangers-would-you-write-code-violating-this-principle-show-why-it-is-a-bad-design-and-then-fix-it)

#### Active-Record
Active-Record is the design pattern that promotes objects to include functions such as Insert, Update, and Delete, and properties that correspond to the columns in some underlying database table. In your opinion and experience, which are the limits and pitfalls of the this pattern?<br/>
[Answer](#active-record-is-the-design-pattern-that-promotes-objects-to-include-functions-such-as-insert-update-and-delete-and-properties-that-correspond-to-the-columns-in-some-underlying-database-table-in-your-opinion-and-experience-which-are-the-limits-and-pitfalls-of-the-this-pattern)

#### Data-Mapper
Data-Mapper is a design pattern that promotes the use of a layer of Mappers that moves data between objects and a database while keeping them independent of each other and the mapper itself. On the contrary, in Active-Record objects directly incorporate operations for persisting themselves to a database, and properties corresponding to the underlying database tables. Do you have an opinion on those patterns? When would you use one instead of the other?<br/>
[Answer](#data-mapper-is-a-design-pattern-that-promotes-the-use-of-a-layer-of-mappers-that-moves-data-between-objects-and-a-database-while-keeping-them-independent-of-each-other-and-the-mapper-itself-on-the-contrary-in-active-record-objects-directly-incorporate-operations-for-persisting-themselves-to-a-database-and-properties-corresponding-to-the-underlying-database-tables-do-you-have-an-opinion-on-those-patterns-when-would-you-use-one-instead-of-the-other)

#### Billion Dollar Mistake
Why is it often said that the introduction of `null` is a "billion dollar mistake"? Would you discuss the techniques to avoid it, such as the Null Object Pattern introduced by the GOF book, or Option types?<br/>
[Answer](#why-is-it-often-said-that-the-introduction-of-null-is-a-billion-dollar-mistake-would-you-discuss-the-techniques-to-avoid-it-such-as-the-null-object-pattern-introduced-by-the-gof-book-or-option-types)

#### Inheritance vs Composition
Many state that, in Object-Oriented Programming, composition is often a better option than inheritance. What's you opinion?<br/>
[Answer](#many-state-that-in-object-oriented-programming-composition-is-often-a-better-option-than-inheritance-whats-you-opinion)

#### Anti-corruption Layer
What is an Anti-corruption Layer?<br/>
[Answer](#what-is-an-anti-corruption-layer)

#### Singleton
Singleton is a design pattern that restricts the instantiation of a class to one single object. Writing a Thread-Safe Singleton class is not so obvious. Would you try?

#### Data Abstraction
The ability to change implementation without affecting clients is called Data Abstraction. Produce an example violating this property, then fix it.<br/>
[Answer](#the-ability-to-change-implementation-without-affecting-clients-is-called-data-abstraction-produce-an-example-violating-this-property-then-fix-it)

#### Dont't Repeat Yourself
Write a snippet of code violating the Don't Repeat Yourself (DRY) principle. Then, fix it.<br/>
[Answer](#write-a-snippet-of-code-violating-the-dont-repeat-yourself-dry-principle-then-fix-it)

#### Dependency Hell
How would you deal with Dependency Hell?<br/>
[Answer](#how-would-you-deal-with-dependency-hell)

#### Goto is Evil
Is goto evil? You may have heard of the famous paper "Go To Statement Considered Harmful" by Edsger Dijkstra, in which he criticized the use of the `goto` statement and advocated structured programming instead. The use of `goto` has always been controversial, so much that even Dijkstra's letter was criticized with articles such as "'GOTO Considered Harmful' Considered Harmful". What's your opinion on the use of `goto`?<br/>
[Answer](#is-goto-evil-you-may-have-heard-of-the-famous-paper-go-to-statement-considered-harmful-by-edsger-dijkstra-in-which-he-criticized-the-use-of-the-goto-statement-and-advocated-structured-programming-instead-the-use-of-goto-has-always-been-controversial-so-much-that-even-dijkstras-letter-was-criticized-with-articles-such-as-goto-considered-harmful-considered-harmful-whats-your-opinion-on-the-use-of-goto)

#### Robustness Principle
The robustness principle is a general design guideline for software that recommends "*be conservative in what you send, be liberal in what you accept*". It is often reworded as "*be a tolerant reader and a careful writer*". Would you like to discuss the rationale of this principle?

#### Separation of Concerns
Separation of Concerns is a design principle for separating a computer program into distinct areas, each one addressing a separate concern. There are a lot of different mechanisms for achieving Separation of Concerns (use of objects, functions, modules, or patterns such as MVC and the like). Would you discuss this topic?


### [[]](#toc) <a name='design'>Questions about Code Design:</a>

* It is often said that one of the most important goals in Object-Oriented Design (and code design in general) is to have High Cohesion and Loose Coupling. What does it mean? Why is it that important and how is it achieved?
* Why do array indexes start with '0' in most languages?
* How do tests and TDD influence code design?
* Write a snippet of code violating the Don't Repeat Yourself (DRY) principle. Then, explain why it is a bad design, and fix it.
* What's the difference between cohesion and coupling?
* What is refactoring useful for?
* Are comments in code useful? Some say they should be avoided as much as possible, and hopefully made unnecessary. Do you agree?
* What is the difference between design and architecture?
* In TDD, why are tests written before code?
* C++ supports multiple inheritance, and Java allows a class to implement multiple interfaces. What impact does using these facilities have on orthogonality? Is there a difference in impact between using multiple inheritance and multiple interfaces? Is there a difference between using delegation and using inheritance? [This question is from The Pragmatic Programmer, by Andrew Hunt and David Thomas]
* What are the pros and cons of holding domain logic in Stored Procedures?
* In your opinion, why has Object-Oriented Design dominated the market for so many years?
* What would you do to understand if your code has a bad design?
#### High Cohesion, Loose Coupling
It is often said that one of the most important goals in Object-Oriented Design (and code design in general) is to have High Cohesion and Loose Coupling. What does it mean? Why is it that important and how is it achieved?

#### Index 0
Why do array indexes start with '0' in most languages?

#### TDD
How do tests and TDD influence code design?

#### DRY violation
Write a snippet of code violating the Don't Repeat Yourself (DRY) principle. Then, explain why it is a bad design, and fix it.

#### Cohesion vs Coupling
What's the difference between cohesion and coupling?

#### Refactoring
What is refactoring useful for?

#### Code comments
Are comments in code useful? Some say they should be avoided as much as possible, and hopefully made unnecessary. Do you agree?

#### Design vs Architecture
What is the difference between design and architecture?

#### Early Testing
In TDD, why are tests written before code?

#### Multiple Inheritance
C++ supports multiple inheritance, and Java allows a class to implement multiple interfaces. What impact does using these facilities have on orthogonality? Is there a difference in impact between using multiple inheritance and multiple interfaces? Is there a difference between using delegation and using inheritance? [This question is from The Pragmatic Programmer, by Andrew Hunt and David Thomas]

#### Domain Logic in Stored Procedures
What are the pros and cons of holding domain logic in Stored Procedures?

#### OOP took over the world
In your opinion, why has Object-Oriented Design dominated the market for so many years?

#### Bad Design
What would you do to understand if your code has a bad design?


### [[]](#toc) <a name='languages'>Questions about Languages:</a>
Expand Down

0 comments on commit ed136e9

Please sign in to comment.