Widgets Question about Exercise 6
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 06, 2015, 08:40:22 AM
Home Help Search chat Login Register 
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan

+ Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+ Old Stuff
| |-+ Chapter Study
| | |-+ Chapter 3 - Classes, Objects, and Methods
| | | |-+ Question about Exercise 6
Pages: [1] Go Down
Author Topic: Question about Exercise 6 (Read 759 times)
Posts: 4

on: December 15, 2011, 12:43:09 PM

In a procedural language such as C, you think about actions and then write code to perform the action on various objects. Referring to the car example, you might write a procedure in C to wash a vehicle and then inside that procedure write code to handle washing a car, washing a boat, washing a motorcycle, and so on. If you took that approach and then wanted to add a new vehicle type (see the previous exercise), do you see advantages or disadvantages to using this procedural approach over an object-oriented approach?

The correct answer would be no, right? The best way to do it would be to create a class for each vehicle, or even a main class with a subclass for each specific vehicle. To add a new vehicle i would just need to implement a new subclass! The events, in each class, could essentially have the same name if i take advantage of the Polymorphism concept. I am right?

Last Edit: December 15, 2011, 12:45:14 PM by Cloaky Logged
Pages: [1] Go Up
Jump to:

Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 All rights reserved.