Where design ends, code begins β and why the boundary is not a wall.
π Where this lives: the belief that design finishes and then coding starts is the single most persistent misconception about software development, and it survives because it describes how buildings are made. Software differs in one decisive way: the act of writing code teaches you things about the design that no amount of diagramming reveals. That is why every serious process β iterative, agile, or otherwise β puts coding inside the design loop rather than after it. Search "design is not a phase continuous design".
Implementation in the development cycle
The OBJECT-ORIENTED IMPLEMENTATION phase takes the design
artefacts and expresses them in a programming language.
THE INPUTS, all produced in ACtE0804 and ACtE0805:
DESIGN CLASS DIAGRAM β class definitions, fields, method
signatures, visibility
INTERACTION DIAGRAMS β method BODIES: the sequence of
messages a method sends
OPERATION CONTRACTS β preconditions as guards,
postconditions as what the method
must achieve
USE CASE EXTENSIONS β exception handling and the test
cases
DOMAIN MODEL β the vocabulary; the class and
method names
SUPPLEMENTARY SPEC β transaction boundaries, timeouts,
logging, security
A WELL-SPECIFIED DESIGN MAKES IMPLEMENTATION LARGELY
MECHANICAL. That is the claim, and it is substantially true for
the structural parts β a class diagram maps to class
definitions almost line for line. It is LESS true for the
algorithmic interiors, which is why implementation still
requires judgement.
THE ITERATIVE REALITY, and the important point of this topic:
IMPLEMENTATION FEEDS BACK INTO DESIGN. Writing the code
reveals things the diagrams could not:
Β· a method that turns out to need information nobody gave
it β a visibility decision was wrong
Β· a class that grows to 400 lines while its siblings are 40
β a responsibility was misassigned
Β· a test that requires six doubles to write β the fan-out
is too high, per the collaboration topic
Β· duplicated logic in three classes β a missing abstraction
Β· an interaction that cannot be made transactional β a
boundary is in the wrong place
NONE OF THESE IS A CODING PROBLEM. Each is a DESIGN DEFECT
that only became visible in code, and the correct response is
to change the design β which is why the phases are activities
within an iteration rather than stages in a sequence.
THE TWO WRONG RESPONSES to design/code divergence:
(a) FORCE THE CODE TO MATCH THE DIAGRAM, accepting a design
you now know is wrong because it was signed off. This
produces working code that fights itself.
(b) IGNORE THE DIAGRAM and let the code diverge silently.
The model becomes stale, which the modelling topic
established is worse than having no model.
THE CORRECT RESPONSE: update the design, or delete the part
of it that is no longer true.
The order of implementation
WHICH CLASS DO YOU WRITE FIRST? The answer follows the
dependency structure, not the diagram's layout.
THE PRINCIPLE: implement classes from LEAST-COUPLED to
MOST-COUPLED, so that when you write a class, the things it
depends on already exist.
A DEPENDENCY-ORDERED PLAN for the licence issuance subsystem
from ACtE0805:
STEP 1 β VALUE OBJECTS AND ENUMERATIONS (no dependencies)
Money, ApplicationNo, LicenceNo, OfficerId,
PaymentMethod, Status
These depend on nothing but the language. They are also the
easiest to test β a pure function of their inputs β and
getting Money right early prevents the currency defect
appearing in ten places.
STEP 2 β SIMPLE DOMAIN ENTITIES (depend only on step 1)
Payment, StatusChange, Licence
Each holds value objects and has little behaviour.
STEP 3 β THE AGGREGATE ROOT (depends on 1 and 2)
Application β which holds Payments, StatusChanges and a
Licence, and enforces the invariants
This is where the real behaviour lives, and where the
interesting tests are.
STEP 4 β INTERFACES (depend on 1β3 for their signatures)
ApplicationRepository, LicenceNumberPool, EventPublisher
Declared in the domain package, per dependency inversion.
STEP 5 β HANDLERS / CONTROLLERS (depend on 1β4)
IssueLicenceHandler, RecordPaymentHandler
Testable with in-memory doubles for the step-4 interfaces,
and needing no database at all.
STEP 6 β INFRASTRUCTURE IMPLEMENTATIONS (depend on 4)
PostgresApplicationRepository, SequenceNumberPool,
InProcessEventPublisher
STEP 7 β PRESENTATION (depends on 5)
the HTTP endpoints or screens
WHY THIS ORDER PAYS: at every step, everything you need already
exists and is tested. You never write a class against a
collaborator that does not yet compile, and you never need a
stub for something you are about to write anyway.
A USEFUL PROPERTY OF THIS ORDER: steps 1β5 are the whole
business behaviour, and none of them requires a database, a
web server or a network. THE ENTIRE DOMAIN AND APPLICATION
LAYER CAN BE BUILT AND TESTED BEFORE ANY INFRASTRUCTURE EXISTS
β which is the hexagonal-architecture payoff from the
analysis-to-design topic, realised as a work plan.
THE ALTERNATIVE ORDER β OUTSIDE-IN (starting from the use case
and letting each layer's needs drive the next) is also
legitimate and pairs naturally with test-driven development:
write the failing acceptance test, then the handler, then
discover what the domain must offer. Both orders converge; the
dependency order is easier when the design is already detailed,
and outside-in is better when the design is still being
discovered.
Coding standards and the practices that matter
CODING STANDARDS are the product standards of the SQA topic,
applied at the source level. Their purpose is not tidiness but
COMPREHENSIBILITY: the reader of a line of code is usually not
its author, and often not its author's colleague.
WHAT A CODING STANDARD SHOULD COVER:
NAMING classes are nouns in PascalCase; methods
are verbs in camelCase; constants in
UPPER_SNAKE; no abbreviations that are not
domain terms
LAYOUT indentation, line length, brace placement β
the parts a FORMATTER should enforce, so
that no human argues about them
COMMENTS what to comment (WHY, not WHAT) and the
documentation-comment format for public
APIs
ERROR HANDLING which exceptions to use, what never to
swallow, whether to check or unchecked
FILE STRUCTURE one public class per file; member ordering
LANGUAGE which features are permitted β no raw
SUBSET types, no mutable statics, no reflection in
business code
TESTS naming and structure of test methods
THE RULE FROM THE SQA TOPIC APPLIES HERE MOST OF ALL: A
STANDARD ENFORCED BY A TOOL COSTS NOTHING TO FOLLOW; A STANDARD
IN A DOCUMENT COSTS AN ARGUMENT IN EVERY REVIEW. Formatting
belongs to a formatter, naming and structure to a linter, and
only the genuinely judgemental parts to human review.
NAMING FROM THE DOMAIN β the practice with the highest return.
The glossary of ACtE0804 is the source of names:
β `ApplicationDTO`, `AppMgr`, `procData()`, `flag2`
β `Application`, `IssueLicenceHandler`, `recordPayment()`,
`isReconciled`
Every name taken from the domain reduces the
representational gap; every invented technical name widens
it. A method called `procData` obliges every future reader to
read its body.
COMMENTS β the discipline that is most often got wrong:
β // increment i by one
i++;
β // set status to issued
this.status = ISSUED;
β // The licence number is allocated BEFORE the status
// change so that a failed allocation leaves no
// half-issued application (use case UC-05, ext. 5a).
A comment restating the code is noise that will fall out of
date. A comment explaining WHY β a non-obvious ordering, a
workaround for an external system's behaviour, a reference to
the requirement β is the most valuable text in a codebase,
because it is the only place that information exists.
THE PRACTICES THAT DISTINGUISH IMPLEMENTATION QUALITY:
TEST-FIRST OR TEST-ALONGSIDE from the test automation
topic: written after the
fact, tests get skipped
under pressure
SMALL COMMITS from the change management
topic: review effectiveness
collapses with diff size
REFACTOR CONTINUOUSLY the design concept from
ACtE0802 β improve structure
without changing behaviour,
under the protection of the
tests
REVIEW EVERY CHANGE the highest-return SQA
activity, at 57.8Γ in the
worked example
STATIC ANALYSIS IN CI catches the defect classes a
human reviewer reads past
THE ONE-LINE SUMMARY: implementation quality is decided less by
cleverness than by whether the feedback loops β tests, reviews,
static analysis, small changes β are short enough to catch
mistakes while they are still cheap.
The build order has a property worth noticing: steps 1 through 5 contain all the business behaviour and require no infrastructure at all. You can implement and test the entire domain and application layer before a database exists β which turns the layering rule from an architectural principle into a practical work plan.
π Go further: the strongest version of "code feeds back into design" is test-driven development, where the test is written first and the design emerges from the difficulty of testing. Its real mechanism is not verification but pressure: a class that is hard to instantiate in a test has too many dependencies, a method that needs elaborate setup has too many responsibilities, and you feel that pain before the code exists rather than after. TDD is best understood as a design technique that produces tests as a by-product, not a testing technique that happens to affect design. Search "TDD as a design tool listen to the tests".
π‘ Exam angle: list the design artefacts that feed implementation and state what each contributes β class diagram to declarations, interaction diagrams to method bodies, contracts to guards, extensions to exception handling and tests. Explain why implementation feeds back into design, with examples of design defects that only appear in code, and state the two wrong responses. Describe the dependency order of implementation and why it avoids stubs. Cover coding standards β what they should specify, the principle that tool-enforced standards cost nothing, and the comment discipline of explaining why rather than what.
Syllabus points
OO development/programming process
Create a free account to tick topics off, take notes as you read, watch the video lessons and get a day-by-day study plan built around your exam date.
Related topics in Object-Oriented Design Implementation