InterviewStack.io LogoInterviewStack.io

Code Quality, Error Handling, and Defensive Programming Questions

Writing robust, high-quality code that fails safely. Covers defensive programming, input validation, error handling and fault tolerance, logging for diagnosability, and general engineering-quality standards. Includes anticipating failure modes and making code resilient to bad inputs and unexpected states.

EasyTechnical
32 practiced

Describe the secure and defensive coding practices a data scientist must follow when shipping model code and data pipelines to production. Provide an example of how you would manage secrets in a CI/CD pipeline as part of your answer.

MediumTechnical
25 practiced

Describe the role of assertions and invariants in maintaining code correctness. When should assertions be used versus throwing exceptions? Provide an example where an assertion detects a developer error early and avoids a costly runtime check in production, and describe how this maps to design-by-contract thinking (preconditions, postconditions, invariants).

MediumTechnical
39 practiced

Your feature store becomes temporarily unavailable. Describe specific strategies you would use to keep online model predictions available in a degraded but safe form. Explain the trade-offs for accuracy, fairness, and user experience, and how you would test the fallback behavior.

MediumTechnical
25 practiced

Design a Java logging helper that redacts common PII, such as email addresses, Social Security numbers, and credit-card numbers, from log messages before they are written. State your assumptions, show the use of compiled regular-expression patterns, discuss the performance considerations, explain how you would configure the helper to extend the redaction patterns, and describe how you would test and validate it at scale. Also cover what structured fields you would include (for example a correlation ID and a job or request identifier), what you would log at INFO versus DEBUG level, and how the approach differs for a nightly batch scoring job versus a real-time service.

That is every published Code Quality, Error Handling, and Defensive Programming question for Data Scientist so far. Browse the other topics in this category, or practice this one interactively.