473,883 Members | 1,651 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

When not to use Object Oriented Programming?

Curtis Rutland
3,256 Recognized Expert Specialist
I was reading through some job postings on a game developer's web site (without any real interest of applying). One of the ones that I saw had this bullet point in the requirements:
  • Appreciation of when not to use Object Oriented Programming.
I've done almost all my work in OO languages...so can someone enlighten me? When do you not want to use OOP?
Dec 23 '08
41 18867
5,058 Recognized Expert Expert
Keeping game development in mind, I would imagine that a less complex OO structure might help increase performance.

For example, when you get into OOP you tend to tear the code up into pieces, creating methods for all tasks, even tasks that may in fact only be called from a single point in the entire application. It makes sense from a design point of view.

But from a practical point of view, simply removing the method and placing the code at that single point would reduce the overhead of calling the method, and every minor tweak counts in game development.
Dec 24 '08 #11
11,448 Recognized Expert MVP
C++ and Java HotSpot compilers are very good at inlining your code for you.

kind regards,

Dec 24 '08 #12
464 Recognized Expert Contributor
You MAY gain a slight performance advantage, but how many times have you had to go back and change a few lines of code, or have to do the same functionality in another location (after the initial piece of code is written). The point is we are not perfect programmers and things do change. If you have separate methods, the time it takes to change and modify the code is considerably less than the time it would take you if you didn't create the methods. Also correct me if I'm wrong, but isn't that the point of inline functions?
Jan 26 '09 #13
5,058 Recognized Expert Expert
I would imagine that, in game development, sacrificing the time it takes to edit multiple copies of the same code snippet is an acceptable loss, even if it only increases the performance by a tiny amount.

I'm no game developer myself, and I don't really use the languages preferred by them, so this is all theoretical in my mind. It could very well be that my example is rendered void by using the right compilers, I don't know.

But my point is still valid, even tho my example may be off target. OOP adds a layer of complexity to the application, which may degrade performance. Knowing when not to add more on top of that is probably what that ad is referring to.
Jan 26 '09 #14
11,448 Recognized Expert MVP
You point isn't valid: OOP does not add a layer of slowing down complexity to an application; it just structures the code as well as the data in contrast with procedural programming that just structures the code. Granted, some processors may execute an 'indirect subroutine call' a bit slower than a 'direct subroutine call' but those processors aren't worth the sand they were created with.

What causes a much larger slowdown are bad algorithms and silly implementations thereof. OOP offers a way to efficiently implement good algorithms. I've had similar discussions about dynamic memory allocation with Fortran fanatics; they fiddled with common blocks and overlays thereof while not realizing that all that fiddling caused a worse slowdown than any mallow/new, free/delete could've caused.

Languages that cause a slowdown when they're handling classes and objects are silly languages; better use another language/tool that does handle those concepts more efficiently. Also OOP doesn't cause larger program executables; programmers do and they shouldn't be programming using an OOPL.

kind regards,

Jan 29 '09 #15
5,058 Recognized Expert Expert
You are probably right. Like I say, I don't have any practical experience with these languages (C/C++ and other such compiled languages) so this is all theoretical to me.
I mostly use PHP, which a interpreted language, where you actually have to sacrifice performance to use OOP. That's probably the source of my confusion.

But if my assumption is not valid, what would the "Appreciati on of when not to use Object Oriented Programming." be? Seems to me that if procedural and OO programing cost the same performance vise, OOP would be the logical choice most, if not all of the time. (Unless, of course, you prefer procedural)
Jan 29 '09 #16
11,448 Recognized Expert MVP
OOP isn't the end of the line; there's also functional programming, logic programming and then some. Nor are OOP and procedural programming orthogonal concepts, e.g. there exist functional programming languages that are very well capable of modelling classes, objects, inheritance, polymorphism and the entire shebang that comes with OOP.

A lot of interpreted languages added OOP capabilities to the language as an afterthought; that's exactly one cause of the slowness. OOP features require additional code, lookups and what have you then. That additional work isn't needed in, say, Objective C or C++ or Java or C#.

Please don't stare at OOP in admiration, it is just an aspect of programming, not a one size fits all shoe. Not all OOP supporting languages use procedural, or structural, programming concepts either.

kind regards,

Jan 30 '09 #17
8 New Member
OO as a philosophy suffers from drawing a certain academic personality type - the type that can't put the textbook down and actually *do* something with what they've learned. Many of the OO ideals taught in schools and books sound beautiful and elegant, but, like poetry, cannot and should not be used in real-world dialog.

I'll give you an example: once we had a need to enhance an existing report to provide totals at the bottom. The report code iterated through a List of items,
pulling out each bean and displaying it in the report. Pretty simple stuff. The guy who went to make the enhancement for adding totals approached me, confused: "I can't seem to find a sum() or total() method on the List object." I kid you not! Poor guy - I guess from a naive, ivory-tower OO-perspective, it might seem like a List object ought to know how to total itself. But come on, what a joke! Just declare a variable called total, initialize it to zero before the loop, and then inside the loop just put a line like total += item.getAmount( ) or whatever. Boom! Done! Should be a ten minute task, including unit-testing. It just goes to show you how an ideal like OO can imbreed to the point where it is too feeble to face problems from outside itself.

OO brings some nice tools to the table, which should be used when appropriate. But you do need to know when to draw the line, and yes, OO languages encourage programing solutions that tend to be less efficient in execution and require more memory. Which is a killer for high-performance apps. (games), as well as highly-scalable apps.

Jun 12 '09 #18
11,448 Recognized Expert MVP
Well, that's a nice bunch of non sequiturs: first you mention someone who can't program himself out of a wet paper bag and then you draw this conclusion?

kind regards,

Jun 12 '09 #19
32,584 Recognized Expert Moderator MVP

Do you have any experience with programming OO at all? It doesn't seem to me like you have much of an understanding of the subject. It can be a culture shock to those steeped in procedural programming I know.

It's probably not a great idea to make comparisons though, until you have a better grasp of the subject. That works quite generally I find.
Jun 12 '09 #20

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Pmb | last post by:
Hi. I'm new to this group. I'm refreshing/learning C++ and am starting to learn Object Oriented Programming (OOP). In discussing this with people I came up short as to what the benefits of OOP are. For example: As I understand it, OOP has its main benefit in software reuse. Thus one develops a software library of classes and this cuts down the overhead of reinventing the wheel. Someone might say that this can be done with structured...
by: Rookie | last post by:
Is C an object oriented programming language?
by: Dale | last post by:
I've searched Amazon and read probably 100 reviews but can't find what seems to be any book that is widely accepted as the definitive book on object oriented programming design and techniques. And most of the highest rated are all written 10 to 15 years ago. Any good suggestions?
by: David Lozzi | last post by:
Howdy, I've discovered how to create and use a class in ASP.NET. However, when is the best time to use a class? For example, I am currently using session variables to store user information (user id, user name, full name, security level, department, etc.). Would I do better to create a class instead? Also, if I did, would I simply store the ID in the session and when accessing the class (User.FullName, User.SecurityLevel, etc.) then check the...
by: Mike Polinske | last post by:
I am new to the C programming language but have been programming in Cobol for over 10 years. When I compile the following code, it compiles clean but I get an application error both under Windows XP and Win2K. #include <stdio.h> #include <ctype.h> char title = "Year End Report";
by: Thierry Chappuis | last post by:
Hi, I'm interested in techniques used to program in an object-oriented way using the C ANSI language. I'm studying the GObject library and Laurent Deniau's OOPC framework published on his web site at http://ldeniau.web.cern.ch/ldeniau/html/oopc/oopc.html. The approach is very instructive. I know that I could do much of this stuff with e.g. C++, but the intellectual challenge of implementing these concepts with pure ANSI C is relevant to...
by: ajba74 | last post by:
Hi fellows, I am reading some books to learn the C programming language, and sometimes I have the feeling that when somebody becomes a C expert, he must learn a more modern and object-oriented language. When I read things like "... C++ is an evolution of C ..." or "... C is a subset of C++ ..." I tend to believe that I will have to learn C+ + sooner or later. It sounds like C++ is the future and C is the past (and will be no longer...
by: Joe Mayo | last post by:
I think I become more and more alone... Everybody tells me that C++ is better, because once a project becomes very large, I should be happy that it has been written in C++ and not C. I'm the only guy thinking that C is a great programming language and that there is no need to program things object oriented. Many people says also that they save more time by programming projects object oriented, but I think its faster to program them in a...
by: notnorwegian | last post by:
i have some confusion over this. sure a class is basically a classification, like for example an animal or flower. and an object/instance of that class is then for example a cat. an object is an instance of a class. that i know, i also know how to program with classes etc. i am just confused about the term object-oriented.
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.