AAmit’s LibraryLEARN · PRACTISE · REFLECT

Customer experience and feedback loops × Programming

Business lens: Customer experience and feedback loops · Technology lens: Programming

Reading scope: Original synthetic teaching. Sources support background, not invented figures or tested outcomes.

Translate a service promise precisely

A fictional service offers a credit for delay under a deliberately simplified policy: ten rupees for each complete hour, capped at thirty rupees. The learner must implement the agreed rule and explain the result to a customer. This is an invented commercial rule, not a legal entitlement or a recommendation about compensation. Start by asking what delay measures, which clock is used and how an invalid observation is handled. The business owner approves the policy; a programmer should not silently choose rounding or eligibility because it is convenient. A useful implementation makes the calculation reproducible and separates the customer message from the internal evidence supporting the decision.

Specify inputs and boundaries

For this exercise delay is a nonnegative number of hours measured under the stipulated policy. Credit is ten times the integer number of complete hours, limited to thirty. A zero delay yields zero credit. A negative duration is invalid and should produce an explicit validation outcome rather than a negative credit or an automatic zero that conceals the defect. Define the representation used for durations and monetary output, including boundary behaviour at exactly one and three hours. Real policies may require dates, time zones, exclusions and remedies; none is supplied here. The simple rule is a learning specification whose limits must travel with its code, tests and customer explanation.

Work through representative examples

At one and a half hours, one complete hour has elapsed, so credit is ₹10. At 3.4 hours the uncapped amount is ₹30 and the cap leaves ₹30. At half an hour no complete hour has elapsed, so credit is ₹0. At four hours the uncapped amount would be ₹40 but the result remains ₹30. A negative half hour must be rejected as invalid under this specification. These examples reveal why ordinary nearest-integer rounding would implement a different policy. Displaying ₹10 in a chosen locale does not convert currency or establish eligibility. Number formatting and the calculation belong to separate stages, each with its own inputs and purpose.

Test the contract and customer message

Write separate checks for zero, just below one hour, exactly one, the cap boundary, above the cap and invalid input. A unit test asserts the expected outcome for a supplied case; passing it does not prove every possible input or integration is correct. Include an explanation that a support worker can compare against the approved rule. If the rule changes, update its version and expected examples before reusing old results. Python testing documentation supports cases and assertions, while number-formatting documentation supports display choices. Neither source confirms the fictional service's commercial policy. Keep the policy version, duration evidence and output together in the exercise so a reviewer can identify a stale rule.

Responsibility, dispute and correction

Operations establishes the recorded delay, customer service communicates the result, finance checks the credit process and the policy owner resolves exceptions. A customer may dispute the delay or policy applicability; the system needs a human review route rather than treating the calculated output as the final truth. If a programming error rounded half-hour delays upwards, inspect affected outputs and the authorised correction process. Do not repair a customer account silently without a traceable basis. Distinguish a calculation defect from incorrect source timing and a policy dispute. Each needs different evidence and ownership, even when all three produce the same customer complaint about an unexpected amount.

From beginner explanation to research

Who approves the credit policy? Whom does support assist? Whose delay evidence is used? What is a complete hour? Where is the cap applied? When does a version change take effect? Why reject negative input? Which boundary tests matter? How is a dispute reviewed? Foundation work explains the four valid examples in plain language. Undergraduate work writes a function and expected tests. Postgraduate work critiques policy ambiguity, versioning and human exceptions. Research work designs an appropriate study of explanation or dispute handling without claiming that a synthetic calculation measures real satisfaction. The portfolio contains the specification, examples, proposed tests and a customer message that accurately describes the bounded rule.

Study questions and answers

What credit applies at 1.5 hours?

One complete hour × ₹10 = ₹10 under the invented rule.

Marking guide: Credit one complete hour at ten giving ten under the stipulated floor-based rule, not fifteen.

What happens at four hours and at negative delay?

Four hours gives ₹40 before the cap and ₹30 after it. Negative delay is invalid, not a valid zero-credit observation.

Marking guide: Credit uncapped forty and capped thirty at four hours; negative delay is invalid, not a valid zero result.

Does formatting currency determine entitlement?

No. Display formatting does not establish eligibility, convert currency or change the approved calculation.

Marking guide: Credit display formatting distinct from eligibility, currency conversion and approved calculation.

Practice task

Write the complete-hour capped-credit function, specify boundary tests and draft an explanation plus a human exception route.

Sources and further reading

  • Python documentation — Decimal arithmetic
    Scope: Selected numeric representation and rounding background checked. Synthetic calculation cases use explicitly stipulated business assumptions, not a financial or tax prescription.
    Access: Public selected reading available without an account in this check. Certificates, webinar playback, hosted execution and service entitlements were not checked.
  • Python — unittest
    Scope: Selected test cases, assertions and fixtures; passing examples do not prove complete coverage.
    Access: Public reading retrieved without an account; service entitlements and hosted execution not checked.
  • MDN — Intl.NumberFormat
    Scope: Selected display formatting background; formatting is not currency conversion or commercial entitlement.
    Access: Public reading retrieved without an account; service entitlements and hosted execution not checked.

Related chapters

Interactive practice

Open workshop

Open interactive matrix reading