Advertisement
Guest User

Has OOP Failed?

a guest
Jan 2nd, 2017
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.07 KB | None | 0 0
  1. Has
  2. OOP Failed?
  3. By Richard Mansfield
  4. September 2005
  5.  
  6. Computer programming today
  7. is in serious difficulty. It is
  8. controlled by what amounts
  9. to a quasi-religious cult--
  10. Object Oriented Programming
  11. (OOP). As a result,
  12. productivity is too often the
  13. last consideration when
  14. programmers are hired to
  15. help a business computerize
  16. its operations.
  17.  
  18. There’s no evidence that the OOP approach is efficient for most programming jobs.
  19. Indeed I know of no serious study comparing traditional, procedure-oriented
  20. programming with OOP. But there’s plenty of anecdotal evidence that OOP retards
  21. programming efforts. Guarantee confidentiality and programmers will usually tell you that
  22. OOP often just makes their job harder.
  23. Excuses for OOP failures abound in the workplace: we are “still working on it”;
  24. “our databases haven’t yet been reorganized to conform to OOP structural
  25. requirements”; “our best OOP guy left a couple of years ago”; “you can’t just read
  26. about OOP in a book, you need to work with it for quite a while before you can
  27. wrap your mind around it”; and so on and so on. If you question the wisdom of
  28. OOP, the response is some version of “you just don’t get it.” But what they’re
  29. really saying is: “You just don’t believe in it.”
  30. All too often a company hires OOP consultants to solve IT problems, but then that
  31. company’s real problems begin. OOP gurus frequently insist on rewriting a company’s
  32. existing software according to OOP principles. And once the OOP takeover starts, it
  33. can become difficult, sometimes impossible, to replace those OOP people. The
  34. company’s programming and even its databases can become so distorted by OOP
  35. technology that switching to more efficient alternative programming approaches can be
  36.  
  37.  
  38. costly but necessary. Bringing in a new group of OOP experts isn’t a solution. They
  39. are likely to find it hard to understand what’s going on in the code written by the
  40. earlier OOP team. OOP encapsulation (hiding code) and sloppy taxonomic naming
  41. practices result in lots of incomprehensible source code. Does anyone benefit from this
  42. confusion and inefficiency?
  43. When the Java language was first designed, a choice had to be made. Should
  44. they mimic the complicated, counter-intuitive punctuation, diction, and syntax used in
  45. C++, or should they create an understandable, clear language--as much as possible
  46. like English? A “natural language.”
  47. They apparently decided to deliberately avoid straightforward, clear syntax because
  48. many professional programmers wouldn’t take such a language seriously. Why? Job
  49. protection. Most professions have their jargon: One benefit is that it serves to
  50. separate the pros from outsiders. Academic theorists are the second primary reason
  51. that OOP is popular, and they are also major contributors to its complexity and
  52. inefficiency.
  53. OOP originated in high-variable systems modeling (such as weather forecasting),
  54. and it can be useful in some kinds of programming. One notable OOP success is
  55. the application of some of its principles to graphic user interface (event-driven
  56. component) programming. However, university professors have extended OOP
  57. principles to all programming, not merely those specialized areas where aspects of
  58. OOP theory work well and make sense. Professors, bless them, all too often prefer
  59. to ignore facts that conflict with their favorite theories.
  60. I’m not saying we don’t need professors. Society often benefits from--and some
  61. kinds of progress depend on--people who flit around testing every new intellectual
  62. craze, taking ideas to extremes. Indeed, Peter Pan would be much the poorer without
  63. Tinkerbelle. But if I’m faced with a mission-critical project, I wouldn’t seek advice
  64. from a pixie.
  65. Although the effectiveness of Object-Oriented Programming is debatable, curiously
  66. there is almost no debate about it. It pervades contemporary computer programming.
  67. Each new generation of programmers marches out of the universities as committed
  68. OOP practitioners. Most are simply unaware of any alternative.
  69.  
  70.  
  71. If you raise questions about OOP’s effectiveness, a hue and cry goes up from the
  72. multitude that have invested many years and much money developing their expertise
  73. in the art of OOP.
  74. I say art because --whatever else it might be--programming isn’t science.
  75. Although subsumed into computer science departments at many universities,
  76. programming is fundamentally linguistic, an act of communication. Alternatively,
  77. computer programming is taught in the math department in some schools, which
  78. makes perhaps even less sense. Programming, like cooking, involves math only
  79. occasionally and tangentially. But this confusion about the purpose and character of
  80. computer programming is endemic in the academy, and spills out into the profession
  81. of programming in the world at large. To me, the greatest misunderstanding involves
  82. the highly dubious utility of OOP and the unnatural family of languages derived from
  83. C, such as Java and C++ that are associated with OOP.
  84. Like many theories, OOP includes some attractive concepts. OOP’s major
  85. principles--encapsulation, inheritance, and polymorphism--are of value in specialized
  86. programming contexts. However, these concepts often prove difficult to apply to most
  87. real-world programming tasks. Yet most programming shops today are relentless in
  88. their cult-like insistence on employing C/OOP for every job they tackle.
  89. Here’s one common example of how OOP is used inappropriately: Database
  90. systems embedded within successful companies often must be highly adaptable--
  91. responsive to the ever-changing needs of a dynamic, effective corporate culture. OOP
  92. database management by contrast often results in relatively inflexible schema, and
  93. future changes in the business model must be translated (mapped) back to the
  94. now-obsolete OOP structures. One feature of OOP encapsulation theory urges that
  95. data be embedded within objects rather than remaining in a distinctly separate system
  96. (as in a traditional database). This contributes to the rigidity of OOP data
  97. management, and makes it more difficult to respond rapidly and efficiently to changes
  98. in the corporation’s, or its customers’, behaviors and needs.
  99. OOP usually isn't the best solution that many claim it is. Of course in the current
  100. workplace programmers and developers cannot freely raise questions about OOP’s
  101. efficacy. OOP is the dominant theory. Questioning it can imperil one’s job. What’s
  102. more, few alternatives to C/OOP are taught in the schools anymore.
  103.  
  104.  
  105. OOP has taken over computer "science" departments to the exclusion of any
  106. alternative programming system. A generation of programmers has graduated from
  107. schools that teach only the OOP way, so that’s what they tend to prefer. It's really
  108. all they know. They memorize a set of “best practices” (abstract design rules) to
  109. help them grind out OOP without making too many mistakes. OOP can be effective
  110. to some extent during the initial design phase--when a program’s broad goals and
  111. large-scale structure is being imagined and sketched in. However, for day-do-day
  112. code writing, OOP is generally the single biggest obstacle to contemporary programmer
  113. productivity. Are results achieved faster? No, creating programs usually takes
  114. considerably longer than it does with more natural languages and more sensible
  115. approaches to modular design. Have bugs been reduced? No, they usually increase.
  116. Is program maintenance easier? No, OOP and C languages are notoriously counterintuitive
  117. and difficult to read.
  118. Given the freedom to choose, the public--amateurs and small business
  119. programmers--greatly prefers Basic and 4GLs and all but ignores OOP. According to
  120. several studies of overall computer language use, Basic and 4GL programmers have
  121. greatly outnumbered C programmers since the 1980’s. But the elite, professional
  122. programmer class learns C-language variants and OOP in their computer "science"
  123. classes, and then stick with OOP/C for the rest of their lives. It reminds me a bit
  124. of the priest class in ancient Egypt. They accepted a bowl of olives from an ordinary
  125. guy who wanted to send a prayer to Osiris, then the priest went into the temple to
  126. talk to the gods in a secret language that only priests, and gods, understood. It's a
  127. living, as they say.
  128.  
  129. OOP’s Benefits Aren’t Unique
  130. OOP is employed in programming in two primary, somewhat unrelated, ways. First,
  131. it’s used to organize code libraries, such as Microsoft’s .NET framework, much the
  132. way a biologist classifies fauna. Second, OOP seeks to bring order to large-scale
  133. programming projects--to help create a sensible overall design and to keep
  134. programmers from stepping on each other’s toes.
  135. OOP does have some useful features for such group-programming jobs.
  136. Encapsulation seals off tested code from prying eyes and from modification that might
  137. introduce bugs. But hiding code isn’t unique to OOP. Most languages permit
  138.  
  139.  
  140. Some even argue that OOP is best even for programmers working solo. This claim
  141. often rests on OOP’s code reusability features--the idea that with OOP you can
  142. easily reuse objects you’ve previously written for other programs, or more easily
  143. update programs if they need modification later on.
  144. This, too, is a largely bogus claim. From the simplest copying and pasting on the
  145. low end, all the way up to classic code libraries--every computer language offers
  146. code reuse and code maintenance features in some form or another. And the
  147. considerable effort required to superimpose OOP on more natural programming
  148. languages and techniques often requires far more programmer time, than any time
  149. saved during future code maintenance. What’s more, it seems obvious that when you
  150. go back to modify existing code, the easier that code is to read and understand, the
  151. more quickly you can edit it. OOP and C are not known for readability. Quite the
  152. opposite.
  153.  
  154. Runaway Linguistic Inflation
  155. Linguistic inflation is a major, unpleasant side-effect of OOP/C and the drive
  156. toward elite jargon for professionals. Partly as a result of attempts to incorporate the
  157. idea of "object" into the programmer's vocabulary, programs and code libraries have
  158. gotten very messy and confusing. However, inured as they are in the One True
  159. Theory, few professional programmers dare complain about the highly redundant,
  160. needlessly complex code, and the breakdown of logical categories in code libraries
  161. that is a direct result of the application of OOP/C principles to otherwise
  162. straightforward computing tasks.
  163. OOP inflates and damages programming languages in several ways:
  164. * Key terms such as object, method and property have lost their descriptive
  165. value almost entirely because they’ve become largely indistinguishable in
  166. meaning. And the term object itself is applied to almost every element in
  167. OOP code libraries.
  168. * The vocabulary that defines OOP features has become highly redundant.
  169.  
  170.  
  171. * Programming tasks such as printing a document that used to require only
  172. three or four words in the source code, can now require hundreds of words.
  173. * The diction in OOP languages grows enormous: The Basic language in 1990
  174. consisted of fewer than 400 terms, and of these only 50 were usually
  175. employed for most common programming tasks; Basic .NET has many
  176. thousands of terms.
  177. * OOP code libraries become huge and difficult to use: Programmers now often
  178. find themselves spending less time writing actual source code than they
  179. spend trying to find, and correctly address, classes in the .NET framework.
  180. Let me elaborate on these points. First, the OOP classification system used to
  181. organize the elements of the programming language breaks down quickly into
  182. essentially meaningless, sometimes conflicting, categories.
  183. OOP superimposes complex taxonomies on top of classic procedures and natural
  184. language technologies. And even the primary OOP categories--such as objects and
  185. their members--are frequently illusory on close inspection. With OOP the
  186. “distinction” between object, property, and method is always up for debate. The
  187. categories are quite vague and often interchangeable.
  188. Consider that OOP’s most fundamental grammatical relationship is between an object
  189. (similar to a noun in human language grammar) and its methods (verbs) and
  190. properties (adjectives). This grammar, though, is merely theoretical. In practice, the
  191. categorizations usually collapse in real-world source code. For example, a single OOP
  192. property can simultaneously be an object and a method in the same “sentence”
  193. (logical line of code). Put another way: an adjective is a noun is a verb. You can
  194. memorize each specific variation of this kind of nonsense, but you cannot diagram it
  195. or learn rules from it for future programming jobs.
  196. What’s more, in Microsoft’s OOP .NET suite of languages, everything is an object,
  197. even fundamental components such as the integer variable type and logical operators.
  198. When everything is something, you have the fish-in-water problem: the concept of
  199. water has no meaning to a fish because it’s wholly pervasive in their world. The
  200. term object is so omnipresent in OOP libraries that it, too, has lost much of its
  201. meaning.
  202.  
  203.  
  204. With OOP-inflected programming languages, computer software becomes more
  205. verbose, less readable, less descriptive, and harder to modify and maintain. OOP
  206. apologists claim the opposite: that OOP is more efficient than traditional programming
  207. approaches. However, I’ve never seen any serious, reliable study comparing OOP with
  208. procedural programming. Such a study is long overdue.
  209.  
  210. Dozens of terms where one will do
  211. Another unpleasant side effect of OOP is its elite patois--a highly redundant jargon
  212. only professionals understand. OOP computer language features now have multiple
  213. names, names that often have no distinctions in meaning--not even subtle
  214. distinctions. For example, consider the many synonyms for what is probably best
  215. described simply as a code library (i.e., a collection of procedures): Assembly,
  216. control library, control type library, class library, object library, namespace, project
  217. model, object model, host object model, proxylib, type library, plug-in, plugin type
  218. library, services, services library, development environment, core type library,
  219. extensibility, runtime library, runtime execution library, runtime execution engine, kernel,
  220. helper , and dynamic link library .
  221. Some will argue that there are distinctions here. Indeed, in some cases, adjectives
  222. such as core, control, or plug-in do shade the meaning a bit. But nearly all the
  223. terms in the previous paragraph are merely synonyms--without even the slightest
  224. distinction between them. And some of the terms are simply inept. One popular
  225. usage, "object library," makes no sense on closer examination. OOP asserts that
  226. "objects" only exist during runtime, during execution of a program. Objects must be
  227. instantiated, they cannot be collected in a library--only classes can exist in a library.
  228. The proper term is "class library," for the same reason that you don't confuse a
  229. cookbook with a restaurant.
  230.  
  231.  
  232. Bloated source code
  233. Perhaps the worst form of inflation resulting from OOP is the redundancy in the
  234. programming code now required to do even common, previously simple, tasks.
  235. Consider the difference between the non-OOP instructions to print a document, and
  236. the OOP version. Here’s how you traditionally print some text in Visual Basic Version
  237. 6 (pre-OOP):
  238. Printer.Print Text1
  239. In the VB.NET OOP version, you must replace these three words with 80 lines of
  240. source code (277 words total). You must use a group of members, import several
  241. libraries, and muster a fair amount of information (such as the “brush” color, line
  242. height, running word count, and so on). You must supervise several other aspects of
  243. the printing process as well. For example, if you don’t correctly specify and keep
  244. track of how several elements of the printing are carried out--every few pages only
  245. the top half of the last line of text appears on the paper, or characters are chopped
  246. off at the right ends of lines. If you’re interested in the gory details, the OOP
  247. version can be found in Book 6, Chapter 3 of my book Visual Basic .NET All-In-
  248. One Desk Reference For Dummies (Wiley).
  249. True, all these extra lines of code do give you more flexibility than the simple
  250. pre-OOP version. But that flexibility carries a terrible price. And this “advantage” is
  251. counterfeit. Non-OOP languages permit you the same flexibility if you want it: You
  252. can employ code libraries (API’s) to manipulate any printer features you need to
  253. control. The difference is, with OOP you must write those 80 extra lines of code
  254. for every printing job.
  255.  
  256. OOP Makes Many Simple Tasks a Struggle
  257. Even highly experienced OOP programmers continually struggle with even simple
  258. tasks. You’d think that years of experience writing in OOP or C-languages would
  259. result in greater facility and productivity. Unfortunately, for all but the brilliantly talented
  260. few--where OOP and C seem harmonic with their brain patterns--experience seems
  261. to have relatively little impact on overall productivity. The main reason for this is that
  262.  
  263.  
  264. nobody is in charge of OOP or the C languages, so there is little consistency and
  265. very few reliable syntactic rules you can learn.
  266. Humanity had a unique opportunity to design a sensible language that would
  267. permit efficient communication between man and machine. Other than Esperanto, this
  268. was the first time in human history that a language could be thoughtfully designed
  269. from the ground up rather than merely accreting like all other human languages. We
  270. failed. Various committees of academic theorists along with programming gurus in
  271. companies competing to control market share have contributed to the current muddle.
  272.  
  273.  
  274. Inconsistent Grammar
  275. To see the inconsistency in OOP grammar, consider an elementary programming
  276. task like changing the size of some text. To change the font size of text to 11
  277. points, classic (non-OOP) code is straightforward and quite similar to the English
  278. language:
  279. TextBox1.FontSize = 11
  280. Compare that to the new "improved" OOP version:
  281. Dim fnt As New System.Text.Font("Arial", 11)
  282. TextBox1.Font = fnt
  283. Which version seems more efficient, easier to remember and use, more readable,
  284. and ultimately more sensible? OOP claims to simplify and to improve efficiency. It
  285. rarely does.
  286. One major problem with OOP libraries is that you have to learn new, unique
  287. taxonomic "addresses," interrelationships, and coding approaches for each programming
  288. task. There's little regularity, so there are few rules you can learn and apply across
  289. tasks. It’s as if a card catalog had exploded in the library, and you had to look
  290. through the pile of cards, only by chance finding the address of a book quickly.
  291. OOP libraries (and the resulting way that you invoke or “address” the functions
  292. contained therein) are organized, but the organization is inconsistent, haphazard, often
  293. illogical. For example, in Visual Basic .NET (the OOP version of Basic), one
  294. committee of Microsoft programmers decided that to change the size of text you must
  295. use the syntax in the previous example.
  296. But another committee--for no discernable reason at all--specified that programmers
  297. must use an entirely different syntax to change the color of text. Here’s how you
  298. must change the color property of text:
  299. Dim c As Color
  300. c = System.Drawing.Color.FromName("blue")
  301. TextBox1.ForeColor = c
  302. Mind you, you're doing exactly the same thing in both situations, namely changing
  303. a property of text. But you change these properties using vastly different source code.
  304.  
  305.  
  306. With OOP taxonomies, there simply are very few conventions. The syntax for each
  307. task must be individually memorized. This is awfully inefficient, and programmers often
  308. spend more time trying to figure out the correct OOP syntax than they do actually
  309. writing the programming code itself.
  310. To change the size of text:
  311. 1. Use the "New" command.
  312. 2. You must provide an argument list.
  313. 3. You don't provide a namespace.
  314. 4. Change the object's property.
  315. To change the color of text:
  316. 1. Don’t use the "New" command.
  317. 2. Don't provide an argument list.
  318. 3. You must provide a namespace.
  319. 4. Change the object's method , not a property.
  320. There’s a marvelous lack of common sense at work here. It represents a serious
  321. corruption of other, far more sensible, approaches to programming.
  322.  
  323. OOP’s Features Don’t Deliver What They Promise
  324. OOP programming also requires that quite a bit of time and effort be spent
  325. wrestling with scoping rules and other essentially clerical issues. For example, among
  326. the OOP scoping commands are: Protected, Friend, and Shared. You even find
  327. combination scoping, using two scope declarations at the same time, such as
  328. Protected Friend, ReadOnly Public, and WriteOnly Friend. This kind of inflation, and
  329. the resulting ambiguity, should be a clue that theory is triumphing over practicality.
  330. Encapsulation--sealing off successful code from further modification--is a valuable
  331. component of OOP. (OOP’s polymorphism and inheritance features are often so
  332. damaging, bug-inducing, and unnecessarily complex that it’s generally sensible to
  333. avoid them whenever possible.) However, creating “black-box” code is hardly
  334. exclusive to OOP. Most computer languages permit you to compile code libraries that
  335. contain unmodifiable, finished procedures. Where OOP differs is that it encourages
  336.  
  337.  
  338. encapsulation not just in libraries where code is being reused, but also promotes
  339. hiding source code within a currently active programming project. In other words--
  340. don’t let one programmer see another programmer’s source code.
  341. Hiding code can of course be useful, particularly with large, complicated programs
  342. where you want to ensure that nobody tampers with other people’s tested, finished
  343. procedures. However, OOP doesn’t limit itself to this useful clerical task. It’s a much
  344. larger, more ambitious system. Its most astonishingly messy feature is often claimed
  345. as its greatest strength: the attempt to automate the process of code reuse.
  346. OOP encourages writing code that behaves differently in different contexts
  347. (polymorphism). Instead of creating two procedures, one named ChocolateShake and
  348. one named VanillaShake, you instead create one procedure named Shake that can be
  349. either chocolate or vanilla, depending on the data you feed to the procedure. While
  350. this sounds promising, in practice it’s confusing. Code can become harder to read
  351. because you’ve removed the descriptive parts of the name--chocolate and vanilla--
  352. from the procedure’s name. You’ve created a more general-purpose procedure out of
  353. two, more specific, more understandable, procedures.
  354. OOP also encourages code reuse via inheritance: expecting the programmer to
  355. modify invisible (encapsulated) code. The contribution of inheritance to code
  356. unreadability, slow program execution, and bugs in general has--even among some
  357. OOP apologists--been widely acknowledged.
  358.  
  359. Alternatives
  360. Nobody should be ashamed to admit that they have problems with OOP or the C
  361. language and its derivatives. Everyone has problems with them. Even OOP experts
  362. bicker among themselves about the "proper" way to manage the various convoluted
  363. aspects of OOP theory.
  364. Some OOP theorists claim that the only alternative to OOP is “spaghetti code,” but
  365. this is a straw man argument. Long ago structured programming ended the abuse of
  366. the GOTO command. Nobody seriously suggests going back to the early days before
  367. subroutines were in common use.
  368.  
  369.  
  370. The true alternative to OOP is procedure-based programming and 4GL (fourthgeneration)
  371. languages that are deliberately constructed to resemble natural human
  372. language as much as possible.
  373. In sum: like countless other intellectual fads over the years ("relevance,"
  374. communism, “modernism,” and so on--history is littered with them) OOP will be
  375. with us until eventually reality asserts itself. But considering how OOP currently
  376. pervades both universities and workplaces, OOP may well prove to be a durable
  377. delusion. Entire generations of indoctrinated programmers continue to march out of the
  378. academy, committed to OOP and nothing but OOP for the rest of their lives.
  379.  
  380. About the Author
  381. Richard Mansfield has been a prominent figure in the computer field for over two
  382. decades. From 1981 through 1987, he was editor of Compute! Magazine. He has
  383. written hundreds of magazine articles and two columns, and he began writing books
  384. full-time in 1991. He’s written 38 computer books altogether and several became
  385. bestsellers, including Machine Language for Beginners (Compute! Books), The Visual
  386. Guide to Visual Basic (Ventana), and The Visual Basic Power Toolkit (Ventana,
  387. with Evangelos Petroutsos).
  388. His recent titles include The Savvy Guide to Digital Music (Sams), CSS Web Design
  389. for Dummies (Wiley), Office 2003 Application Development All-in-One Desk
  390. Reference For Dummies (Wiley), Visual Basic .NET All-In-One Desk Reference for
  391. Dummies (Wiley), XML All-In-One Desk Reference for Dummies (Wiley, with
  392. Richard Wagner), Visual Basic .NET Database Programming for Dummies, Visual
  393. Basic 6 Database Programming for Dummies (Hungry Minds), and The Wi-Fi
  394. Experience: Everyone's Guide to 802.11b Wireless Networking (Que).
  395. Overall, his books have sold more than 500,000 copies worldwide, and have been
  396. translated into 12 languages.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement