# General Programming Interview Questions
+ Please answer the questions based on your understanding and knowledge. If you don't know, just answer you don't know.
+ Some questions have standard answers, some do not. However, the important thing is not about the correctness of answers, but how you understand those issues, how do you find answers, and how do you solve problems.
+ You can answer based on things inside your brain, or you can find answers from anywhere. However, if you got answers from other places, please cite the source of the information.
+ Some questions are related to experience. If you don't have relevant experience, please imagine how you would deal with it in this situation.
+ Please use the programming language you are familiar with the most to do the coding questions, or use the programming language that job description is required (if any). The coding questions will give examples in `JavaScript`.
+ You're not allowed to reproduce all or part of the content without permission.
## Ways of Thinking Questions
### Q1. There are many factors and aspects in programming. Please explain the meaning of the terms down below, then sort them in an order that you think is following the importance and priority and explain why you sort them this way.
> + Performance
> + Scalability
> + Reliability
> + Maintainability
> + Reuseability
> + Extensibility
> + Readability
> + Testability
> + Availability
> + Security
### Q2. What are traits of good developers? Why? What traits do you have? What traits don't you have?
### Q3. When you're learning a new technology, what are your learning methods, approaches, and strategies? Why?
## Concepts Questions
### Q4. What are the pros and cons of object-oriented programming? Why?
### Q5. What are functions, usages, and purposes of using variables? What are good usages? What are bad usages? Why?
### Q6. What is refactoring? How do you do refactoring? When do you need to do refactoring? How do you ensure that the original functions won't be broken after you did the refactoring?
## Technical Questions
### Q7. In some programming languages (e.g., JavaScript),Why does 0.1 + 0.2 not equal 0.3 precisely? How do you solve this problem?

### Q8. What is Method Chaining? What are the pros and cons? Where is it suitable to use? Where is it not suitable to use?
### Q9. What is unit testing? What is it used for? What codes should be tested? What codes should not be tested? Why do many people think it's difficult? Does software without any unit testing indicate the quality is bad? Does software with completed and detailed unit testing indicate the quality is good?
## Coding Questions
### Q10. Please follow the requirements to write a filter method.
This is a booking system for house cleaning. Here are the requirements:
> * As a `person who only does busy business`, I want a `housekeeper` to clean my house so that I can be a couch potato and melt in front of the TV.
> * As a `cat's slave`, I want a `housekeeper` to clean my house so that my cat emperor accepts the cleanliness and is able to mess it up later.
> * As a `college girl`, I want a `female housekeeper` to clean my house so that no filthy guys can enter my secret room.
> * As a `college boy`, I only need a `one-hour cleaning service` because there is no other furniture besides my bed and TV.
> * As a `housekeeper`, I want to set a `service city` (it'd better to be the same `district`) so that I won't ride my scooter for thousand miles.
> * As a `housekeeper`, I want to set `minimum service hours` so that I won't ride for three hours but clean for half an hour.
> * As a `housekeeper`, I want to be able to `abandon` orders that I don't like so that I don't have to meet some annoying `customers`.
> * As a `platform operator`, I hope `customers` can rate `housekeepers` so that we can reward good ones and punish bad ones.
> * As a `platform operator`, I hope we can log `housekeepers`' `abandonment rates` because picky eaters won't grow well.
> * As a `platform operator`, I need the system to be able to auto-assign `housekeepers` for `customers` based on `service addresses`, `satisfaction stars`, `abandonment rates` so that I won't have to hire a lot of customer service staff.
Please follow the matching rules down below to write a method to assign a `housekeeper`. You don't have to consider the database connection or software architecture.
First, use filter conditions to narrow down the range.
> 1. When an `order` wants a `specific gender`, filter by the gender.
> 2. A `housekeeper` can decide the `minimum service hours` to take. If the service hours of an `order` are too low, it won't be matched.
> 3. The `housekeeper` who provides services has to live in the `service city`.
> 4. If a `housekeeper`'s `resident zip code` is as same as the `service zip code`, then, use `service zip code` as the filter condition, and get rid of `housekeepers` who live in different `resident zip codes`.
> 5. If there is no `housekeeper` whose `resident zip code` is as same as the `service zip code`, then, remain the same filter condition. Only use `service city` for filter condition.
After filtered, please follow the sort conditions to sort results.
> 1. the person who has more `satisfaction stars` gets first.
> 2. the person who has a lower `abandonment rate` gets first.
💥Oops, you got a problem!
Theoretically, the top one will be the designated `housekeeper`. However, you realized the `satisfaction stars` and `abandonment rate` are hard to change in a short time period.
For example, for those orders made on the same day, the `satisfaction stars` and `abandonment rate` of `housekeepers` are almost the same because those scores will be given by customers after the services are done.
To avoid always assigning the same `housekeeper`, please design a weighting mechanism to do a random assignment. Let the high order `housekeeper` have a higher chance to be assigned, but avoid always assigning the top one.
Here are the examples of `housekeeper` and `order`:
```javascript=
/* a housekeeper to serve **/
const housekeeper = {
/* gender **/
gender: 'female',
/* resident city **/
residentCity: 'Taipei',
/* resident zip code **/
residentZipCode: 100,
/* satisfaction stars (total is 5) **/
stars: 4.3,
/* abandonment rate **/
abandonmentRate: 0.02,
/* accept orders that have pets **/
acceptPets: true,
/* minimum service hours (inclusive) **/
minimumHours: 2,
}
```
```javascript=
/* an order from a customer **/
const order = {
/* service hours (required) **/
serviceHours: 2,
/* service city (required) **/
serviceCity: 'Taoyuan',
/* service zip code (required) **/
serviceZipCode: 320,
/* the gender that a customer required (optional) **/
specificGender: 'male',
/* whether has pets (optional) **/
hasPets: true,
}
```
Your method signature would be like:
```javascript=
// all housekeepers
const allHousekeepers = [housekeeper1, housekeeper2, ... ]
// the designated housekeeper after filtered
const designatedHousekeeper = findMatchedHousekeeper(order, allHousekeepers)
```
### Q11. Please write a method to find all dates of Sunday(s) between two dates.
For example, find all Sunday(s) between `2021-08-01` and `2021-08-31`.
In this case, it should return `2021-08-08`, `2021-08-15`, `2021-08-22`, `2021-08-29`.
### Q12. Please write a method to determine that all time slots in a set are not overlapped.
The picture down below shows all cases between two time periods (overlapped or not overlapped). `After`, `Start Touching`, `End Touching`, `Before` are considered `not overlapped`.

Here are example arrays of time slots:
```javascript=
const overlappedSlots = [
{ start: '08:00', end: '11:00' },
{ start: '10:00', end: '17:00' },
{ start: '16:00', end: '19:00' },
]
const nonOverlappedSlots = [
{ start: '08:00', end: '10:00' },
{ start: '13:00', end: '16:00' },
{ start: '16:00', end: '19:00' },
]
```
Please write a method that takes a `time slots array` as a `parameter`, and return a `boolean` to indicate that all time slots are `not overlapped`.
## Projects Questions
### Q13. What is the most common problem in team-based development? How would you solve it?
### Q14. How can you clarify and verify clients' needs when they are unable to correctly tell you what exactly they want? How to avoid potential needs?
### Q15. How do you do time estimates? What are the reasons for the time estimates that are accurate and inaccurate? Is doing time estimates really useful?
## Optional Questions (not-scored)
### Q16. Why do some people say that laziness is a virtue of programmers?
### Q17. Project managers always say: "Getting things done before making it perfect," is this statement feasible? why?
### Q18. What is the craziest, most ridiculous, most bizarre, most incredible, and most unbelievable thing you have ever done? Why?