Notes from Creating N-Tier Applications in C#, Part 2 Pluralsight Course
— software development, coding, pluralsight — 2 min read
Steve Smith's Pluralsight course Creating N-Tier Applications in C#, Part 2 goes into more detail about N-Tier Applications.
I recently completed Creating N-Tier Applications in C#, Part 2 by Steve Smith.
Here are my notes from Creating N-Tier Applications in C#, Part 1.
Here are my notes from Part 2:
Testing
- Unit tests in an n-tier application should generally only care about one of your tiers (which should be in its own project file); integration tests will likely care about several tiers, and possibly also have some external dependencies on databases, etc.
- Mocks are a useful tool in unit tests, but should generally be used for tests of behavior, rather than tests of state
- If you're working in a shared repository, you should run all tests before checking in (also, make sure you're using the latest version and make sure your code builds)
Persistence
- All objects in an application are constructed, then spend some time being active and perhaps are modified. Finally they are disposed of.
- Objects should know nothing about if/how they are persisted (SRP!)
- It's important that objects are consistent throughout the application
- This is most applicable in scenarios where changes are made and then saved
- "An interface should be designed to make the wrong things hard and the right things easy."
- Object-Relational Mappers (ORMs) (e.g. Microsoft Entity Framework)
- Code-First Entity Framework - create entities and tell Entity Framework to map them to the database
- Consider The Repository Pattern and/or The Unit of Work Pattern
Core Logic Reuse
- "Holy Grail of Software" = code reuse
- software components should be like LEGOs
- Dependency Inversion Principle -> depend on interfaces, not specific implementation
- related to IOC containers, which are essentially "factories on steroids"
- aids code reuse
- DTO = Data Transfer Object - typically a class full of data, no behavior
Thanks for reading! I hope you find this and other articles here at ilyanaDev helpful! Be sure to follow me on Twitter @ilyanaDev.