Skip to content

Instantly share code, notes, and snippets.

@nickmarden
Last active December 1, 2021 03:15
Show Gist options
  • Save nickmarden/6aa826349f8aab80430ac5808b05e7cd to your computer and use it in GitHub Desktop.
Save nickmarden/6aa826349f8aab80430ac5808b05e7cd to your computer and use it in GitHub Desktop.

PLEASE NOTE: Do not publicly post your answers on this Gist, please forward them to your recruiting contact instead ;-)

1. Voting

Each voter can vote in zero or more referenda. Each referendum has one or more questions, and each question is a yes/no vote. Write the simplest normalized schema to describe this in generic SQL statements or as an entity-relationship diagram. Point out where the indexes would be if you want to quickly know the results of a given referendum question, but you never expect to query a single voter's voting record. In what way does the nature of the application affect your design judgment about privacy, and what effect would that have on normalization considerations?

2. Rewriting history with git

You've getting ready to submit a pull request to the coolapp repo. You branch contains two commits: M, followed by N. The lineage is this:

main:   X --> Y --> Z (HEAD commit is Z)
                     \
your-branch:          M --> N (HEAD commit is N)

You want to contribute the code back to the official coolapp repo, but you realize there is a really dumb typo in one of your source code comments (not commit messages) in commit M. You'd still like to submit the pull request as two commits M' and N', where M' is the fixed version of M, and N' is the same exact diff as N. How do you rewrite git history to make this happen? Is N' the same hash as N? Why or why not?

3. SignalR Demo

Write a sample application that does the following:

  • Creates a SignalR hub that exposes at least one server method with complex data types in its signature
  • Establishes a connection to the SignalR hub to one or more clients and sending a complex object complexObj to all of the clients at once. From the clients’ point of view, how is the receipt of the object handled?
  • Invokes a named method clientMethod(complexObj) on a single connected client

4. So Many Conversations At Once!

You need to write a server that can handle hundreds or even thousands of chat conversations simultaneously. You have chosen to model this with Conversation objects, each of which contains a list of ConversationLog (timestamp + participant name + message) objects. Each Conversation can be updated concurrently by the multiple participants in that conversation by adding new ConversationLog entries to the Conversation.

Write .NET code that accomplishes the following:

  • Defines the data classes Conversation and ConversationLog that hold the conversation data. The Conversation object must be able to receive new ConversationLog entries without blocking. The order of new conversation log entries is important!
  • Defines a third class, whose name is not specified, that houses the list of all Conversation objects. This class should allow Conversations to be added or removed from it in a thread-safe manner.

5. My User List Isn’t Working!

A UsersList component should display a list of users. Once we click on one user, a profile information needs to be displayed, however there's a bug and the profile information is not shown correctly.

a) Identify the cause of the profile issue and describe how it could be corrected.

b) Where is the best place in the UsersList component to call getAllUsers?

import React from 'react';
import { getUserDetails, getAllUsers } from './requests';
 
class UsersList extends React.Component {
  constructor(props) {
	//...
  }
 
  //...
 
  handleUserSelection = (userId) => {
	this.setState({userId});
	getUserDetails(this.state.userId, this.handleUserDetailsResponse);
  }
 
  //...
 
  render() {
	return (
  	<div>
    	{/* ... */}
  	</div>
	);
  }
}

6. JavaScript

The class below contains information about users assigned to operators.

a) Identify 2 bugs in the Operators class.

b) How would you implement the getNumberOfUsersPerOperator method?

export default class Operators {
  constructor() {
	this.operatorsInfo = {};
	this.addUserToOperator = this.addUserToOperator.bind(this);
  }
 
  //...
 
  addUserToOperator(userId, operatorId) {
	operatorsInfo[operatorId] = [...operatorsInfo[operatorId], userId];
  }
 
  getNumberOfUsersPerOperator() {
	//...
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment