O'Reilly logo

Head First C#, 3rd Edition by Andrew Stellman, Jennifer Greene

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. Objects: Get Oriented!: Making code make sense

image with no caption

Every program you write solves a problem.

When you’re building a program, it’s always a good idea to start by thinking about what problem your program’s supposed to solve. That’s why objects are really useful. They let you structure your code based on the problem it’s solving, so that you can spend your time thinking about the problem you need to work on rather than getting bogged down in the mechanics of writing code. When you use objects right, you end up with code that’s intuitive to write, and easy to read and change.

How Mike thinks about his problems

Mike’s a programmer about to head out to a job interview. He can’t wait to show off his C# skills, but first he has to get there—and he’s running late!

image with no caption

How Mike’s car navigation system thinks about his problems

Mike built his own GPS navigation system, which he uses to help him get around town.

Mike’s navigation system solves the street navigation problem the same way he does.

Mike’s Navigator class has methods to set and modify routes

Mike’s Navigator class has methods, which are where the action happens. But unlike the button_Click() methods in the forms you’ve built, they’re all focused around a single problem: navigating a route through a city. That’s why Mike stuck them together ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required