Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Procedural v Object Oriented Programming (http://www.chiefdelphi.com/forums/showthread.php?t=89240)

davidthefat 15-01-2011 16:10

Procedural v Object Oriented Programming
 
Today one of the mentors and I had a major miscommunication and got no progress programming wise today. I want to program the robot object oriented but the mentor wants procedural. Now you see he is not a programming mentor. Do I just listen to him and do what he wants or do what I seem fit? He and I agree that C++ is better fit, but that can not be done due to the number of programmers that do not know C++. How can I convince the mentors to let me program in C++? Its selfish, but I believe that I can write more efficient code with C++. I am not as familiar with Java than I am with C++.


I know procedural and OO is independent of the language, but I believe that OO is more efficient in C++ because I can use pointers instead of using multiple copies of the object. I planned on having "Managers" that manage everything in their "domain". Like a sensor manager, actuator manager and other managers. Now the mentor wants me to not use objects. From my experience, my way is more "efficient" code wise than his way is. So what do I do? Just do what he says?

Ether 15-01-2011 16:48

Re: Procedural v Object Oriented Programming
 
Quote:

Originally Posted by davidthefat (Post 1000881)
I know procedural and OO is independent of the language, but I believe that OO is more efficient in C++ because I can use pointers instead of using multiple copies of the object.

Not sure what you mean by this. Can you elaborate?



DonRotolo 15-01-2011 17:00

Re: Procedural v Object Oriented Programming
 
Quote:

Originally Posted by davidthefat (Post 1000881)
Now you see he is not a programming mentor.

Nope, can't see that from here.

My advice is to note the word "Team". If you are the only one who can use C++, or one of three who can while three or five others cannot, then you must consider the capabilities of the team.

If you're the only one who is good with C++, I see you as a potential bottleneck in programming. Our team would NEVER let a single student be responsible for an entire system, ain't gonna happen.

If half the programmers can do C++, then what is it the other half of the programmers will be doing?

Just because YOU can do a better job does not mean that it is best for the team. I see it only as what's best for you, and that doesn't fly in my book.


OK, now let's say you have a good case, and C++ really is a better choice. (Remember, I'm not aware of the specific situation on your team). Then it becomes your responsibility to logically explain why your way is superior for the team. Keep emotion out of it, keep your needs out of it: Why is it best for the team. Have several mentors listen to your "defense", and then accept their decision as final, with either your 100% support, or your resignation from the team - no team can have someone not fully committed to the team's decisions.


Lastly, think about why your team exists. What is the "product" delivered by the team? I can tell you it is NOT robots. It is "students", or to quote Team 1676's vision statement:
Quote:

The team’s product is inspired students with improved career skills, improved college skills, and an appreciation for their role in a science-driven and technological world.
If this is similar to what your team believes, then the other students (who do not know C++) deserve a chance to contribute and learn. Next year, teach everyone C++ between September and December so you have the flexibility.

imac256 15-01-2011 17:01

Re: Procedural v Object Oriented Programming
 
Do you guys have a programming mentor? If you do get his advice and see what he thinks. In my experience programming for FIRST robots I have used a mix of procedural and object oriented in C++ (in this case I consider procedural calling a function inside the class which the robot started to run, because with the cRIO there must be at least one class).

I do procedural calls in the code to break up the main teleop loop, so I would have a MecanumDrive() function which is called, and then that calls an OO class we wrote to get joystick information. I would create new classes if it were for sensors which we would have multiple of (our sensors for the Swerve Drive is an example), or for something we might use in future years (a class to interact with an Xbox 360 controller is an example). That way there is less repetitious code.

With that method of programming in mind, my suggestion is to use OO to program the robot, because it means that the code is better organized and therefore can be more easily fixed at competitions and during testing. And in my experience OO code has proved to be more understandable for people looking at the code because you can have calls like "FrontSensor->GetAngle();" which when reading it you can see that you are getting the angle of the front sensor.

That is just my 2 cents though.

Nadav Zingerman 15-01-2011 17:02

Re: Procedural v Object Oriented Programming
 
Quote:

Originally Posted by davidthefat (Post 1000881)
Today one of the mentors and I had a major miscommunication and got no progress programming wise today. I want to program the robot object oriented but the mentor wants procedural. Now you see he is not a programming mentor. Do I just listen to him and do what he wants or do what I seem fit? He and I agree that C++ is better fit, but that can not be done due to the number of programmers that do not know C++. How can I convince the mentors to let me program in C++? Its selfish, but I believe that I can write more efficient code with C++. I am not as familiar with Java than I am with C++.


I know procedural and OO is independent of the language, but I believe that OO is more efficient in C++ because I can use pointers instead of using multiple copies of the object. I planned on having "Managers" that manage everything in their "domain". Like a sensor manager, actuator manager and other managers. Now the mentor wants me to not use objects. From my experience, my way is more "efficient" code wise than his way is. So what do I do? Just do what he says?

The WPI Libaray basically forces you to use a lot of OOP to use it. OOP is conceptually simpler for most people, so you should probably use it.
I didn't quite understand whether the argument was about procedural vs. OOP or C++ vs. Java.

Also, your observation that Java is less efficient is incorrect. Unless you do some heavy (and most likely unnecessary) memory optimization, Java is just as efficient as C++, but easier to use (due to garbage collection). The difference is negligible. Java does not create "multiple copies" of an object. Those are pretty much pointers too, more accurately called references (This somewhat oversimplifies it). You should learn more about Java before deciding it's less efficient (It is, but only negligibly so and only if your C++ code is highly optimized).

I think that you should probably use Java if other people know that better. I find that moving from C++ to Java is easier than the other way around, plus it's more fair if there are many people that prefer Java.

davidthefat 15-01-2011 17:10

Re: Procedural v Object Oriented Programming
 
Quote:

Originally Posted by Ether (Post 1000931)
Not sure what you mean by this. Can you elaborate?


Ok from what I know, Java makes multiple copies of the object that I pass through parameters. In C++ you can just reference the object and it does not get copied into another memory location. If that is not true, my mistake.
Quote:

Originally Posted by DonRotolo (Post 1000938)
Nope, can't see that from here.

My advice is to note the word "Team". If you are the only one who can use C++, or one of three who can while three or five others cannot, then you must consider the capabilities of the team.

If you're the only one who is good with C++, I see you as a potential bottleneck in programming. Our team would NEVER let a single student be responsible for an entire system, ain't gonna happen.

If half the programmers can do C++, then what is it the other half of the programmers will be doing?

Just because YOU can do a better job does not mean that it is best for the team. I see it only as what's best for you, and that doesn't fly in my book.


OK, now let's say you have a good case, and C++ really is a better choice. (Remember, I'm not aware of the specific situation on your team). Then it becomes your responsibility to logically explain why your way is superior for the team. Keep emotion out of it, keep your needs out of it: Why is it best for the team. Have several mentors listen to your "defense", and then accept their decision as final, with either your 100% support, or your resignation from the team - no team can have someone not fully committed to the team's decisions.


Lastly, think about why your team exists. What is the "product" delivered by the team? I can tell you it is NOT robots. It is "students", or to quote Team 1676's vision statement:
If this is similar to what your team believes, then the other students (who do not know C++) deserve a chance to contribute and learn. Next year, teach everyone C++ between September and December so you have the flexibility.

Yes that is why I made the choice of staying with Java, there was only 3 programmers last year, but from that time, we have grown to around 8. That was when I made the executive decision to stay with Java for the sake of others.
Quote:

Originally Posted by imac256 (Post 1000940)
Do you guys have a programming mentor? If you do get his advice and see what he thinks. In my experience programming for FIRST robots I have used a mix of procedural and object oriented in C++ (in this case I consider procedural calling a function inside the class which the robot started to run, because with the cRIO there must be at least one class).

I do procedural calls in the code to break up the main teleop loop, so I would have a MecanumDrive() function which is called, and then that calls an OO class we wrote to get joystick information. I would create new classes if it were for sensors which we would have multiple of (our sensors for the Swerve Drive is an example), or for something we might use in future years (a class to interact with an Xbox 360 controller is an example). That way there is less repetitious code.

With that method of programming in mind, my suggestion is to use OO to program the robot, because it means that the code is better organized and therefore can be more easily fixed at competitions and during testing. And in my experience OO code has proved to be more understandable for people looking at the code because you can have calls like "FrontSensor->GetAngle();" which when reading it you can see that you are getting the angle of the front sensor.

That is just my 2 cents though.

We have 2 programming mentors, in fact, they also want C++. They made me the lead programmer and they want to take the "hands off" mentality. They do not interfere with anything unless I ask. They can't make it to 75% of the meetings. So I have to make all the executive decisions for the programmers. I am also the most experienced out of the 8. Half of them do not even show up half the time either.

Chris is me 15-01-2011 17:10

Re: Procedural v Object Oriented Programming
 
Quote:

Originally Posted by davidthefat (Post 1000881)
He and I agree that C++ is better fit, but that can not be done due to the number of programmers that do not know C++. How can I convince the mentors to let me program in C++? Its selfish, but I believe that I can write more efficient code with C++. I am not as familiar with Java than I am with C++.

Emphasis added.

Stop thinking about you and start thinking about your team.

davidthefat 15-01-2011 17:11

Re: Procedural v Object Oriented Programming
 
Quote:

Originally Posted by Ether (Post 1000931)
Not sure what you mean by this. Can you elaborate?


Ok from what I know, Java makes multiple copies of the object that I pass through parameters. In C++ you can just reference the object and it does not get copied into another memory location. If that is not true, my mistake.
Quote:

Originally Posted by DonRotolo (Post 1000938)
Nope, can't see that from here.

My advice is to note the word "Team". If you are the only one who can use C++, or one of three who can while three or five others cannot, then you must consider the capabilities of the team.

If you're the only one who is good with C++, I see you as a potential bottleneck in programming. Our team would NEVER let a single student be responsible for an entire system, ain't gonna happen.

If half the programmers can do C++, then what is it the other half of the programmers will be doing?

Just because YOU can do a better job does not mean that it is best for the team. I see it only as what's best for you, and that doesn't fly in my book.


OK, now let's say you have a good case, and C++ really is a better choice. (Remember, I'm not aware of the specific situation on your team). Then it becomes your responsibility to logically explain why your way is superior for the team. Keep emotion out of it, keep your needs out of it: Why is it best for the team. Have several mentors listen to your "defense", and then accept their decision as final, with either your 100% support, or your resignation from the team - no team can have someone not fully committed to the team's decisions.


Lastly, think about why your team exists. What is the "product" delivered by the team? I can tell you it is NOT robots. It is "students", or to quote Team 1676's vision statement:
If this is similar to what your team believes, then the other students (who do not know C++) deserve a chance to contribute and learn. Next year, teach everyone C++ between September and December so you have the flexibility.

Yes that is why I made the choice of staying with Java, there was only 3 programmers last year, but from that time, we have grown to around 8. That was when I made the executive decision to stay with Java for the sake of others.
Quote:

Originally Posted by imac256 (Post 1000940)
Do you guys have a programming mentor? If you do get his advice and see what he thinks. In my experience programming for FIRST robots I have used a mix of procedural and object oriented in C++ (in this case I consider procedural calling a function inside the class which the robot started to run, because with the cRIO there must be at least one class).

I do procedural calls in the code to break up the main teleop loop, so I would have a MecanumDrive() function which is called, and then that calls an OO class we wrote to get joystick information. I would create new classes if it were for sensors which we would have multiple of (our sensors for the Swerve Drive is an example), or for something we might use in future years (a class to interact with an Xbox 360 controller is an example). That way there is less repetitious code.

With that method of programming in mind, my suggestion is to use OO to program the robot, because it means that the code is better organized and therefore can be more easily fixed at competitions and during testing. And in my experience OO code has proved to be more understandable for people looking at the code because you can have calls like "FrontSensor->GetAngle();" which when reading it you can see that you are getting the angle of the front sensor.

That is just my 2 cents though.

We have 2 programming mentors, in fact, they also want C++. They made me the lead programmer and they want to take the "hands off" mentality. They do not interfere with anything unless I ask. They can't make it to 75% of the meetings. So I have to make all the executive decisions for the programmers. I am also the most experienced out of the 8. Half of them do not even show up half the time either.

Ether 16-01-2011 12:05

Re: Procedural v Object Oriented Programming
 
Quote:

Originally Posted by davidthefat (Post 1000951)
Ok from what I know, Java makes multiple copies of the object that I pass through parameters. If that is not true, my mistake.

It is not true.



DonRotolo 16-01-2011 12:27

Re: Procedural v Object Oriented Programming
 
Very strange. The user ID "davidthefat" no longer exists.

Hmmm.:confused:

GGCO 16-01-2011 12:40

Re: Procedural v Object Oriented Programming
 
Sounds like you're the only one who's consistently attending meetings, so if I were you I'd continue to make these executive decisions. I think you're right in doing that.

Now if half of the 8 programmers don't show up to meetings, don't bend over backwards to accommodated them. However, if you're the only one with C++ experience, and the others can't understand it, then you must put the team first and stick with Java.

gvarndell 16-01-2011 12:40

Re: Procedural v Object Oriented Programming
 
Quote:

Originally Posted by DonRotolo (Post 1001040)
Very strange. The user ID "davidthefat" no longer exists.

Perhaps he no longer has a team affiliation.

nighterfighter 16-01-2011 14:53

Re: Procedural v Object Oriented Programming
 
So, as I understand it, all 3 of the mentors agree that C++ is better, but do not wish to do it because the other programmers don't know C++?

How much do they know Java? Have they programmed the robot in Java before?

If all the Java they really know is from, say, a comp sci. class, then i would suggest sticking with C++, as you have programmed the robot in C++.

If all the Java they know is from a computer science class, then they could learn C++ really quickly.

davidthefat 16-01-2011 19:28

Re: Procedural v Object Oriented Programming
 
Quote:

Originally Posted by DonRotolo (Post 1001040)
Very strange. The user ID "davidthefat" no longer exists.

Hmmm.:confused:

Quote:

Originally Posted by gvarndell (Post 1001056)
Perhaps he no longer has a team affiliation.

Apparently, my account was lost during the server crash.

Now this shows up as my first post

JewishDan18 16-01-2011 20:36

Re: Procedural v Object Oriented Programming
 
They're both Turing complete, so difference in functionality shouldn't be an issue :)

In my experience doing both, the code written is so similar that I made the decision to use Java simply because I like Netbeans better than Windriver (especially since I use Ubuntu).


All times are GMT -5. The time now is 13:04.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi