Chapter 3. Objects: Get Oriented!: Making code make sense
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!
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 ...
Get Head First C#, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.