Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
July 23, 2018, 12:58:23 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register Chat  
Pages: [1]   Go Down
  Print  
Author Topic: Question 6  (Read 1841 times)
acedwards
Newbie
*
Posts: 2


Email
« on: July 09, 2009, 08:13:22 AM »

I just want to make sure I'm understanding all the conceptual distinctions as I go along in addition to hacking through the actual coding. Question 6 distinguished between an object based approach and a procedural approach.  I'm guessing that in a procedural approach to what we see in number 5, rather than:

[myVehicle prep];
[myVehicle getGas];

we would have

[myCar prep], [myBoat prep] etc?

Is that the distinction?  General vs. specific? 

If so then I can see a disadvantage, in that a procedural approach seems to involve more code and repetition while an object based approach is more flexible.  Am I missing something?  I can see how the procedural approach might make it easier to keep things straight in your mind if you weren't planning on working with too many different vehicle types.

Just trying to get a firm grasp here.
Logged
skochan
Administrator
Hero Member
*****
Posts: 3114



« Reply #1 on: July 09, 2009, 09:10:06 PM »

Yes, I think you're on the right track here.   Classes are distinct from one another.  With a procedural approach you have functions that perform operations, for example a prep function would have to be modified to accommodate new vehicle types as they are added.   With a class approach, each vehicle can be implemented as its own class, which can be independent of other vehicles defined by other classes.  Adding a new vehicle type would involve adding a new class and would typically not involve modifying any of the code for the other classes that handle the other vehicles.

Cheers,

Steve Kochan
Logged
acedwards
Newbie
*
Posts: 2


Email
« Reply #2 on: July 12, 2009, 07:10:40 PM »

Thanks Steve! 
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

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 ゥ 2009 classroomM.com. All rights reserved.