Cover by Jennifer Greene, Andrew Stellman

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

Chapter 5. Encapsulation: Keep your privates... private

image with no caption

Ever wished for a little more privacy?

Sometimes your objects feel the same way. Just like you don’t want anybody you don’t trust reading your journal or paging through your bank statements, good objects don’t let other objects go poking around their fields. In this chapter, you’re going to learn about the power of encapsulation. You’ll make your object’s data private, and add methods to protect how that data is accessed.

Kathleen is an event planner

She’s been planning dinner parties for her clients and she’s doing really well. But lately she’s been having a hard time responding to clients fast enough with an estimate for her services.

image with no caption

When a new client calls Kathleen to do a party, she needs to find out the number of guests, what kind of drinks to serve, and what decorations she should buy. Then she uses a pretty complicated calculation to figure out the total cost, based on a flow chart she’s been using for years. The bad news is that it takes her a long time to work through her chart, and while she’s estimating, her potential clients are checking out other event planners.

It’s up to you to build her a C#-driven event estimator and save her business. Imagine the party she’ll throw you when you succeed!

What does the estimator do? ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required