4.1 KiB
#interview #logos #pair-programming
Ricardo sent him the Minesweeper problem.
Wasn't early to the meeting. Showed up at 13:02
Console application in C#, limited GUI
Seems familiar with Visual Studio. Able to explain his basic plan to get going: two models (Cell and Board), one service to calculated neighboring cells.
Interesting choice: adding "NeighborCount" on the cell model--should the cell model know about its neighbors?
IN progress: ahs not initialized the Board property yet--how will he discover this? Got NRE when he ran this. Easily found that he missed initializing the BoardGame property, explained why it threw well. Struggle a little to initialize the multi-dimensional array correctly.
Questions:
- Can you GridSize everywhere to avoid errors?
- Does each Cell really need to know it's neighbor mine count? Or is that something the board knows about?
- Instead of a
(Row, Column)comment, is there another way we could label the values? - Is there a way to calculate the coordinates of the surrounding cells without statically constructing a list of offset pairs?
- You iterate through all cells in the board multiple times. Can you extract that logic to reuse wherever needed instead of copying it? Looking for an answer that includes passing a function to a method. His answer: method with flag to identify what to do in function.
- Can he explain why using GridSize at the property initialization level doesn't work? He couldn't explain it--he needed a const or static integer for
GridSizeinstead of a readonly class field. Opted to initialize the property at the top of the constructor. His answer: use it in the loops with the proper adjustments - Can he simplify the user input questions (like don't show option for placing a flag if no squares are revealed yet--ie, impossible to know where mine is yet), or does he want to allow a user to place flags without knowing
- How can you communicate to the user better about what's going on (found mine or tried to place flag on revealed square, for example)? His answer: create another while block, while input is not valid, keep asking, showing message
- What if someone enters a row or column that does not exist on the board?
Nits:
- Property, field and variable naming not consistent
- Not communicating to user if flag cannot be placed because cell is revealed
- Unnecessary comments
Issues:
- Reaching into the
Boardclass to set cell properties directly in theBoardGamefield instead of letting theBoardclass own manipulating theBoardGame - Mixed logic of revealing the cell with "SearchNeighbors" method logic
- Somewhat spaghetti logic
- Quite a few hard-coded numbers when they could be easily calculated
Notes:
- Using
Randomto fill 10 mines into the board, knows basics ofRandomAPI. - Speaks English very well
- Did not run the program early to see if there were errors
- Found a bug he wrote in column and row check before executing program by thinking about it logically and visualizing the board.
- Has a bug using
.Lengthof a multi-dimensional array! Will be x * y and not x as he's hoping. He figured it out without any prompting from me and usedGridSizein the check instead. - He had thoughts about the
Board.BoardGamefield--renaming it. This is a good sign to me, thinking about clearing naming something that's redundant (against the class name). - Used a
Queue<T>to do a breadth-first search of neighboring cells. - Talked through logic of revealing 0-neighboring-mine-count cells well
- Recognized duplicate logic of calculating neighboring cell coordinates and reused it
- Decided to have property to keep track of number of revealed cells instead of recalculating number each time the user plays.
His thoughts on things to improve code?
- Valid input of users
- Fix revealing same cell twice
- Logic of checking if user won: should work, but not happy with it. Its highly dependent on logic of revealing cells. So it's fragile. Would prefer to more independent process where user won.
- Moving logic to BFS outside of class., thinking about single responsibility principle. Searching the board is task of the board, however.