Implement an interactive CLI class with tests

Read the full interview experience this question came from →

Quick Overview

This question evaluates object-oriented design, command-line interface implementation, persistent state management, input validation and error logging, extensibility for new commands, comprehensive unit testing, and continuous integration configuration.

Implement an interactive CLI class with tests

Company: Shopify

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Design and implement a command-line interactive application as a single class using OOP principles. The program should support commands: add <key> <value>, get <key>, delete <key>, list, help, and exit; persist state to a local file; validate and handle invalid input gracefully; log errors; and be easily extensible for new commands. Write comprehensive unit tests that cover happy paths, edge cases (e.g., duplicate keys, missing keys, malformed commands), and error handling. Include a README with local setup instructions, how to run tests, and a GitHub workflow (e.g., Actions) that runs the test suite on push. Explain your class design (state, methods, dependency boundaries), how you would refactor to support subcommands/modules, and trade-offs you made under a 60-minute time constraint.

Overview: This question evaluates object-oriented design, command-line interface implementation, persistent state management, input validation and error logging, extensibility for new commands, comprehensive unit testing, and continuous integration configuration.

Read the full Shopify Machine Learning Engineer interview experience this question came from

|Home/Coding & Algorithms/Shopify
Shopify logo
Shopify
Aug 13, 2025
mediumMachine Learning EngineerOnsiteCoding & Algorithms
15
0

Design and implement a command-line interactive application as a single class using OOP principles. The program should support commands: add <key> <value>, get <key>, delete <key>, list, help, and exit; persist state to a local file; validate and handle invalid input gracefully; log errors; and be easily extensible for new commands. Write comprehensive unit tests that cover happy paths, edge cases (e.g., duplicate keys, missing keys, malformed commands), and error handling. Include a README with local setup instructions, how to run tests, and a GitHub workflow (e.g., Actions) that runs the test suite on push. Explain your class design (state, methods, dependency boundaries), how you would refactor to support subcommands/modules, and trade-offs you made under a 60-minute time constraint.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...