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?

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

**

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:

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.

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.

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.

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.

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.

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.

Emphasis added.

Stop thinking about you and start thinking about your team.

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.

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.

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.

It is not true.

**

Very strange. The user ID “davidthefat” no longer exists.

Hmmm.:confused:

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.

Perhaps he no longer has a team affiliation.

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.

Apparently, my account was lost during the server crash.

Now this shows up as my first post

They’re both Turing complete, so difference in functionality shouldn’t be an issue :slight_smile:

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).

From a technical sense, Java does make multiple copies of an object. But in practice this doesn’t mean what most people think of as making multiple copies of an object. An object is intantiated in Java, the object references a memory location at which the data is stored. If you create another object and set it equal to the first object (such as when you pass it while calling a method) you do create a copy with the same data. But since that data is the the memory location where the “real” data that defines the object is located, when you change the copy you are changing the original.

OK, that was too confusing. Consider this:
Cat A = new Cat(“Kitty”);
Cat B = A;
B.changeName(“Spike”);
System.out.println(A.getName());
/* This code prints out ‘Spike’ because both A and B are referencing (you can think of it as ‘pointing at’ if this helps) the same location in memory. */

As for decisions on what language and style to use, as several commenters have posted, you should be asking yourself what is best for the team? And not just for this year but for the future. And you might also consider that using the language with which you are less comfortable will expand your own programming talents.

To some of the other respondents - David’s original question has very, very little to do with unimportant aspects of language differences, and almost everything to do with organizing teams.

David - While the programming topic might be interesting. It is also unimportant.

You shouldn’t continue to let trivial differences between languages distract you. It is evident from the opening paragraph of your OP that you realize the real subject of your question, so deal with that subject.

Work with the team mentors to agree on an approach that puts service before self.

Leaders serve.

Blake

Welcome to ChiefDelphi! :smiley: :ahh: :ahh: :ahh:

Object Oriented programming is still procedural (but with OBJECTS!). Was this something about the choice of language instead? If it is (like I think it is), do what others have said and just pick the one most people agree on.

Basically, all languages are fundamentally the same (OK, except things like Erlang and Haskell, but we’ll ignore those…) so the only real difference is available libraries and syntax. I personally choose Java because of the huge standard library (which is, sadly, diminished in the microedition) and because I hate how the WPILib has things named in C++ (I loathe the Microsoft coding style).

Anyway, you could pretty easily learn Java. Especially with NetBeans and the Javadocs. If you like to use pointers, though, you’ll probably beat your head against your desk sometimes…

If you were the only programmer, or you only had two student programmers, then yes, I’d suggest explaining to the mentor why you chose that language, and stick with it, while teaching the other student at the same time.

But with 8? You pretty much need to stop worrying about what YOU think would be best for only YOU, and start thinking about what would be best for the TEAM. As Don pointed out, building the robot is only the tool used to build the future leaders, innovators, and businesspeople of the world.

By the way, one way to convince your mentor to use C++, is to show that you’re willing to teach the others how to use that language. And before you say anything (I’ve read your posts regarding teammates), don’t underestimate your teammates. You’ve still got 5 weeks. That’s plenty of time.