Enterprise Software Engineering with C# and .NET: Architecture, Design Patterns, and AI-Enabled Systems · HIT

Week 2   Part I · C# and .NET Foundations

Modern C# for Enterprise Domain Models

Instructor lesson plan: lecture (2 h) and practice (2 h).

Learning objectives

Tools this week

C# 12+domain examplesLINQLINQPad optional

🎓Lecture · 2 hours

0:00-0:1010 minRecap and retrieval
  • Review domains and use cases from week 1.
  • Ask what belongs in code before any API exists.
0:10-0:3525 minModern C# type choices
  • Records, init-only properties, required members, readonly members, nullable reference types.
  • Entity identity versus value equality in C# terms.
0:35-1:0025 minGenerics and reusable policies
  • Generic collections, typed identifiers, result types, and reusable validation policies.
  • Abstractions as contracts at boundaries, not decoration around every class.
1:00-1:1010 minLINQ and exceptionsQueries, transformations, and domain-specific failures.
1:10-1:2010 minBreak
1:20-1:4525 minAsync and await at boundaries
  • Tasks, non-blocking I/O, cancellation, and common mistakes.
  • Why the domain core should not become async by accident.
1:45-2:0015 minFrom use case to modelTurn a use-case sentence into entities, value objects, and first invariants.
Common misconception to confront.

Students often think: a record is always better because it is shorter.
Set it straight: records are excellent for values and immutable data. Entities with identity and lifecycle need explicit modelling.

Check for understanding
When is a value object a good fit?
When equality is based on the contained values, such as Money, DateRange, Address, or Email.
Why should cancellation tokens appear near I/O boundaries?
They let web requests, database calls, and external calls stop work when the caller no longer needs the result.
Key takeaways.

📚Reading & resources

💻Practice · 2 hours

0:00-0:1515 minWarm-up kata
  • Implement Money as a value object.
  • Check equality and invalid currency examples.
0:15-0:5035 minDomain entities
  • Teams implement first entities for the selected domain.
  • Add constructors or factories that enforce invariants.
0:50-1:1020 minLINQ and collections
  • Write query examples over in-memory objects.
  • Discuss what should and should not become a LINQ expression.
1:10-1:2010 minBreak
1:20-1:5030 minDomain-rule examples
  • Write examples for two domain rules.
  • Use assertions that name the business expectation.
1:50-2:0010 minProject-integration briefCommit initial domain entities, value objects, and rule examples.

Project integration (this week)

PreviousWeek 1: IntroductionNextWeek 3: SOLID Principles and Clean Code