From the course: C#: Design Patterns Part 1

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Solution: Class adapter vs. object adapter

Solution: Class adapter vs. object adapter - Python Tutorial

From the course: C#: Design Patterns Part 1

Solution: Class adapter vs. object adapter

(upbeat music) - [Instructor] Were you able to change the adapter pattern we were using in the view model? The class adapter, wasn't the best tool for the job here but it was worth trying out so that we can understand why. In the order item view model, I removed the private order and instead extended the order class. This allowed the removal of properties that we didn't modify down here on lines 31 through 34 but it meant that I had to override the total due and the order date properties since we want to present string versions of those properties. Rather than referencing the order in these properties we can use the orders properties directly except where we need to use the base, like we're doing here for the total due and the order date. However, the view model is now really muddied up the display properties with the original orders properties. So back up here, you can see I've created the interface I order item view model.…

Contents