Slashdot Mirror


Can OO Programming Solve Engineering Problems?

ThChalm asks: "I am the first one to admit that my programming experience is somewhat limited. The majority of it has been obtained writing FORTRAN code to solve problems in mechanical engineering. I have written some smaller (you might say toy) codes using C. I have read a lot of books on C++ (and OOP), but always get frustrated with the following question: Why can't anyone show me an engineering application that is solved with an object oriented program?"

"I appreciate the concepts of OOP and see its applicability in managing records, GUIs, and possibly standard function libraries. I cannot, however, convince myself that there is a clean way to use these concepts to solve the type of procedural problems that I have encountered in the past (finite difference solutions to differential equations, finite-volume computational fluid dynamics, iterative solutions to non-linear equations, Monte-Carlo simulation of radiative heat transfer, etc.)

Am I just being close minded to the ideas of OOP or do my problems just require 'procedural' solutions, which are better solved using procedural techniques? I'll even be happy with the answer 'Your problems are two small and specialized to realize any significant advantages of OOP.'

I'd be interested in hearing comments from anyone else who has this problem, anyone who has worked through it, or anyone who can send me an example of an engineering application of C++ and OOP."

621 comments

  1. OOP won't help, sorry... by Anonymous Coward · · Score: 5, Funny

    Your problems are too small and specialized to realize any significant advantages of OOP.

    1. Re:OOP won't help, sorry... by Anonymous Coward · · Score: 0

      No, his problems are too large and diffuse to realize any significant advantages of OOP.

    2. Re:OOP won't help, sorry... by coflow · · Score: 1

      it seems to me that the larger and more diffuse a problem is, the more that problem screams out for object oriented design....

    3. Re:OOP won't help, sorry... by stephend · · Score: 5, Funny

      The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones.

    4. Re:OOP won't help, sorry... by imp · · Score: 5, Insightful
      The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones.
      Well, the great thing about C is that you can write great FORTRAN programs in it :-)

      You can abuse any tool. OO code also lets you make complex problems look like a managable set of simple ones.

    5. Re:OOP won't help, sorry... by Arandir · · Score: 3, Insightful

      The comment got modded up to funny, but it's dead on the mark. OO Programming is about O (Objects). When designing a program, first determine the objects in your domain. The stuff you specifically mentioned are not objects. If you can't find any objects in your domain, then don't go the OO route.

      Here's an example: Airfoil design. The object in the domain is the airfoil (and probably composed of other objects like surfaces, sections, etc). The actual equations used are not the object, they are what you do with the object. So when you talk about finite difference solutions, fluid dynamics, and iterative solutions, you aren't talking about objects, but what you can do WITH objects.

      Even if OO doesn't fit your domain, take a look at the STL and Generic Programming in general. There's some useful stuff in there for your needs.

      --
      A Government Is a Body of People, Usually Notably Ungoverned
    6. Re:OOP won't help, sorry... by Anonymous Coward · · Score: 0

      MATLAB solves many such problems and is written in C++ (and more recently they use Java, too). ORACLE is a database that is often used for storing and manipulating vast amounts of numerical data. This, too, is written in C++. There are several commercial C++ APIs that provide for heavily optimized complex number operations, polynomial operations, matrix operations, and transforms. Such APIs take advantage of operator overloading to allow straight-forward translation of standard mathematical notation to C++ code using an OOP paradigm.

      All of these problems could also have been solved with C programming practices. In fact, the OOP concepts of C++ can be implemented in C manually (that was how C++ started, back in the days of C with Classes and later cfront). The aforementioned projects do not do so for economic reasons; it was cheaper to develop and maintain C++ code. Perhaps your projects are cheaper to develop and maintain under C.

    7. Re:OOP won't help, sorry... by Codifex+Maximus · · Score: 2

      Using your Airfoil analogy, I'd say that you could objectify the airfoil and perform "What If" scenarios by modifying the properties of the object while simulating a wind-tunnel type test.

      You could incorporate the physics and differential equation calculations into the object so it reacts in a realistic way. Heck, go ahead and objectify the wind-tunnel while yer at it.

      --
      Codifex Maximus ~ In search of... a shorter sig.
    8. Re:OOP won't help, sorry... by V.P. · · Score: 1
      Just because something is "written in C++" doesn't mean it has anything to do with OOP.

      MATLAB and ORACLE have been in development for so long that I'd bet that most of that "C++" is age-old C code that nobody understands any more.

    9. Re:OOP won't help, sorry... by pyrrho · · Score: 1

      Not to be facetious, but the parent post seems to indicate a misunderstanding of "objects". Objects in the software engineering sense are not metaphors. You didn't say they were but that is what is implied, why?

      You said if you can't find objects in your domain.

      Objects are functions associated with data, I guarantee his software problem involves data that can be organized with functions that act on that data.

      Programmers need to learn that objects are not metaphors! They are collections of data and methods into a bundle, for understandability, for reuse, for reimplimentation/replacement. Unless you (a) don't know an OO language or (b) use a system that does not support OO languages or (c) have a really compelling technical reason (though these are dwindling), you should use an OO approach.

      But don't let you class system structures get too deep or you waste the advantages. I'm not a purist, but I am convinced... how did I get convinced... when it became clear that the proper way to code in C was object oriented. (What? Of course you can!)

      --

      -pyrrho

    10. Re:OOP won't help, sorry... by kevlar · · Score: 2

      I agree. Object Oriented is simply a means of organization. If you choose to handle everything linearly, then go the route of C/FORTRAN etc. If you wish to handle the calculations from multiple perspectives, you'll need good organization, which OO provides you with. OO is nice for modeling because you can reduce the data/computations down into their respective parts and isolate bugs and modeling errors easier. Fixing the problems is easy too because if your work is designed properly, you can easily replace the flawed component, minimizing the effectual change you required. Biased? Maybe, but its all in how your brain chooses to work out the details. Mine tends to be OO-centric with the exception of writing code thats only a few lines long.

    11. Re:OOP won't help, sorry... by Arandir · · Score: 2

      You didn't say they were but that is what is implied, why?

      I didn't mean to imply that all objects are metaphors, but I hoped to imply that using metaphors is a valid and useful means to determine what the objects are in your domain.

      Programmers need to learn that objects are not metaphors!

      Maybe a better way to put this is that object are not ONLY metaphors. But objects as metaphors is a good starting point for OO Analysis. Your domain is full of objects. Some of those objects will be suitable for classes. Many of them won't. That why you do the analysis. In terms of the airfoil example, an airfoil as an object in the domain *may* be suitable for an OO class. But maybe not. But it's the best place to start looking. Perhaps an airfoil would be better represented as a collection of surface objects.

      Using objects as metaphors is "top down" analysis. Using the base data structures to build objects from is "bottom up" analysis. Neither is wrong.

      --
      A Government Is a Body of People, Usually Notably Ungoverned
    12. Re:OOP won't help, sorry... by Anonymous Coward · · Score: 0
      Er, uh.. but I can do OO with c. Why do people confuse a programming technique with a programming language....

      Sure, somthing like java or python with their clean OO design will make it easier, but you can do good design, be it OO or not, with any language.

    13. Re:OOP won't help, sorry... by pyrrho · · Score: 1

      >Maybe a better way to put this is that object are not ONLY metaphors.

      You are totally right. A good metaphor can really lead a good object design... my emphasis was due to the fact that many people seem to only think of them as metaphors. For example, when taking a Java course the instructor told us to state our problem in english, map nouns to objects and verbs to methods! That is anathema to me. A bad way to proceed.

      --

      -pyrrho

    14. Re:OOP won't help, sorry... by mcjulio · · Score: 1

      True, you can emulate a section of OOP with C, but you do not get the compiler-enforced scoping restrictions that make the technique useful, nor do you get the keyword semantics that support the paradigm. You can theoretically craft this with a custom preprocessor and macro-defined keywords, but why bother when the work has been done for you in oo-ready languages like C++ and Java?

    15. Re:OOP won't help, sorry... by Anonymous Coward · · Score: 0

      You can also emulate a Pentium with paper and pencil.

    16. Re:OOP won't help, sorry... by Anonymous Coward · · Score: 0

      You need to approach the solution of your problems with OOD (design) before you proceed to OOP.

      It is likely you conceive the solutions to your problems as iterations over simultaneous equations. Fortran is actually good for implementing those types of solutions. I'm not familiar enough with your problem space to extoll the benefits of OOD in your discipline. But, it is likely you would have to change the way you think about your problems and solutions before OOD/OOP will become useful.

    17. Re:OOP won't help, sorry... by not_cub · · Score: 1

      Your problems are too small and specialized to realize any significant advantages of OOP.

      Why the hell did this get modded up as funny? It *is* insightful, if a little terse.

      I am currently in my final year of an undergraduate Maths course in Britain. We have to do a series of computer projects to solve mathematical problems, ranging from applied, engineering/physics type problems (for example fluid dynamics). Between school and university I worked as a programmer on a product for several financial companies.

      For the projects for my course, the programs just use a computer as a big calculator, and the goal is to have it spit out a number at the end. If I have the time, and the answer isn't obviously wrong or right, I can write the program again from a slightly different perspective, and if it spits out nearly the same answer that is fine. Most of the work is purely getting the computer to plug the numbers into formulae. It is a waste of my time to use OOP for this. You might as well ask if OOP is a good solution for a scientific calculator.

      For the project for the big companies, the most important thing was that they worked 24-7, that any of the values being calculated could be altered at any time, or the calculatons themselves and that each value calculated was recorded (if it miscalculates and someone is out by a million pounds, they will want to go back over it afterwards). To this end, it is a good idea to use objects because it is critical to know you are keeping track of all your data structures all the time. Compared to that, the calculations themselves are pretty insignificant (just like I bet the programmers for excel didn't spend as much time sweating about the SUM function, as they did about the object tree for the sheets, cells, etc).

      not_cub

      --
      q='echo "q=$s$q$s;s=$b$s;b=$b$b;$q"';s=\';b=\\;echo "q=$s$q$s;s=$b$s;b=$b$b;$q"
    18. Re:OOP won't help, sorry... by cheese_wallet · · Score: 1

      "You can also emulate a Pentium with paper and pencil."

      That made my day!

    19. Re:OOP won't help, sorry... by Anonymous Coward · · Score: 0

      >>Your problems are too small and specialized to
      >>realize any significant advantages of OOP.
      >Why the hell did this get modded up as funny? It
      >*is* insightful, if a little terse.

      Maybe because the author of the original article invited the response by writing: "I'll even be happy with the answer 'Your problems are two small and specialized to realize any significant advantages of OOP.'""?

    20. Re:OOP won't help, sorry... by Anonymous Coward · · Score: 1

      Your problems are huge, though - you're a fucking idiot! Go fuck your momma, then fuck your sister, then your uncle (you uncle fucker), then yourself.

      FUCK YOU!!!
      AC

    21. Re:OOP won't help, sorry... by Anonymous Coward · · Score: 0

      Fuck you, ass-licker. Whether you want to go_fuck_someones_self(you) or you.go_fuck_yourself(), go fuck yourself!!!

      you putrid, no nothing, british uncle fucker!!!

      AC

    22. Re:OOP won't help, sorry... by Anonymous Coward · · Score: 0

      It seems to me that you are championing modular programming, which is an older idea than OO programming. Indeed modularity should be applied by every programmer whenever possible, but this does not have anything to do with OO per se.

    23. Re:OOP won't help, sorry... by Grab · · Score: 2

      The airfoil will be one object, likely composed of sub-objects like surfaces. The air itself may also be a large collection of objects to do your finite element analysis. The fluid-flow modelling will be an object linking them using some standard "hooks", so that if you want to change to a new modelling method, you just have to change the one object. And there'll be a solver object which adjusts the airfoil and watches the results.

      Grab.

    24. Re:OOP won't help, sorry... by Anonymous Coward · · Score: 0

      Note - I'm not advating re-inventing the wheel, I'm simply pointing out to you that you shouldn't confuse the tool used with the technique used. i.e., a programming language and a programming techinique are not one and the same.

    25. Re:OOP won't help, sorry... by Anonymous Coward · · Score: 0

      You call that OOP?

    26. Re:OOP won't help, sorry... by Anonymous Coward · · Score: 0
      "The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones."

      Same with your paycheck perhaps. The manager will have no idea what you did to it, but he may be impressed.

      OOP code also lets you make complex problems look like a managable set of simple ones.

      I never met a technique nor paradigm that did not try to do this. The million dollar question is if OOP does it better. I have yet to see it. It seems to solve or help some complexity management problems at the expense of others.

    27. Re:OOP won't help, sorry... by 4of12 · · Score: 2

      I didn't mean to imply that all objects are metaphors,

      Perhaps not, but as far as I'm concerned most objects are metawhores.

      --
      "Provided by the management for your protection."
  2. OOP by ParamonKreel · · Score: 2, Informative

    It's not that you can solve problems in OOP that you can't solve in Procedural (Fortran/C like), it's just that for many problems, OOP is much faster, allowing you to re-use much code to deal with things in a similar way when they can be and use the specifics only when needed.

    1. Re:OOP by Kamel+Jockey · · Score: 2, Interesting

      OOP is much faster, allowing you to re-use much code to deal with things in a similar way when they can be and use the specifics only when needed.

      OOP tends to produce very bloated machine code though. In some mission critical real time systems, or on embedded systems in which there are siginificant resource limits, this may not be a good programming tactic. Yes, it reduces development time, but it tends to increase execution time.

      But its sure saved my ass on numerous occaisions! Because of OOP, many of my non-trivial programs "practically write themselves!"

      --
      In case of fire, do not use elevator. Use water!
    2. Re:OOP by kevin42 · · Score: 3, Insightful

      That has been true in the past, but with modern compilers (like gcc) you will get very similar code and only a slight increase in overhead (vtables) with C++ over C. Lots of people are using C++ in small embedded systems now.

      Real bloat comes from libraries like STL...

    3. Re:OOP by Chris+Parrinello · · Score: 1

      "very bloated" is really incorrect nowadays for modern compilers for OO languages such as C++. This is a common misconception that old timer real-time and embedded programmers like to cling to whenever anybody mentions OO. Basically, if you avoid relying heavily on polymorphism for method calls, C++ is just as fast as C. If executeable size is a problem then just don't use or link in standard libraries.

      My opinion about the procedural vs. OO in RT or embedded systems debate is that if all of these platforms are so resource constrained, then the applications should really be written in assembly anyway. One can write really poor performing code in a procedural language just as easily as an OO language. Why risk it? :)

      Chris

    4. Re:OOP by ParamonKreel · · Score: 1

      I meant in the development time. I'm well aware that as you get further and further away from machine code, you loose the speed of telling the processor exactly how to move electrons around.

    5. Re:OOP by FlowerPotAdmin · · Score: 1

      Real bloat comes from libraries like STL...

      Actually, don't you mean template use in general?

      --
      -Justin
      That's enough posting for now lads, there're trolls afoot.
    6. Re:OOP by madmaxx · · Score: 2, Funny

      lol ... from fud surrounding one topic to another. the STL is no more bloated than my mother-in-law. err, hmmm ... wait ... no more bloated than a canned ham. what do you mean by bloat anyway? unqualified mud-slinging is no where near as fun.

      --
      mx
    7. Re:OOP by Anonymous Coward · · Score: 0

      The use of OOP cripples the mind; its teaching should, therefore, be regarded as a criminal offense.

      ...with apologies to Dijkstra

    8. Re:OOP by kevin42 · · Score: 2

      I guess I should have put a smiley face on that last comment, because I meant it as a sort of troll.

      I have nothing against STL in general, but some compilers have had problems which caused the use of STL to make your program very very large. By bloat I mean large. But I use STL when I need it and again with a good compiler it's not a problem.

    9. Re:OOP by Anonymous Coward · · Score: 0

      The differences with OO machine code are more to do with the compiler than anything else. If the compiler does things like inlining properly then the many subroutine calls that OO code tends to make don't really create much more overhead than a procedural compiled program.

      Most of the time when people say OO is slow/bloated they mean Java is slow/bloated which is a little unfair since it needs a vm to run, and isn't actually compiled down into machine code anyway.

      The issue of code re-use from OO is a bit of a non-event too. In my opinion the best code will use some OO techniques where they are applicable, even non-OO code can have code re-use and inheritance etc. A case of choosing the right tool for the right job.

      The poster of the story hit the nail on the head when he asked "will OO be better for procedural tasks?", basically no it won't...use procedural programming techniques for those programs but be aware of the benefits of OO and you may be able to apply some of them. OO is not a be-all and end-all solution to everything.

    10. Re:OOP by Kamel+Jockey · · Score: 2, Insightful

      "very bloated" is really incorrect nowadays for modern compilers for OO languages such as C++. This is a common misconception that old timer real-time and embedded programmers like to cling to whenever anybody mentions OO.

      Not quite. The reason my statement about compiled code being very bloated, especially on embedded systems, is because there are numerous embedded CPUs for which you can develop software, and good-quality compilers for each of these chips (yes, you need a compiler for each individual chip!) are only now beginning to enter the fray.

      Many of these compilers do not take advantage of many of the obscure but highly efficient CPU instructions which can truly optimize the machine code. Additionally, speed is not necessarily the only objective for which a coder would wish to optimize. In the embedded world, other factors such as minimal code size, power consumption and memory consumption, among other things, often take precedence over speed.

      So hence, many programmers still prefer to use hand-coded assembly for these types of systems.

      --
      In case of fire, do not use elevator. Use water!
    11. Re:OOP by Anonymous Coward · · Score: 0

      The original SGI STL implementation was written with all the bodies of member functions inline, which resulted in a lot more bloat than necessary. I don't know for sure, but I believe the gcc team is rewriting it to remove the unnecessary inlines.

    12. Re:OOP by Cato+the+Elder · · Score: 2

      I beleive you also get a substantial amount of overhead if you enable exceptions. Many embedded systems use C++ but disable exceptions.

    13. Re:OOP by V.P. · · Score: 1
      Well, STL (and using C++ templates for containers in general) will always introduce some bloat. Every time you use vector<T> with a different type T, the compiler essentially creates a new copy of the vector code that only handles T.

      In current versions of Java you have less code bloat (since there is just one instance of the vector code), but you pay for that with worse performance (you have to cast things into and out of Objectcontainers), and less static checking (the compiler can't ensure that you're only placing Ts in the container).

    14. Re:OOP by cakoose · · Score: 1

      The Generic Java variant supports generic types (though the types have to be object types).

    15. Re:OOP by pyrrho · · Score: 1

      btw: this is because the easiest way to implement templates is to essentially copy the code generated by the template into every module that references it. Furthermore, a copy will be made of the code for each type it's used with, i.e. vector of int and vector of float create two copies for the vector code, one compiled to use ints and one to use floats.

      Most current compilers now do not take this "easy" approach and share code more like you would hope. But you still get a copy of vector (etc.) for each template you declare with a different type.

      --

      -pyrrho

    16. Re:OOP by madmaxx · · Score: 1

      It isn't bloat, until it makes an executable fat ... which is generally only the result of using *many* specializations of a template or templates. Using the template construct && STL wisely (like programming sensibly in general) will result in code of respectible size. General misnomers need not apply ;P

      Remember, the designers of the STL selected templates knowing full that template instantination results in 'duplicate' code (a.k.a. specialized code). Their reasoning (from memory) was soley for performance and policy issolation. Had they selected the ABC approach (base class) people would whine about performance.

      Comming from requirements in the C world (the same one that spawned most of the early C++ adopters), using templates is the obvious best choice. Read (or reread) 'The C++ programming language' and 'Design and evolution of the C++ language' by Stroustrup ... the design choices, and implied costs/reasons to use are well documented.

      --
      mx
    17. Re:OOP by Anonymous Coward · · Score: 0

      Not true. In Electrical Engineering, OOP can be very usefull on a small scale. Examples are filter classes ( wich a coworker has resently implimented), force/sense classes, DSP classes, RCL network classes, test specification classes. etc. These would be used in relativly simple programms, some of which discounting comments could fit on a page. I feel that C/C++ promotes ( encourages) mixing OOP with procedural techniques just like BASIC encouraged spagetti code techniques in the old days. A pure OOP paradigm is a difficult switch for thouse with years of procedural experiance. It is often easier to fall back on what we know and probably have done befor, if the language will allow it. This is probably the main reason fro the slow adotion of OOP in engineering, rather then the suitability of the object programming paradigm.

    18. Re:OOP by Ayende+Rahien · · Score: 2

      Yes, that is because the compiler has to add checks that would destory objects that fall out of scope while the exeption travel upward in the stack.

      --

      --
      Two witches watched two watches.
      Which witch watched which watch?
  3. Use Functional by Zordak · · Score: 1, Interesting

    Functional programming is better suited to solving engineering problems. You don't need the overhead of OO design for your engineering programs. I would stick to C unless you are trying to do some kind of fancy GUI.

    --

    Today's Sesame Street was brought to you by the number e.
    1. Re:Use Functional by VP · · Score: 5, Informative

      C is a procedural language, not a functional language. Examples of the latter include LISP, Scheme, and ML.

      As to whether an object-oriented approach is suitable for engineering applications, I think it depends on the applications and problems. How important is abstraction and re-use? If you deal with matrices, would you benefit from a matrix object which implements all the properties a matrix has? With differential equations, are there objects suitable for implementation?

      As with all general questions I am afraid the answer is "It depends."

    2. Re:Use Functional by OSSMKitty · · Score: 1

      While I would agree that functional programming is a great paradigm for solving general engineering problems, I think it would have some issues with the problem domain specified by the post.

      For example, in Haskell, as in most functional languages, you can never be quite sure how the runtime is implementing your algorithm. In some cases, say a Simpson's rule approximation, this doesn't matter because:

      1. Any optimization that needs to be done is easy to do by changing the algorithm, and
      2. the endpoint is easy to determine.
      However, this isn't always the case for some numerical or simulation algorithms that might run a long time, have a fixed algorithm, a lot of special cases, and heuristic based endpoints.
    3. Re:Use Functional by benjymous · · Score: 1

      For example, in Haskell, as in most functional languages, you can never be quite sure how the runtime is implementing your algorithm.


      Then again, in Haskell I was never quite sure what I was implementing either :-\
      --
      Help me! I'm turning into a grapefruit!
    4. Re:Use Functional by angel'o'sphere · · Score: 1

      Wow,

      again a cluelsess moderator moded a WRONG statement of a even more cluelsees programmer up to "Interesting".

      At first: C is not a functional language.
      Programming in C is not functional programming.

      Second: there are endless "engineering" problems.

      Its absolutley impossioble to say in general: OO is better or procedureal is better.

      If you think in OBJECTS the next step is to identify what a object for your certain problem domain is and: HOW TO IMPLEMENT IT.

      Not each OBJECT you find is implemented as a class.

      If your object is a gas molecule with x, y and z coordinates and an impulse for a gas simulation it is quite good possible that you won't implement a class where a object is one single molecule.

      You can as well implement a class which holds arrays of x, y, z, and impulse components and your OBJECT is just an integer index pointing into that array.

      Operations normaly put into the class Molecule like Molecule::collide(Molecule& x) would then be operations of the class holding the arrays of molecule data. And it would likely look like this: MoleculeData::collide(int moleculeIndex1, int moleculeIndex2);

      The point is that you approach the problme with thinking in objects. What is a molecule? What does it? What can I ask it?

      What is *NOT* a molucule and there for does not belong into the molecule 'class'?

      What is similar to a molecule?
      What other class has that given property in common with the molecule? Is there such a class? Is there a relation to that class?

      After you have answered all that questions you can even implement the OO design totaly procedural. You do not need to use OO programming constructs if they do indeed not fit.

      However: for any procedural C program you give me, I write you a faster OO program.
      Just to show you: your claim OO is allways slower is WRONG.

      However to complete the ironic circle: for every OO program you give me, I write you a plain C program which is faster. Just to show you: in the cases where a natural OO program is faster I knwo a trick how to make it even faster in plain C.

      Regards,
      angel'o'sphere

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    5. Re:Use Functional by Anonymous Coward · · Score: 0

      For a fact, the exact implementation may be diferrent from one might imagine looking at the source, but it's the property of lazy pure functional languages with their equational reasoning and other optimizations that are possible under that paradigm -- but the optimizations never affect the halting property of the program or computation results.

      Which, unfortunately, cannot be said about the old school languages like C, C++, .NET, Java, Fortran, Scheme etc. etc.

      Feel encouraged to read about some functional languages semantics. The SMLofNJ homepage, and Haskell definition might be a good start.

    6. Re:Use Functional by Coz · · Score: 1

      Please, don't relegate OO design to GUIs. OO design have much more applicability than just drawing screens; indeed, some of the worst OO code I've ever seen was built by GUI-builders, and GUI experts (human).

      --
      I love vegetarians - some of my favorite foods are vegetarians.
    7. Re:Use Functional by Zordak · · Score: 1

      I wasn't intending to imply that GUI's are the only useful application of OO design. I was saying that functions are more useful in solving engineering problems, so in this particular case, I would only use them for the interface. I personally hate doing GUI design (C++ Builder practically does it for me, which is fine with me), but I use objects to do all sorts of useful things in much of my daily work, which unfortunately is closer to Computer Science than Engineering (at least until I graduate).

      --

      Today's Sesame Street was brought to you by the number e.
    8. Re:Use Functional by Anonymous Coward · · Score: 0

      However: for any procedural C program you give me, I write you a faster OO program.
      Just to show you: your claim OO is allways slower is WRONG.

      However to complete the ironic circle: for every OO program you give me, I write you a plain C program which is faster. Just to show you: in the cases where a natural OO program is faster I knwo a trick how to make it even faster in plain C.


      So, if I give you a random program in, say OO, and give you back the faster C version, then you can make an OO version even faster than the C version? If so, how many iterations can you do so?

    9. Re:Use Functional by Anonymous Coward · · Score: 0

      LISP as a family of languages includes all kinds of programming paradigms. The current standard, Common Lisp, is explicitly a multiparadigm language that supports OO programming, procedural programming, generic programming, and functional programming. On the other hand, Scheme is focused on functional programming (but has some imperative features).

  4. Look at the audience.... by Arctic+Fox · · Score: 4, Interesting

    Most engineers have been taught that FORTRAN is the way to solve problems in engineering. If everyone starts out with that prejudice and is stuck there.
    Where I work, there is a project to write an engineering application in VB, and it has seemed to be one problem after another after another. (I know i know, VB is crap). The core library functions are in C, in a DLL, so I guess thats a bit of a start.
    FORTRAN has been ingrained into the current working generations of engineers, so they're going to use what they know.
    Heck, I've even seen SQLPlus code (from Aspen) written very very very FORTRAN like. Instead of using min(), max(), there was a bunch of select looping and checking variables..... Oy.

    1. Re:Look at the audience.... by Kierthos · · Score: 0, Redundant

      Hrm... I don't know... I have degrees in both Mechanical Engineering and Computer Science, and while getting my B.S. in Mech.E, we only had one course on FORTRAN programming after the 101 intro. Whereas in the Comp.Sci. program, there were multiple courses involved in programming in C/C++.

      Maybe Engineering grad students get more FORTRAN, but I tend to doubt it.

      Kierthos

      --
      Mr. Hu is not a ninja.
    2. Re:Look at the audience.... by Bat_Masterson · · Score: 3, Insightful

      You're confusing programming language with design concepts. The question is not "is Fortran better for engineering problems than C++?" but rather "can OO design and development be applied well to engineering problems?"

    3. Re:Look at the audience.... by NecroPuppy · · Score: 2

      Not as far as I know... I was a computer engineering student, and I regularly worked with the grad students, mostly as a gofer.

      Mostly, they worked with pre-existing software packages; when they needed to actually write anything, it would be in C/C++ or LISP - sometimes both at once.

      And let me tell you, embedded LISP code inside a C programer is really ugly looking...

      --
      I like you, Stuart. You're not like everyone else, here, at Slashdot.
    4. Re:Look at the audience.... by wsloand · · Score: 3, Interesting

      Most engineers have been taught that FORTRAN is the way to solve problems in engineering. If everyone starts out with that prejudice and is stuck there.

      Engineering problems are generally solved by iterating through a set of equations (sometimes hundreds of them). Iteration is the only way known to solve these problems. While you could rewrite your iteration into recursion, you would probably be filling up massive amounts of memory uselessly.

      Actually, you should take a look at the compilers that are out there. If you write some code in FORTRAN with any decent compiler then the compiler will generally do some very nice things for you (like automatic parallelization). Engineering code is often very parallelizable. And when you compare the wall clock time for a FORTRAN engineering program and a C engineering program generally the FORTRAN will work better because the compiler knows very well how to handle the FORmula TRANslation in FORTRAN.

      In summary, it is not a "prejudice," it is a knowledge of the best tool for the job. Your broad statement of "VB is crap" may generally be true, but you should remember that it is an available tool and that for some things (needing a hack that can solve a small windows problem quickly) it is the best tool for the job.

      Engineers' goals are generally to use the best tool at their disposal for the task at hand.

      I speak from experience working with Molecular Modeling as a Chemical Engineer. On my most recent project, I used FORTRAN, Perl, and Matlab (yes that is a programming language not just a program). Each tool is the best at what it does for its purpose.

    5. Re:Look at the audience.... by divbyzero · · Score: 2

      I'm a C programmer, and I'm rather proud of the LISP code embedded within me. :-)

      Actually, s-expressions are a rather useful storage type, even in C. Implementing an s-expression library for C took me only a few hours and a couple hundred lines of code. Note that this is not an embedded LISP interpreter, although it be turned into one fairly easily.

      --
      But my grandest creation, as history will tell,
      Was Firefrorefiddle, the Fiend of the Fell.
    6. Re:Look at the audience.... by pivo · · Score: 2, Informative
      engineering problems are generally solved by iterating through a set of equations (sometimes hundreds of them). Iteration is the only way known to solve these problems. While you could rewrite your iteration into recursion, you would probably be filling up massive amounts of memory uselessly.

      First, OO languages are perfectly capabile of performing iteration. Second if you use languages that support tail recursion, you can avoid growing the stack in recursive invocations.

      The important point is that there's nothing about OO languages that require or favor recursive vs. iterative coding.

    7. Re:Look at the audience.... by jxqvg · · Score: 1
      VB will definitely turn out crap, but I think the best way to approach using it is as a prototyping tool. If you're doing an important project, rough it out in VB or whatever scripting language you like. It all comes back to one essential truth: Make it work, then make it work well.

      It's a real shame that my company does the same thing you guys'll probably end up doing: rough it out in VB[Script] and call it good.

    8. Re:Look at the audience.... by coats · · Score: 5, Informative
      The important point is that there's nothing about OO languages that require or favor recursive vs. iterative coding.
      If, as he says, he is interested in large engineering problems, then there are two likely things he will target:
      1. small problems for which run-time is not a problem; and

      2. compute-intensive problems for which run-time is important.
      For the first of these, an interpreted prototyping language with an embedded symbolic processor (like mathematica) may well be the best bet.

      For the second kind of problem, optimization can be of critical importance. It is inherent in the language that Fortran is more optimizable than C: due to the rules of the language, alias analysis in Fortran is a (relatively simple) polynomial-time problem. At present (though there is effort being put into the C 2X standard to try to change this), alias analysis for C and C++ is a NP-complete problem. And given the current processor trends (deeply pipelined superscalar processors running much faster than their memory interfaces), that gives Fortran a factor of 2 performance edge (at present; this promises to become even more marked in the future...)

      That doesn't mean that you can't write object-based software in Fortran; I've been doing that for many years, on large scientific modeling codes. Bertrand Meyer's seminal book (The Construction of Object Oriented Software? -- not sure of the title; I'm snowed in at home and my copy is at the office :-( ) even has a section on writing object based Fortran.

      Based on two decades of experience in computer modeling, my advice to ThChalm is:

      Write object-based software with large objects. By this, I mean that you should make entire field objects (whose attributes are large arrays), for example, rather than having fine-grained objects with just values as attributes. Then the iterators and solvers properly are methods that contain the procedural code
      And frequently this attitude will cause you to re-think the problem, and use far better algorithms than you would have otherwise.

      When I applied these ideas to various problems in the high-performance environmental modeling problem domain, I wound up with an emissions model that is 600 times faster than its fine-grained OO predecessor, and an atmospheric chemistry/transport model that is 10 times faster than a competing naively-written procedural-style model.

      --
      "My opinions are my own, and I've got *lots* of them!"
    9. Re:Look at the audience.... by Analog+Squirrel · · Score: 1

      Hmmm... before we start arguing P vs NP-complete problems, how about some actual data? If Fortran produced code twice as fast as C, the whole "C vs Fortan" religeous war wouldn't exist. I am using C for my current project, an event-driven har particle simulation, because the paper in which the algorithm I'm using was published stated that the program produced from the C compiler run about 10% faster than the equivalent Fortran program(Marin, Risso, Cordero; Efficient Algorithms for Many-Body Hard Particle Molecular Dynamics; Journal of Computational Physics, 1993, vol 109, pgs 306-317). This doesn't make the rest of what you say invalid - in fact I agree with most of the rest of what you said, including the advice to make use of large-grained objects. What makes OO languages important in large scale software engineering is that they tend to enforce good programming style(an object is really a logical ordering of high cohesion procedures and data). Good programming style can be used to great benefit in any language, but many languages allow a large number of horrible abuses - C is the poster child for abusable languages. I think this why OO elements are finding their way into most modern languages: C evolved into C++ and objective C and even Fortran 95 has OO capabilities.

      --
      I'd rather be flying
    10. Re:Look at the audience.... by coats · · Score: 2
      event-driven hard particle simulation... the paper in which the algorithm I'm using was published stated that the program produced from the C compiler run about 10% faster than the equivalent Fortran program... Many-Body Hard Particle Molecular Dynamics...
      ...an indirect-addressing problem, no? So you have a problem dominated by memory-based data dependencies, not one dominated by computation (and so the alias-analysis aspect is not important to that particular class of codes. If you look at your peak FLOPpage, you'll find that it is almost certainly less than 10% of theoretical processor peak. Dense computational codes (for which alias analysis is important) will run at 50% or better (if well-written).

      The bad news is that your 10% will get to be a progressively smaller fraction, given trends in processor architecture (deeper pipelines, greater scalarity).

      --
      "My opinions are my own, and I've got *lots* of them!"
    11. Re:Look at the audience.... by Anonymous Coward · · Score: 0

      When I was in university (about 10 years ago or so) I had a summer job working for a researcher. They had this FORTRAN program that they had wanted
      to use - it was in a research journal and someone else had typed in the code.

      I got it to run and ran it once and it took more than 24 hours to complete. Then I read through all the code and noticed all the horrible, inefficient algorithms used in the program, fixed it and then it ran in about 20 minutes.

      Sometimes I wonder if some of these people who think they "need" fortran for the performance,
      when what they really need is to learn how to write efficient algorithms.

      In some cases I am sure it is justified to use fortran, but no amount of compiler optimization can save you from using bad algorithms.

    12. Re:Look at the audience.... by Analog+Squirrel · · Score: 1
      Heh - point well taken. :-)

      I was merely quoting the primary source I'm working from. I have to get mine working properly before I have any objective data of my own :(

      You're right, of course. In fact, the "Efficent" part of the algorithm has to do with the event selection(use a balanced tree and event selection becomes a log N operation). With large data sets, this is extremely important. It won't be until I add better physics that the computational aspect will be seen all that much...
      The primary reason I didn't use Fortran 90/95(so I could compare the run times of the resulting programs) is that I don't have access to a good compiler.

      --
      I'd rather be flying
    13. Re:Look at the audience.... by Anonymous Coward · · Score: 0

      Fortran and OOP are NOT mutually exclusive, in fact the Fortran 90 dialect has OOP features. While not an "engineering" application, there was substantial work done by Norton along with Decyk and Szymanski and others on simulation of plasma physics and containment, in their numerical Tokamak simulation, The CACM paper gives a nice overview but it is not available on line due to copyright restrictions.

      Unfortunately, since this post is actually factual and informative and I'm an AC it will not get modded up to a readable level without help, Thus, I'll need to throw in the following keywords/phrases to get
      modded up :-)

      Alan Cox
      Linus Thorvalds
      KDE
      GNOME
      Richard Stallman
      Beowulf Cluster
      Micro$oft sux
      L33T HaxorsRIAA Bastards!How about a Beowlf cluster of those?

    14. Re:Look at the audience.... by ameoba · · Score: 2

      I was always under the impression that FORTRAM was the language of choice for engineering apps because there's 30 years worth of codebase and libraries built up for it.

      --
      my sig's at the bottom of the page.
    15. Re:Look at the audience.... by Tony-A · · Score: 1

      Not just the current generation. FORTRAN has been around and available for more than 40 years that I am personally aware of. Fun thing on GE Timesharing was to use FORTRASH (only the first 3 letters were significant).
      The assumption is that everybody knows FORTRAN, at least to the point of being able to read and write Formulas. Programming ability is a completely different subject, although FORTRAN has been used as a sort of universal machine language.
      Integers, Floats (called REAL), and Complex numbers are the (very!) basic data types. The results of computations are very predictable. For fun, try to establish bounds on the numeric errors that a C or Pascal compiler is allowed to commit. If you have something like Result = (Large - Large) / (Large - Large), the various algebraicly equivalent forms can yield wildly different results. Experience and instinct dictate spelling it out in painstaking detail if the results are critical.

    16. Re:Look at the audience.... by wsloand · · Score: 1

      Sometimes I wonder if some of these people who think they "need" fortran for the performance,
      when what they really need is to learn how to write efficient algorithms.


      This is true for most larger engineering algorithms. Generally, at least 20% of the time should be spent on the 1-2% of the code that is the most inner loop. Also good analysis should be performed on the compiler itself. For example sometimes x*x takes less time than x^2 and when you do this 100K times per iteration over 100K iterations the fact that you save .001 seconds per exponentiation can make a noticable difference.

    17. Re:Look at the audience.... by servoled · · Score: 1

      I am in school for electrical engineering, and for the most part they aren't teaching us fortran at all. Most of the time we use matlab to solve things which previously would have been solved in a fortran program. Seeing as I don't know much about fortran I can't make a good comparison, but my professor says that he can write the necessary programs alot faster in matlab than he ever could in fortran.

      --
      "I have a porkchop, you have a porkchop. I have a veal, you have a veal".
    18. Re:Look at the audience.... by w_crossman · · Score: 1

      VB isn't a scripting language! VB is compiled just like any other real language. The only reason I'm using Java now is because VB just doesn't object-orient well and doesn't have enough features. I love the language otherwise. The VB IDE also blasts away others in stability and user-friendliness. C/C++ could learn a lot from VB. Don't knock until you've really tried it. The worst it could be accused of is allowing programmers to write bad code.

  5. OOP by Ashcrow · · Score: 2, Interesting

    In my opinion, OOP is only good in large scale yet generic problems. I've seen many people do C/C++ combonations where they filled in C++ gaps with their own C code.

    Maybe another way to look at it is to use what you know. It seems like a good amount of engineering students use fortran or pascel to do their engineering work in. As a computer science guy I hardly ever see fortran or pascel when doing my work (school or job), but it boils down to the fact that it works and thats whats important.

  6. what should i use? by oyenstikker · · Score: 1

    So what would be a good language to learn for a beginning mechanical engineering student?

    --
    The masses are the crack whores of religion.
    1. Re:what should i use? by Anonymous Coward · · Score: 0

      English.

    2. Re:what should i use? by QuaintRcky · · Score: 1

      Python - a lot of scientists and engineers use it.

      The value of python comes from the clarity and simplicity of the language, meaning it is much easier to concentrate on the problem than the language. It also has a first class object model, and yes - it is just as happy in the functional or structural programming model as the object oriented one.

      Also in answer to the main question, yes the examples you are giving are too small, but combine 10 such filters into a workflow of data processing and you might start to see some of the value of object-orientation. As the richness of data-sets increases, and the complexity of the algorithms to work on them increases, object-orientation is a way of staying on top of the complexity. It is also more of a "simulation" approach to breaking down the problem, think of a real world solution and simulate it - it is no accident that smalltalk (one of the early O-O languages and still one of the best) evolved from the language simula.

    3. Re:what should i use? by redhog · · Score: 2

      Why not learn Scheme? It is weel suited for implementing recursive algorithms in a straight-forward way. Also, may I suggest learning some logic-based language, like prolog, with a finite domain solver included (as the one in gprolog)? I don't know, since I'm no engineer, but I can imagine a finite domain solver being usefull for engineering tasks (it can be used for e.g. scheduling several tasks to reduce resource usage and the like).

      --
      --The knowledge that you are an idiot, is what distinguishes you from one.
    4. Re:what should i use? by Anonymous Coward · · Score: 0

      forget the language..
      ProE, you'll get a high paying job

    5. Re:what should i use? by Anonymous Coward · · Score: 0

      Fortran 95. Almost all the things computer science people hate about Fortran have been deleted or declared obscolescent (i.e., will be deleted in the next version of the standard, expected to be finalized within 3 to 5 years). Modules, Derived Types, and Pointers make it possible to do OO design within Fortran 95. GOTO is still supported, but it's primary uses (branch out of a loop iteration) are now more easily handled with CYCLE and EXIT. The array notation, and large number number of array-oriented intrinsic functions make scientific programming much easier. Compiler optimizations within Fortran are much easier than for C since the use of pointers is controlled fairly tightly, such that it is EASY for the compiler to detect when pointer aliasing might or might not be a problem. I can write shitty Fortran 95 and still achieve 10% better performance than tightly coded C or C++ due to this feature alone.

    6. Re:what should i use? by howard_roark · · Score: 1

      Speaking as a mechanical engineering student, take a C or C++ class. Try to find a good class where they teach you some optimization and theory, and don't just give you a sheet of code and have you type it in. C and C++ are nice because they are very common, you can get compilers for them just about anywhere, and they are very fast (some may argue that fortran is faster for calcs, but it wont be much faster). Another advantage is that 75% of the languages I have seen are block structured languages (like C). Once you learn C you can learn just about any non OOP language in a couple hours. If you learn C++ and OO theory you can do just about any OO language. Someone made a good point about OO being a style, rather than being required by the language. In most cases I would agree, but if you want to do Java, you need to know OO. Other languages that are helpfull for MEs are Matlab (student version is relatively cheap), Maple (student version also cheap)and Python (lots of math libs). Stay away from basic, you will just code yourself into a corner.

    7. Re:what should i use? by geekoid · · Score: 2

      C
      if you know C, your learning curve on everything else will be much smaller.

      I presume you'll be using some sort of CAD in your work, find out if any of the CAD program support plug-ins, or features you can write your self. that learn the language it supports. Thats a good career move, even if you have to learn basic!

      --
      The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
    8. Re:what should i use? by DeMorganLaw · · Score: 1

      I helped a friend of mine through the two computer science classes he took as a mech. engineer. Both classes were in C and actually pretty cool, use C to solve practical problems. I still have hardly done any practical coding in my three years as a CS major.

    9. Re:what should i use? by sigwinch · · Score: 2
      Python - a lot of scientists and engineers use it. The value of python comes from the clarity and simplicity of the language, meaning it is much easier to concentrate on the problem than the language.
      I'd add that Python is very easy to learn, and forgiving of mistakes. It's also easy to write optimized extensions in C or C++, so running into a performance wall isn't a big worry.
      --

      --
      Kuro5hin.org: where the good times never end. ;-)

    10. Re:what should i use? by Anonymous Coward · · Score: 0

      English...

    11. Re:what should i use? by Anonymous Coward · · Score: 0

      Matlab.

      Very simply put, Matlab is to numbers as Perl is to Strings.

      I was a science major & all anyone used for calculations was matlab. Matlab can boil nearly any iterative operation and most accumulative operations into 1-2 lines of matrix code, without the need for a for-loop.

    12. Re:what should i use? by Anonymous Coward · · Score: 0

      Java and/or Python

    13. Re:what should i use? by Anonymous Coward · · Score: 0

      Well, all of our MEs have 2 required quarters taking FORTRAN, and they use it for many of their later classes. However, there has been an emphasis encouraging the MEs to pick up CS minors in recent years, which would give them experience using C/C++ and Java. (Oh, and MFC stuff too blah!)

    14. Re:what should i use? by Anonymous Coward · · Score: 0

      I'll agree with all of the above... but note that Matlab can get expensive. Octave (matlab clone) is out there for linux and it's FREE.

    15. Re:what should i use? by Kirruth · · Score: 1
      There are three broad kinds of programming (called "paradigms") you might want to do:

      - imperative programming: which is telling the computer all about the data, all about what you want to do with it, then going through it step by step.

      - functional programming: which abstracts what you want to do with the data i.e. a functional program will calculate an answer, without necessarily telling you how it did it

      - object orientated programming: which abstracts the data i.e. you tell the computer what to do with a box containing the data, but don't care as much about what might be in the box.

      When people say a programming language is "functional" or "object orientated" it means that the programming language has a core set of features which make programming using that particular paradigm easy.

      The kind of problems you will want to solve in engineering will typically be functional in nature: simple data, complex transformations.

      You could use a pure functional language to do that: ML is popular (as, er, functional languages go), Haskell is great too.

      Or you could use so-called multiparadigm languages. Scheme or Lisp, its big brother, have functional and object orientated elements. Python has all three paradigms in its core, without going into huge depth in any of them.

      So, any of those would be a good choice. Python is very accessible: I'd go with that first of all.

      --
      "Well, put a stake in my heart and drag me into sunlight."
    16. Re:what should i use? by Bush+Pig · · Score: 0

      I'd have to agree here. I did a couple of numerical analysis units at university, and we used Matlab extensively. It's a great prototyping language for engineering-type problems, and debugged scripts can be easily converted to FORTRAN programs for real problems (as the two languages have similar syntax - or did at least).

      --
      What a long, strange trip it's been.
    17. Re:what should i use? by Anonymous Coward · · Score: 0

      You should use French, or at the very least use English with a French accent.
      Nothing gets you laid quite like using french - and as a beginning mechanical engineering student - you need all the help you can get!

    18. Re:what should i use? by Anonymous Coward · · Score: 0

      perl

    19. Re:what should i use? by Anonymous Coward · · Score: 2, Insightful

      Glad to see so many mentions of Python, and i agree. Its a great language, with clear syntax, powerful built in types and many many useful libraries (web server library as standard... what are thinking?)

      Python makes excellent glue for bringing in a lot of different parts to make one program. The thing is that for a lot of the time glue is all you need.

      When you need more than glue, I recommend some other languages, and some super-glue. If Python can't do something fast enough, Ada can ( I was shocked to see a teeny ada program outperform a teeny C program by a factor of 5, and all it was doing was a simple calculation several million times. The Ada compiler must have done a truly great job .)

      If you think you can express certain parts of the system better in a functional language, such as haskell, then use haskell for those certain parts.

      And as for the super-glue? CORBA is an amazing system for getting languages to talk to each other, even with parts being run on other machines ( if you need high MFLOPS in one function, make sure it runs on a mchine with high MFLOPS, makes sense to me ;)

      So yes, I would recommend you start by learning Python. If that is ever not enough for a part of a system, use something else that is. I like haskell and Ada, as I think they represent the best there is for their target audiences. I can say the same for CORBA, I think its the best super-glue on the market, and enables many languages to integrate seemlessly.

    20. Re:what should i use? by other_things_to_do · · Score: 1

      Absolutely! One cannot over estimate the value of mental serenity in engineering school. When you have abusive work loads, abusive hours, and abusive professors getting some sure takes the edge off.

  7. Complex Question... by Marx_Mrvelous · · Score: 5, Interesting

    This is a really difficult question to answer. I guess my reply would be that no, pure "OO" programming wouldn't hold any advantage to simple procedural programming in this case. However, you can easily add procedures to objects, so OO language is really just a superset of procedural.

    Personally, I like the organizational potential of OO. You can have a Pipe object, and call function like Pipe.calculateFlowrate(12,43,23), then you could have a subclass SquarePipe, and call the function SquarePipe.calculateFlowrate(12,12,43,23).
    Essentially, you could have 10 objects each with 10 functions to do 100 different tasks, rather than 100 different functions to do 100 different tasks.

    --

    Moderation: Put your hand inside the puppet head!
    1. Re:Complex Question... by taliver · · Score: 2, Insightful

      However, you still end up writting 100 different functions in either case, and calling

      squarepipe.calculateFlowrate

      seems no easier to remember than

      squarePipe_CalculateFlowRate()

      or

      CalculateFlowrate(SQUAREPIPE,...)

      Also, if you have generic functions across all classes, you are left with a bizarre model of pipes, bowls, steam generators, and anything else having to be under some umbrella so you can attach a "SurfaceArea" or "Volume" calculator or some other generic routine.

      I've also never been a big believer of the whole "code-reuse" argument. The biggest code-reuse in practce is all done in C, and very non-OO -- libc.

      Unless you already have a big simulator witten in OO style, and you need a simulator, I'm not sure of the use of OOP. If you are trying to do a large calculation, then the time you spend in trying to stick to the OOP mindset doesn't seem like it will ever pay off.

      --

      I demand a million helicopters and a DOLLAR!

    2. Re:Complex Question... by tibbetts · · Score: 1

      You can have a Pipe object, and call function like Pipe.calculateFlowrate(12,43,23), then you could have a subclass SquarePipe, and call the function SquarePipe.calculateFlowrate(12,12,43,23). Essentially, you could have 10 objects each with 10 functions to do 100 different tasks, rather than 100 different functions to do 100 different tasks.

      While I agree in principle with this example (since mechanical engineering deals with real-world objects which can be quite easily modeled using OO design), I find fault with the example's implementation. The SquarePipe doesn't inherit anything useful from a Pipe, especially because the calculateFlowrate() methods have different signatures. Perhaps a better model would look like this:

      class Pipe {
      public:
      virtual float getFlowRate( float& x, float& y ) = 0;
      }

      class RoundPipe : public virtual Pipe {
      private:
      float _diameter;

      public:
      RoundPipe( float& d ) : _diameter( d ) { ; }

      getFlowRate( float& x, float& y ) const {
      // i don't know the flowrate formula
      return ( _diameter * x * y );
      }
      }

      class RectangularPipe : public virtual Pipe {
      private:
      float _height;
      float _width;

      public:
      RectangularPipe( float& h, float& w ) : _height( h ), _width( w ) { ; }
      float getFlowRate( float& x, float& y ) const {
      return ( _height * _width * x * y );
      }

      // now use them polymorphically to find the flow rates
      Pipe round = new RoundPipe( 30.0 );
      std::cout << "Round pipe flow rate: " << round.getFlowRate( 12.0, 9.0 ) << std::endl;
      Pipe rect = new RectangularPipe( 4.0, 40.0 );
      std::cout << "Rectangular pipe flow rate: " << rect.getFlowRate( 12.0, 9.0 ) << std::endl;

      Add support for things like pipe length, and you can now use high-level Pipe objects without having to always pay attention to whether they're round or rectangular. (In other applications, such as positioning pipes in a predefined space, the specifics may be more important.)

      --
      :wq
    3. Re:Complex Question... by piggy · · Score: 4, Insightful
      However, you still end up writting 100 different functions in either case, and calling

      squarepipe.calculateFlowrate

      seems no easier to remember than

      squarePipe_CalculateFlowRate()

      or

      CalculateFlowrate(SQUAREPIPE,...)
      But this is easier if you don't know the pipe type before runtime, or the type could change:

      PipeType * theTypeOfPipeAsParameter;
      FlowRateParams * flowrateparams;
      Pipe * thePipe;
      [[thePipe alloc] initPipeWithType:theTypeOfPipeAsParameter];
      flowrate = [thePipe calculateFlowrate:flowrateparams];

      That is, you are correct unless you dynamically create pipes of different kinds at runtime, perhaps using an abstract factory (for example, an interactive simulation which allows the engineer to manipulate the objects) or, at a more basic level, have need to send the same message to a collection of disparate pipes (for example, compare the simplicity of the design and code to send the same "calculateFlowrate" message to each object in an array in a polymorphic OO language versus a procedural language).

      My point is that, perhaps the implementation of the calculation cannot easily be made OO, but access to that calculation can often benefit from an OO wrapper.

      Just off the top of my head. At work, we are attempting to apply OO to requirements analysis, while still persisting in the "object-based" world of Ada development. (This means that I don't have any real world, OO engineering implementation examples).

      Russell Ahrens

    4. Re:Complex Question... by STSeer · · Score: 2, Insightful

      "It is better to have 100 functions operate on one data structure than 10 functions on 10 data structures. "

      Alan J. Perlis

      http://www.cs.yale.edu/homes/perlis-alan/quotes. ht ml

    5. Re:Complex Question... by Malc · · Score: 2

      "The biggest code-reuse in practce is all done in C, and very non-OO -- libc. "

      These days, the STL is a more and more popular example of OO code re-use. Yes, I know, it can lead to code-bloat. But, in most things that I've worked on that hasn't mattered. What has mattered is that I've been able to produce easily read, easily maintained, bug free code very quickly. Where there has been a performance issue, I can come back and spend more time on it later. Of course, in every OO language where there is heavy use of class-libraries (e.g. everything in Java or SmallTalk), you're seeing huge amounts of daily code-reuse. In most cases of custom code, the effort of making it re-usable only seems worthwile if you're going to re-use it at least three times.

    6. Re:Complex Question... by Anonymous Coward · · Score: 0

      > You can have a Pipe object, and [...]

      If you create a pipe object, that reflects _your_ concept of a pipe. This might be fine for your usage, but if you want the pipe object to be useable to a wide audience of programmers and have wide applicability (one of the goals of OOP), you have to REALLY generalize the concept of a PIPE and thus make it VERY complex.

      Since no one is the ultimate authority on pipes, it would be necessary to assemble a congress of technical professionals to decide on all the appropriate methods, properties, interfaces and abstractions for all the levels of the inheritance heirarchy of the pipe object. Of course, this would then have to be fully consistent with even more complex related objects such as fluids and valves. Oh yeah, and throw in properties of accepted specs for all the different standards organizations (ANSI, MIL spec, ISO...), and then make them all consistent in usage. Finally, repeat the above every two years, forever.

      The ultimate result of trying to generalize the concept of "pipe" into a universally useable object will be a dictionary-sized piece of documentation that paralyzes a programmer's productivity for days and that practically begs for inproper useage.

      OOP is very hard to do properly. In a sense, the designer of an object is a TOOLMAKER. Software tool sets are the hard to design because you are not designing for a PARTICULAR usage, you are designing for an UNKNOWN usage.

      Very few people are BOTH domain experts (ie mechanical engineers) AND computer science experts. Until it is possible for domain expertise to be translated into OOP without computer science knowledge, OOP will be not be at the forefront of techincal computing.

    7. Re:Complex Question... by michael_cain · · Score: 4, Insightful
      Dang -- never have moderator points when I want them...

      I particularly like this as an example of the expressive power that an OO language can provide. A straightforward "equivalent" in C (not necessarily a good equivalent) might look like

      #define PIPE struct Pipe
      #define ROUND 1
      #define RECTANGULAR 2

      PIPE {
      int type;
      float diameter;
      float width;
      float height;
      }
      .
      .

      float
      flow_rate(pipe, x, y)
      PIPE *pipe;
      float x, y;
      {
      float result;
      switch (pipe->type) {
      case ROUND:
      result = stuff;
      break;

      case RECTANGULAR:
      result = stuff;
      break;

      default:
      result = -1; // Assume real flows are positive
      break;
      }
      return result;
      }
      .
      .

      PIPE *round, *rect;
      .
      .

      round = (PIPE *)malloc(sizeof(PIPE));
      round->type = ROUND;
      round->diameter = 30.0;
      result = flow_rate(round, 12.0, 9.0);
      rect = (PIPE *)malloc(sizeof(PIPE));
      rect->type = RECTANGULAR;
      rect->height = 4.0;
      rect->width = 40.0;
      result = flow_rate(rect, 12.0, 9.0);

      And there are lots of problems with trying to maintain or extend this code. For one thing, the code that deals with ROUND pipes is scattered all over the place in each of the functions that applies to the generic pipe concept. If different pipe types require different numbers of parameters for flow_rate, you have to get into varargs stuff and lose a lot of type-checking that the compiler might do for you.

    8. Re:Complex Question... by jmccay · · Score: 2

      To some extent you can do that in Functional Programming. It all depends on how you design the functions. You can use 10 super functions to call a varing number of subfuntions the get futher specified as you go down.
      As someone else pointed out, a mixture of functional and OOP is probably your best bet. This way you continue emphasis the best tool for the best job. OOP is just another methodolgy of writing programs. More will come along--such as aspect oriented programming. (Don't ask me the detail because I haven't had time to delve to deep into it yet, and for more information on that see AOSD.)
      With each new methodology I learn, I add it to my belt of tools. I expect to keep on doing this. You never know when we will need to revert back to some older methodolgies--although I doubt I will go back to spaghetti code.

      --
      At the next eco-hypocrisy-meeting, count the private jets used to get to the meeting. Should be interesting to see that
    9. Re:Complex Question... by dmelomed · · Score: 1

      His question is specific to OO, but anyway: one of the reasons why stuff like that is not solved using OO languages is probably because they don't offer much of the requirements for these problems.

      His, problems IMHO scream "GIVE ME A FUNCTIONAL LANGUAGE". Some functional languages semantically and syntactically resemble calculus and offer features that are better at helping solving engineering problems at hand. Take a look at Haskell or Erlang (a heavy-duty language proven by telecom industry) for example.
      Simple syntax, easy to learn (very few keywords), very few side-effects and you probably don't want a mechanical engineer to worry about memory allocation either.

      I would think these exceed an engineer's requirements over C++ or Java for solving many problems (not all): garbage collection of course, massive concurrency (thousands of threads in one instance of a virtual machine in Erlang for example is no problem) as part of the language, exceptions handling, built-in interprocess communication, pattern matching (polymorphism), resizable lists and tuples, tail-call recursion, modules, hot code updates on running systems, etc., etc. And no OO to get in the way. These help you concentrate on _what_ to solve at hand, instead of _how_ to solve your problems (memory allocation, OO, etc.). You leave most of _how_ to the language, and worry about the problem, not language. Similar to working with Mathematica or Maple, except on a much larger scale.

      These languages are great for higher-level logic that's very tough to do in lower-level languages like C or C++. They can be interfaced to C or other languages for performance-critical, or device drivers etc. needs. Bottom line: writing software for many engineering problems in functional languages should be easier, because they were designed for some of those specific purposes (like Ericsson's AXD switch).

    10. Re:Complex Question... by Peaker · · Score: 2

      Note that C++ mostly offers syntax sugar over C.

      In C, you don't really have to 'switch' for polymorphism.
      You could use a vtable. You don't have to use malloc and inits, and can write a new and init method for your object. As for a 'dynamic' number of parameters, you'd need a vararg list in C++ too. You're talking about overloaded argument lists, and this can be implemented in C, if you just manually mangle the arglist into the function/method name. C++ doesn't really add conceptual improvements to C (except for exception handling and templates, but both are broken beyond repair), and all of the new C++ syntax is just abbriviating some C underscores :)
      You generally end up with the same C++ code, with :: replaced by underscores, vtables manually written, and new methods to malloc and call _init methods that you could do without in C++.

      typedef struct {
      struct pipe_vtable_s* vtable;
      float diameter;
      float width;
      float height;
      } pipe_t;

      typedef struct pipe_vtable_s {
      float (*flow_rate)(pipe_t* pipe, float x, float y);
      } pipe_vtable_t;

      float round_pipe_flow_rate(pipe_t* pipe, float x, float y);
      float rectangular_pipe_flow_rate(pipe_t* pipe, float x, float y);

      pipe_vtable_t round_pipe_vtable = { round_pipe_flow_rate };
      pipe_vtable_t rectangular_pipe_vtable = { rectangular_pipe_flow_rate };

      void pipe_init(pipe_t* pipe, pipe_vtable_t* vtable,
      float diameter, float width, float height) {
      pipe->vtable = vtable;
      pipe->diameter = diameter;
      pipe->width = width;
      pipe->height = height;
      }

      pipe_t* round_pipe_new(float diameter, float width, float height) {
      pipe_t* pipe = (pipe_t*)malloc(sizeof(pipe_t));
      pipe_init(pipe, &round_pipe_vtable, diameter, width, height);
      return pipe;
      }

      pipe_t* rectangular_pipe_new(float diameter, float width, float height) {
      pipe_t* pipe = (pipe_t*)malloc(sizeof(pipe_t));
      pipe_init(pipe, &rectangular_pipe_vtable, diameter, width, height);
      return pipe;
      }

      float round_pipe_flow_rate(pipe_t* pipe, float x, float y) {
      return stuff;
      }
      float rectangular_pipe_flow_rate(pipe_t* pipe, float x, float y) {
      return stuff;
      }

      pipe_t *round, *rect;
      float result;

      round = round_pipe_new(30.0, 0, 0);
      result = round->vtable->flow_rate(round, 12.0, 9.0);
      rect = rectangular_pipe_new(0, 40, 4);
      result = rect->vtable->flow_rate(rect, 12.0, 9.0);

      Yes, a lot more pain doing the declarative stuff, but once its done, the actual code is just as simple.

      -------------
      For goodness sake, don't use that #define PIPE thing, that's what typedef's are for!
      And two #defines in a range? That's what enums are for!

    11. Re:Complex Question... by nathanh · · Score: 2
      And there are lots of problems with trying to maintain or extend this code.

      No wonder, you write shit like this...

      #define PIPE struct Pipe
      #define ROUND 1
      #define RECTANGULAR 2

      What's wrong with typedef? enum? Why are you using switch statements instead of function pointers? Why doesn't your PIPE structure use a union? Why are you throwing assumptions into the default case instead of just asserting them at the start?

      It's OK for you to have less than stellar C skills; nobody is born knowing C. But it's not OK for you to then make judgements about the relative merits of C versus an OO language. You need to be good at BOTH before you can make qualitative comparisons.

    12. Re:Complex Question... by igrek · · Score: 2

      The STL is NOT based on OO paradigm. It's called generic programming. And Alexander Stepanov, the STL author, is not happy with OOP at all. There were some problems with mapping STL concepts into the C++ language. Bjarne Stroustrup even added some non-OO features to the language in order to support STL.

    13. Re:Complex Question... by ShunScene · · Score: 1

      You're confusing OO techniques with classes.
      It's perfectly legal and moral to use classes to organise your code to clean up your example, with no requirement that you also put it into an inheritance heirarchy...
      As a random example, consider the named constructor idiom:
      class Pipe{
      public:
      Pipe Round(); //factory to create a Round pipe
      Pipe Square(); //factory to create a Square pipe

      Pipe & operator = (const Pipe &); //assignment operator
      Pipe(const Pipe &); //copy constructor

      private:
      Pipe(); //constructor is private
      };

      Pipe roundedPipe = Pipe::Round();


      (Notice the pass-by-value semantics you get too...)

      -ShunScene

    14. Re:Complex Question... by Malc · · Score: 1

      I'd like to understand... can you explain or post a link to an explanation? Sure, it is extremely and impressively generic, and Mr. Stepanov is a complete abstraction nutcase! But, I'm not sure why you would say that it isn't OO.

  8. Different solutions to different problems by Crimplene+Prakman · · Score: 5, Interesting

    There are a number of ways to approach this, but I've found the following useful:

    • if you're relating to physical objects e.g. sensors, displays, etc., then create an object
    • Algorithms, problem-solving functions, and procedures such as you're talking about, can then be added as methods to the objects you've created, or you can create new "virtual" or "calculator" objects to fit between the ins and outs, that expose your algorithms and procedures as methods before outputting them.

    It's more a matter of thinking in terms of telling your processes to do stuff than creating a road for them to walk down. If you know what I mean ;-)

    All your Qaeda are belong to US

    1. Re:Different solutions to different problems by wfrp01 · · Score: 2

      Algorithms, problem-solving functions, and procedures such as you're talking about

      ...can also be objects. See SGI's STL Manual for some examples.

      I'm not arguing in favor of using OO for everything, just pointing out that "objects" can be more broadly defined that the typical C++ intro depicts them.

      --

      --Lawrence Lessig for Congress!
  9. Perhaps the computational power is to be questionn by aepervius · · Score: 1

    I am not experienced in OOP programming anymore, especially how good the compiler are now, but maybe OOP is mostly used for its inheritance in data structure , and reusability of the code (enhance UI, management problem etc...). On the other hand, physic and mathematic problem require usage of pure processing power on calcul. Maybe OOP would help add an UI layer, but using data structure with OOP in raw calcul might add an innacceptable "slow down".

    --
    C. Sagan : A demon haunted world:
    http://www.amazon.com/gp/product/0345409469/
    visit randi.org
  10. Don't confuse OO techniques and languages by twoflower · · Score: 3, Insightful

    OO design has nothing to do with C++ versus C. You can do OO design with any language you like; much of the Linux kernel has elements of OO design, but is implemented in C.

    Language is an implementation detail. It does not dictate design.

    Twoflower

    --


    --
    Twoflower
    1. Re:Don't confuse OO techniques and languages by Anonymous Coward · · Score: 0

      This is a troll right? You can't do object oriented programming with every language. Many languages don't have the ability to do OOP.

      Sure you could do OOP with C, but you'd have to do a lot of extra footwork in order to get those objects created in C to act like objects.

    2. Re:Don't confuse OO techniques and languages by Anonymous Coward · · Score: 0

      Ok smarty pants. What language is your precious OOP language actually written in? Huh? Huh?

      Smack!

    3. Re:Don't confuse OO techniques and languages by Marsh+Jedi · · Score: 1

      Um, okay...

      If this were true, then why did we _need_ all these other languages? Caprice?

      If people invented / adopted new languages only when a program cannot be implemented effectively, perl or another kitchen-sink language would have long ago swallowed the Earth.

      Many languages reason for being is that that their inherent features make design cleaner.

      Do not tell me that Emacs would have the same design if it were written in Java.

    4. Re:Don't confuse OO techniques and languages by kaladorn · · Score: 1

      Language _should_be_ an implementation detail. In practical fact, there are many instances where it actually does represent a constraint.

      Additionally, not all languages are equally capable of implementing a given design. Design done without reference to the language it will be implemented in is Utopian thinking. It fails to account for the efficiencies and defficiencies of particular languages.

      In a perfect world, langauge would be an implementation detail. In the real one, it is a design consideration.

      --
      -- Mal: "Well they tell you: never hit a man with a closed fist. But it is, on occasion, hilarious."
    5. Re:Don't confuse OO techniques and languages by Anonymous Coward · · Score: 0

      Most modern compilers are written in their own language, e.g. the c compiler is written in c, the c++ compiler is written in c++.

    6. Re:Don't confuse OO techniques and languages by chris_mahan · · Score: 1

      Absolutely.

      The same goes for human languages. The language itself influences the thoughts of the author, so that a particular expression in one language can never be quite the same in another.

      --

      "Piter, too, is dead."

    7. Re:Don't confuse OO techniques and languages by UnknownSoldier · · Score: 2

      2F> You can do OO design with any language you like
      MJ> Um, okay...
      MJ>If this were true, then why did we _need_ all these other languages? Caprice?

      Mostly because of cleaner syntax.

      You do have a point -- sometimes the language(s) make it impossible to express a given paradigm (i.e. Generic Programming in C)

      Methinks you haven't read Bjarne Stroustrups (dated but interesting) paper called What is Object-Orientated Programming

      YES, you *can* do OOP in C. What do you think 'cfront' did back when C++ was still in development, and there was no native compilers?! It translated C++ code into C. Sure it was ugly** C code, but it was C code doing the same job as "native" C++.

      (** ugly is not a redundant adjective describing C :) I've seen some beautifull C code)

      A native C++ compiler provides
      a) cleaner syntax
      b) better type safety

      Now templates are a whole different ball of wax. C has no paradigm for expressing generic programming. And this is the *real* reason C++ is so popular -- Multiparadigm support: Procedural, OO, and Generic. C++ is VERY powerfull once you start combining OO and Generic Programming. See Moden C++ Design - Generic Programming and Design Patterns Applied by Andrei Alexandrescu

      > Many languages reason for being is that that their inherent features make design cleaner.

      You are correct -- the underlying language that the app is implemented in will constrain the design, but a good language will let you pick the "best" design for you app.

      Cheers

    8. Re:Don't confuse OO techniques and languages by UnknownSoldier · · Score: 2

      > Most modern compilers are written in their own language, e.g. the c compiler is written in c, the c++ compiler is written in c++.

      The author's point is that C++ was first written in C, ala "cfront"
      (One of the Modula-3 compilers I used also produced native C code as well.)

      Using another language as your IL (Intermediate Language) is not new. Heck even gcc does this ;-)

      Cheers

    9. Re:Don't confuse OO techniques and languages by flegged · · Score: 1

      So how do you get your C++ compiler up and running, without a C++ compiler in the first place?
      The answer is that you bootstrap it with another compiler. The first C++ compilers were written in C. The first C compiler was written in assembly.

      Yes, you can write object oriented programs in assembly. You just treat every (non-builtin) variable as a pointer to an object. This is how it's done when C++ or Java is compiled to machine code (and yes, Java does get compiled to machine code, right before it's executed).

      And you can write procedural code in Java. The language does not dictate the design.

      --

      "I think he was truly surprised at how little I cared about how big a market the Mac had" - Linus on Jobs
    10. Re:Don't confuse OO techniques and languages by Anonymous Coward · · Score: 2, Insightful

      > Now templates are a whole different ball of wax. C has no paradigm for expressing generic programming.

      You are right, there is no nice way to specify generic (i.e. template) functions in C, but as with everything else in programming, there are ways. I can do generic functions in C, no problems at all, its just rather darn ugly.

      As you, and many people have correctly pointed out, the language is irrelevant. You can do pretty much anything in any language apart from where the language stops you expressing certain things. After all, C/C++/python/haskell all end up being run on finite state machines (CPUs) which do nothing more than maths and storage. A language can stop you in areas (like make file access impossible because there is just no way to do it) but apart from that you can do it all (might not be in a reasonable time frame, but so what)

      A language is just a way for a programmer to express what they want to be done. Some languages lend themselves to certain methods better than others. A perfect language would lend itself to any conceivable method, with a good clean, yet powerful syntax. Unfortunately elegance and control do not go hand in hand, which is why there are still many different languages.

    11. Re:Don't confuse OO techniques and languages by Ayende+Rahien · · Score: 2

      > So how do you get your C++ compiler up and running, without a C++ compiler in the first place?

      Well, I know that once upon a time, they sat (on a Pascal compiler, written in pascal) and executed the compiler *by hand*, and then just inputted all the zeros & ones to the computer, one by one.
      I shudder to think how long it would take for modern compilers.

      --

      --
      Two witches watched two watches.
      Which witch watched which watch?
  11. Round peg, Square Hole... by einer · · Score: 3, Insightful

    I'm not terribly familier with the problems you have presented (I.E. I know what a monte carlo alogorithm is, but not the radiative heat transfer part...), but it sounds to me like you're trying to fit the problem to the solution and not the other way around. OOP can be useful if you're trying to model something, or replicate the behavior behavior and characteristics of a real world problem, but it's not that great for say, solving a system of equations... I guess you can use whatever language or system you would like, but not many need C++ and the STL to evaluate expressions.

    1. Re:Round peg, Square Hole... by RTMFD · · Score: 2, Interesting

      I would have to differ with you on this one. I took a CS class this semester that dealt with the advantages and disadvantages of using OO code to solve damped spring problems, ODE solvers, etc. Using template engines, the Barton-Nackman trick, and other less-than obvious tricks allow you to have most of the benefits of a pure OO system without the speed tradeoffs.

    2. Re:Round peg, Square Hole... by madmaxx · · Score: 3, Insightful

      I disagree. C++ is intended to solve systems in the language of the domain - which is one of the central purposes of the language (see Design and Evolution of C++ by Stroustrup). Some of the strongest uses of C++ I've seen today are well abstracted matrix libraries for advanced signal processing (Blitz++) ... not too far from what the question is asking about.

      --
      mx
  12. need more specifics by demian031 · · Score: 1

    if you are plugging numbers in and expecting numbers out then procedural would be just as good as anything.

    but there might be other applications where oop will really pay off for you. one thing i can think of is possibly simulations.

    i think oop was first used in northern europe (yeah before PARC) to simulate manufacturing systems.

  13. Engineering Processes are Procedural by mheine · · Score: 4, Insightful

    All of the techniques you listed and most other engineering problems are expressed in a procedural format. In order to use OO you would have to transform the problem into an object problem. The things that OO does really well at are things where we already think in object terms. Like GUI widgets. Most engineering problems simply aren't expressed that way. Although most problems could be rephrased that way the algorithms would necessarily not be equivalent (better or worse would require experimentation)

    1. Re:Engineering Processes are Procedural by khendron · · Score: 1

      Not necessarily. I used to work on engineering simulations of engines in marine enviroments. While all the coding was done procedurally using FORTRAN, the actual application was very OO. The (gas turbine) engine was broken down into its individual components (compressor, combustion chamber, turbine, etc), and was connected to a power drive train to a propeller, and so forth. I think that OO would have done very nicely in this application.

      IMHO, one of the main reasons that OO is not used often in engineering application is that mechanical engineers are not trained to use it. In fact most mechanical engineers have minimal programming training in Universoty. OO is a powerful way of implementing a solution, but there are many many pitfalls that can turn the code into a nightmare. Until you are taught what these pitfalls are, you will probably end up with an unmaintainable mass of spaghetti code.

      There are three ways to learn OO properly. (1) Formally, in University, (2) On the job training by an experienced OO programmer, and (3) trial by fire on the job by yourself. In my experience (1) doesn't happen, most employers are not willing to invest in (2), and not willing to risk (3).

      --
      Life is like a web application. Sometime you need cookies just to get by.
    2. Re:Engineering Processes are Procedural by dissipative_struct · · Score: 1

      I'm not sure that engineering processes are more "procedural" than anything else. True, at the lowest level, you're probably working with processes that are better represented as functions/methods than as objects. But I think the same thing is true of most other problem spaces: at the most atomic level, the programming is more procedural. OO is an intelligent way to bring all these "low-level" pieces together.

      I expect the best use of OO in Engineering is still to provide an intelligent framework for a system that needs multiple atomic processes. For example, say you're simulating a gas in a chamber as a bunch of Newtonian spheres that collide with perfect elasticity. You could make a "GasParticle" class, and design you're simulation from there. Using the OO method is going to make it easier to incorporate changes later (i.e. imperfectly inelastic collisions) and makes your code more reusable (if you want to do a flow simulation in a similar way, you can reuse your "GasParticle" class).

  14. I think it's a problem of scale and understanding. by PHAEDRU5 · · Score: 4, Insightful

    If you're dealing with a problem that can be reduced to a mathematical formula or the like, you're probably better off looking in Numerical Recipes or the NAG libraries, or what have you.

    In this case, you're dealing with a well-defined, well-understood problem. You could implement a solution using OO principals, but why bother. I mean, you're not going to be changing it or adapting it all that much.

    The power of OO happens at a higher level, and with less-well understoof problems. In this case, you're modeling higher-level entities, with less well-understood properties that are much more liable to change. In this case, the ideas of modularity, pluggable behavious, cohesiveness, etc., become much more important.

    I hope that didn't sound too much like a hand-waving explanation.

    --
    668: Neighbour of the Beast
  15. any componentized program by mugnyte · · Score: 2, Insightful

    Code Reuse and extensibility is (IMHO) the largest advantage of OO. By (trying) to demark a dotted line around the box of code you want to (re)use and separating out your new code, you realize gains in writing and testing. Communicating what code actually does is also much cleaner in a componentized view.

    So take a look at many programs writting in Windows these days. Anything written that uses COM. Almost all *ix shell scripting. While they all follow different aspects of "object" reuse, you are benefitting from using a block of solid code without having to retest it. I'm abstracting the definition many people have of "object" as such, but in the end all the goals are similar: Get it done better, faster.

    mug

    1. Re:any componentized program by Anonymous Coward · · Score: 1, Informative
      OOP has next to nothing to offer compared to GP (Generic Programming) IMHO, although your mileage may vary.. ;-)

      OOP implies polymorphism (also known as ad-hoc polymorphism) through inheritance. Inheritance is one of the strongest possible relations you can express in an OO language. When you express such strong relationships between types (or class if you want to take a more pure approach) you are actually making your components extremely cohesive.

      Yes of course, you can always treat objects as "Object", but that doesn't help you much. You still need to know the least common denominator, and in most cases, it is NOT Object (or whatever your favorite root class is named). Thus you have to specialize your code to a specific purpose, or at least adapt to an older concept (by inheriting from a foreign class).

      Generic programming promotes something called true polymorphism. Generic polymorphism does not require inheritance. In fact, it does not require anything if you wish. For instance, look at containers. There you don't require anything of the polymorphic types (depending on implementation details of the language. C++ containers may for instance require copy constructable types and such). Of course you can do this with Object as well, just look at java. But you get a bonus here, and it's called "type safety".

      Not only do you get true polymorphic types, but you also get true polymorphic functions based on the types it processes. See it as instead of adapting the types (your required inheritance), you make the functions adapt to your types instead. For free. No hassle. No manual overloading required!

      Of course, not all things can be made generic, but thats where YOUR ideas come into play. You fill in the blanks. And that my friend, you can use good old fashioned imperative programming, functional programming, OO programming, logic programming, or whatever makes you tick.

      I used to be a believer in the saying "OO solves any problem". But then I discovered generic programming, and I changed my mind. OO does not solve all problems.. cleanly and efficiently. I started getting an idea during functional programming class, but then the FP-zealots don't want to hear about anything called generic. "It's functional, not generic!". 2 years later I started to use STL at work when I used C++. Guess what? Jesus [read ANSI C++ committee] reached out and touched me.

      STL not only gives you remarkably nice containers, it also gives you algorithms for free, the notion of functors and iterators. Mix these together, you'll never have to write retarded loops again working of your sets of data. They provide 100+ algorithms, tested and bugfree just for you to use. STL also have some real cool things in store: Models and concepts. These are interface descriptions for how components can be interacted with. It's similar to that of javas interfaces. The difference is that it no inheritance is required (java calls it implements, but its just an "pure virtual class being inherited"). A concept may just state something like "the type must be copy constructible and provide a function called size(), where the return value is compatible with the type size_t". If there is no copy constructor or size() function for that type, then the compiler will yell at you. In other words, extremely low cohesion.

      Try STL for your problem solving and you will like I, find that most of the boiler plate cruft has already been implemented for you. And the best part is that you don't have to commit yourself to some other class hierarchy.

      Those who are interested in STL, I dearly recommend the book "Generic Programming and the STL: Using and Extending the C++ Standard Template Library" by Matt Austern (amazon link). That one is really great learning STL and how/why it works, but it assumes that you know the basics of templates and C++. Starts out with the concept of iterators (quite a big deal in STL!), goes on with gory C++ details, continues with the different models and concepts STL has to offer, and finally provides a reference for pretty much everything in STL so that you can interpret the components in STL as well as providing your own component which are compatible with STL (in terms of concepts and models). Quite a good read actually, eventhough you don't plan on doing any generic programming.

      Another book is "Modern C++ Design: Generic Programming and Design Patterns Applied" by Andrei Alexandrescu (amazon link). This one is really advanced and can make your brain explode. But nonetheless it's a really good read. Eventhough many of the things in there may be called "too radical" by todays standard, it's a great source of ideas. This guy, Andrei, really pushes C++ to the limits. It's quite a spectacular show!

      The best part about Andrei is that he's an open source dude. Perhaps not a GPL-zealot, but nonethless, he likes to contribute code which may be used w/o restrictions by anyone else. His library "Loki" is currently being ported and integrated into the boost library. The boost library is the natural extension of STL, written and maintained by C++ committee members and other excellent engineers. All code that goes into boost must go through a rigorous peer code review as well as document review, thus you can count on the quality!

      Ok. This wasn't exactly on-topic, but it's a valid alternative to OO for engineering stuff. The way I see it, GP is most likely well suited for those kinds of applications.

      The parent of this post refers to COM objects as the main code reuse strategy in Windows. Guess what serious Windows developers use to write COM objects? Yep, you guess right: STL and ATL (Active Template Library). Infact, these two libraries make it a breeze to implement COM objects in Windows (although, I prefer the UNIX environment. I wish the customers of the firm where I work could see it that way too..)

  16. Not functional programming... by Chris+Parrinello · · Score: 2, Informative

    Some of the replies here are a little confused. To paraphrase The Princess Bride, the word does not mean what you think it does.

    Functional programs evaluate expressions rather than execute commands to "get stuff done". Scheme (which is derived from Lisp) is one of the more well known functional programming languages.

    1. Re:Not functional programming... by Anonymous Coward · · Score: 0

      I don't want to disappoint you too much, but the area of functional programming has evolved during the last 10 years. Scheme and most LISP variants are not considered functional anymore, but multiparadigm. (CLOS is more an OO language than functional!)

      There are many key features missing in these languages which any FP-programmer would miss:
      * Strong typing
      * Type inference
      * Pattern matching
      * Currying

      Try telling an OO programmer not to use encapsulation and inheritance and he'll snarl at you.. ;-)

  17. Is it neccessary to be an end all be all? by syrupMatt · · Score: 2, Insightful

    I would tend to agree that OOP might be the wrong solution. It seems to me that OOP is designed to generalize code to solve broad problems. Engineering, and other applications which require minute changes depending on multiple factors might be better served by procedural code designed to specifically handle those problems.

    An interesting point that is raised is the fact that OOP, while an enormously helpful tool to many programmers and despite its advantages in many other theaters of software design, does not have to be an end all be all for programming as a whole. The tool that works should be the tool that is used.

    --
    "Moving through the masses like a fish through water." syrup
    1. Re:Is it neccessary to be an end all be all? by Anonymous Coward · · Score: 0

      It seems to me that OOP is designed to generalize code to solve broad problems

      In my years of field experience I've found that both flowers and chocolate are far more helpful in solving broad problems. As a matter of fact I have seen such problems become serious issues when the most appropriate object oriented paradigms are applied. For some reason they object to being objectified (might be a recursion issue, I'll have to re-examine my code).

  18. Scope by Liquid(TJ) · · Score: 1
    I don't think that OOP is intended to completly replace traditional language concepts, esp. on the function level. OO in my opinion really shines in dealing with relationships between objects or concepts, but the object classes themselves shouldn't always behave the same. I generally think of an object as a collection of data items and thier properties, but an "object" can also be a black box of functions that acts other objects, or any other set of properties that's approprate.

    If a program's sole purpose it to generate numbers based on other numbers, I don't see any reason to force OO methods onto the system. But if it's part of a larger system, then you may want a class that behaives like an object to the world, but acts like a function set internally.

  19. It's a way of thinking by JustAnotherReader · · Score: 1
    Once you learn OOP and truly "grok" the meaning of OOP you'll wonder why you ever coded any other way. It's difficult to answer the question "What's the businessw case for OOP" because we're not talking about how to build a more efficient web server, we're talking conceptually about design, implementation, and code re-use.

    So there's no easy answer. Unfortunatly, the real answer is to spend a year or two coding in C++ or Java and becoming familier with OOP concepts. Then you'll be able to answer your own question.

  20. Engineering DOES use OOP. by S� · · Score: 1

    Maybe its just us new eggs, but I've only been taught using OOP, through MATLAB code, which is almost the same as C/C++.

    S
    ------
    The City of Palo Alto, in its official description of parking lot standards,
    specifies the grade of wheelchair access ramps in terms of centimeters of rise per foot of run. A compromise, I imagine...

    --
    The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to
    1. Re:Engineering DOES use OOP. by Rev.Maynard · · Score: 1

      through MATLAB code, which is almost the same as C/C++.

      yeah, and being able to put gas in your car makes you a certified mechanic.

      --Rev.Maynard

    2. Re:Engineering DOES use OOP. by Anonymous Coward · · Score: 0

      Excuse me? MATLAB almost the same as C/C++?

      It might be pretty darn similar to C, but it's light years away from C++. I take it you have never actually touched C++ before.

    3. Re:Engineering DOES use OOP. by Anonymous Coward · · Score: 0

      Maybe you have never touched matlab lately. It has

      objects
      inhertience
      operator overloading

      If you look at the control systems toolbox you will find most of it is coded in an OOP style. For example differential equations to describe system behaviour are written as objects. These objects all have standard behaviours such as bode plots, step function response, generic input function response, root finding, stability analysis etc. However there are several representations of transfer functions, state based, laplace based, continuous time based, discreet time based. All these representations are derived from a common base class.

  21. How can we answer that... by Katravax · · Score: 2, Insightful

    ...when the jury is still out on whether OOP can even solve computer science problems?

    Other than a small handful of examples, I haven't seen where OO helps any way other than the creation of arbitrary data types and convenient grouping of data and functionality which can be done, although less cleanly, in a procedural language as well. The complexities of inheritance and God forbid, polymorphism, usually lead to more problems than they solve, in my opinion.

    I agree that OO programming can be more programmer-friendly in some cases, but in general find it more trouble than it's worth. Sometimes it looks to me like most of the things that can be re-used have already been turned into libraries, and the rest is all custom programming.

    I confess to learning programming using procedural techniques and using them for a dozen years before picking up OOP, and still finding those techniques easier to apply. But I'm not the only one that questions whether OO is a big red herring to productivity.

    1. Re:How can we answer that... by DrSkwid · · Score: 1

      try looking at javascript sometime

      --
      There are places where the networks are not touching,and there are places where they are-Boeing's Lori Gunter
    2. Re:How can we answer that... by -brazil- · · Score: 1

      Nobody's forcing you to use inheritance and polymorphism. I just like object-oriented languages because they make it easier to write clean, modular code. "Advanced" features like inheritance and polymorphism can be useful too, and only become a problem when used obsessively. Program in a way that best solves the problem, not in a way that best fits the programming paradigm.

      --

      The illegal we do immediately. The unconstitutional takes a little longer.
      --Henry Kissinger

    3. Re:How can we answer that... by geekoid · · Score: 2

      easier to write clean, modular code

      Myth, only good programming techniques make this possible. I can not count the number of time I've seen class implementation that use more then 10 levels of indirection.

      Plus OO religion is worse then vi or emacs religion. I almost got fired once because I wrote a function that bypassed a class. The fact that data transfer 10X faster(no exageration) was the only thing that saved my ass. But they still took out the function because it wasn't pure OO.

      --
      The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
    4. Re:How can we answer that... by -brazil- · · Score: 1
      Myth, only good programming techniques make this possible.


      No Myth. Such techniques are easier to apply when the language itself is geared towards it.

      --

      The illegal we do immediately. The unconstitutional takes a little longer.
      --Henry Kissinger

  22. Stick with Fortran by CmdrTuco · · Score: 0

    Despite what the 13 yr old computer science experts on Slashdot might tell you, Fortran (esp. Fortran 77) rocks. Stick with it. Remember the KISS principle.

  23. OOP solves Software Engineering problems by soboroff · · Score: 5, Insightful

    OOP doesn't solve engineering problems of the kind you describe. The programs solve the problems.

    OOP is a way to think about structuring the program, how you organize data and operations on the data, how you build reusable components which you can apply in some future problem you need to write a program to solve. In other words, OO helps solve software engineering problems. You'll still need to write the program which solves your particular problem.

    And before the flames commence, yes, OO isn't the only solution to this class of problems. It's just one.

    1. Re:OOP solves Software Engineering problems by James+Skarzinskas · · Score: 0

      No, I'm not here to flame; I completely agree with you. The object oriented paradigm is not a magical solution to world starvation and every other problem, it is merely a design model that the programs follow. It's more than possible to solve any of these problems with one long main() function in C (ugh, I've seen this before, many many times) but who is to judge which has solved the problem "better"? Kudos to your brave response to the hordes of OOP zealots ;).

  24. Here's a problem by Henry+V+.009 · · Score: 3, Interesting

    How do you write a million lines of maintainable code in six months with 5 programmers in Silicon Valley and 50 in Turkey? Hint: You don't do it in C.

    1. Re:Here's a problem by Anonymous Coward · · Score: 0

      you don't do it in C...
      if you can't code that is. ;)

    2. Re:Here's a problem by Anonymous Coward · · Score: 0

      You code it in Snobol with Ada extensions, of course.

    3. Re:Here's a problem by Amazing+Quantum+Man · · Score: 2



      Nah, you hand code it in machine code as a C array of bytes...

      unsigned char main[] = { /* ... */ };

      Assembler is for wimps!
      </HUMOR>

      Seriously, you use Ada95 or C++.

      --
      Fascism starts when the efficiency of the government becomes more important than the rights of the people.
    4. Re:Here's a problem by Anonymous Coward · · Score: 0

      Just get the Turks some green cards.

    5. Re:Here's a problem by Anonymous Coward · · Score: 0

      The answer is of course, you design and document robust interfaces between the components implemented by each party. What does this have to do with programming languages?

  25. Objects are not just modeling metaphors by big.ears · · Score: 2

    OO programming is not just about modeling the problem well, which in and of itself is enough to recommend the approach to an engineer. It also addresses the very difficult task of generating and maintaining a large software project in a form that a human can understand. For many small tasks, the extra overhead involved might not be worth the extra effort required if you are not already comfortable with the OO metaphor.

  26. OOPs (I did it again) by CaptainAlbert · · Score: 5, Insightful

    Take a look at BLITZ++, then tell me OOP is not useful for scientists and engineers. :-)

    I think the safest thing to say is that whatever your programming needs, whether you're doing pure matrix/BLAS number crunching or writing complex simulations/models, you should think twice before using FORTRAN. Well-written code in, say, C++ will be more maintainable and accessible to other people you work with (and who have to touch your code in future).

    The only thing which keeps people using FORTAN that I've seen is that the optimising compiler support is fantastic compared with the equivalent offerings in C/C++ compilers. But that's not much of an excuse for general day to day problem-solving.

    Just my 2p.

    --
    These sigs are more interesting tha
    1. Re:OOPs (I did it again) by thebron · · Score: 1

      But, if you're doing high performance computing and need to efficiently use every clock cycle of your IBM SP, you've no real choice except FORTRAN. The compilers are just plain better.

    2. Re:OOPs (I did it again) by p3d0 · · Score: 1

      I have never used BLITZ++, but I don't think it's object-oriented. It's more along the lines of the generic programming paradigm, making heavy use of templates, much like the STL.

      --
      Patrick Doyle
      I mod down every jackass who puts his moderation policy in his sig. Oh, wait a sec....
    3. Re:OOPs (I did it again) by Pierre · · Score: 1

      It's not as though he is using FORTRAN66

      There are modern implimentations of fortran that include stucts, dynamic allocation etc. (fortran95)

      Well written code in any language is easier to maintain and read. Fortran is pretty nice for numerical calculations.

      Having said that - there are some books out there targeted at this market.

      Introductory Java for Scientists and Engineers
      by Richard Davies

      Essential C++ for Engineers and Scientists
      Jeri R. Hanly

      and many more...

    4. Re:OOPs (I did it again) by joss · · Score: 2

      Check out blitz thoroughly before you jump to that conclusion. It is an extraordinary library that provides extreme efficiency while allowing you to write very high level mathematical looking code with performance right up with F90. If you need to squeeze the last 5% out of a very stable routine, stick with Fortran, if you're going to be changing things even somewhat frequently, blitz may well be a better bet.

      However, it is emphatically *not* based upon OOP principles. It is object-based generic programming and has virtually nothing to do with what most people think of as OOP programming (inheritance etc).

      --
      http://rareformnewmedia.com/
    5. Re:OOPs (I did it again) by Anonymous Coward · · Score: 0

      Yep, you're right. It uses mostly templates. Not that I have used it either.

      But it looks pretty darn cool. Using the possiblity of the C++ template mechanism to have mutually recursive templates that are evaluated at compile time it generates code that should rival FORTRAN performance.

      Fx. a function template "dot_product" can be expanded:

      dot_product(a,b)

      as:

      a[0]*b[0]+a[1]*b[1]+a[2]*b[2]

      at compile-time. Which is optimal..

      Thats pretty cool..

    6. Re:OOPs (I did it again) by Anonymous Coward · · Score: 0

      A good Fortran reference:
      Steven J. Chapman, "Fortran 90/95 for Scientists and Engineers", McGraw-Hill, 1998.

    7. Re:OOPs (I did it again) by blakestah · · Score: 2

      I think the safest thing to say is that whatever your programming needs, whether you're doing pure matrix/BLAS number crunching or writing complex simulations/models, you should think twice before using FORTRAN. Well-written code in, say, C++ will be more maintainable and accessible to other people you work with (and who have to touch your code in future).

      Provided you are not working with other engineers, that is. ForTran is really deeply embedded in lots of engineering locales, and there is an enormous codebase available.

      Let's just say you'll have a hard time finding a senior engineer who knows C++, and an equally hard time finding one who doesn't know ForTran. And, often, the senior engineers are among your better resources. C++ was not even stable when they trained, and ForTran has consistently maintained its edge in optimized compilers, which is all the senior engineers really care about.

      Leave C++ programming for writing GUI programs, where its benefits are tangible and obvious.

    8. Re:OOPs (I did it again) by Anonymous Coward · · Score: 0

      In Fortran 95:

      Dot_Product (A,B), or
      Sum (A*B)

    9. Re:OOPs (I did it again) by thebron · · Score: 1

      Indeed. Physicists are the same as engineers. All I care about is 1) code that is readable enough for most other physicists and 2) wall-clock time. FORTRAN wins in virtually every instance I've come across. That said, there is an emotional response among physicists using C or C++ for scientific computing. For jobs that aren't so computationally intensive, C++ can be great. Many physicists have started using C and C++ extensively, but it's not what I would call pervasive.

    10. Re:OOPs (I did it again) by Anonymous Coward · · Score: 0

      I'm afraid I don't know FORTRAN, I haven't done any scientific programming.

      My point was just that C++ templates, although ugly and convoluted, can actually be very useful.

      (They can also be used for calculating prime numbers at compile-time, spitting them out as error-messages, or anything else imaginable as the C++ template mechanism is Turing equvivalent...)

    11. Re:OOPs (I did it again) by Anonymous Coward · · Score: 0


      HOOPS is an object oriented graphics library that is specifically for engineering problems, on which about 100 commercial engineering applications are based. Yes, OO is useful.

      Though HOOPS is OO, it is C-based (with additional bindings for Fortran, Python and Java). What makes it OO is that it has its data in a hierarchy with inheritance, and that anything and everything has a unique identifier (a "key").

    12. Re:OOPs (I did it again) by p3d0 · · Score: 2

      It is cool, though I'm not convinced that writing an optimizer in C++ templates is the way to go. Certainly the idea of having libraries that can direct the process of code generation (rather than just providing a bunch of canned subroutines) is very cool, but C++ templates are too verbose and unweildy for mortal man.

      They do have some truly awesome features, though. Like the way you can provide specialized implementations of things. It has been a while, but I think if you have a template<int n>, you can also easily provide a template<2> with a specially optimized version for when n=2.

      --
      Patrick Doyle
      I mod down every jackass who puts his moderation policy in his sig. Oh, wait a sec....
    13. Re:OOPs (I did it again) by gizmo_mathboy · · Score: 1

      Well-written code in, say, C++ will be more maintainable and accessible to other people you work with (and who have to touch your code in future).


      I think the key is first well-written code. The language is more dependent upon whom is maintaining it than the language itself. FORTRAN is basically the standard for engineers/scientists so that it would be likely that any engineering apps would need to be written in it. However, if the maintainers are more familiar with C/C++ then it would be better to be in that language.

      I would also add that it's good to use idioms of the language used. As a Perl programmer I read all the time about how bad it is to use Perl idioms. Well, if I'm writing a Perl program I expect it to be maintained by programmers that know Perl. Just as I would expect C, Ada, Forth, Lisp, etc programs to be maintained by individuals proficient in the language of the program (just my little soap box speech).

    14. Re:OOPs (I did it again) by Alsee · · Score: 2
      [templates] can also be used for calculating prime numbers at compile-time, spitting them out as error-messages, or anything else imaginable as the C++ template mechanism is Turing equvivalent...

      In that case, there's no need to bother running the program. Just do everything at compile time...

      Compiler error message:
      • Error in Template SquarePipe(1.25)
        flow rate error 28.213


      Or better yet:
      Compile Advent.c
      • Error in Template maze of twisty little passages, all alike
        (A)bort (R)ecompile or (F)ail?


      -
      --
      - - You can't take something off the Internet! That's like trying to take pee out of a swimming pool.
    15. Re:OOPs (I did it again) by myelin42 · · Score: 1

      Somebody used error messages like that to implement an adventure game a while back. In C though, not C++ ;-)

      Here it is; it's one of the 1994 winners in the IOCCC (International Obfuscated C Code Competition).

      westley.c: "Adventure/Dungeon like game played via the C pre-processor"

      (The main index is here.)

    16. Re:OOPs (I did it again) by sjames · · Score: 2

      you should think twice before using FORTRAN.

      I doubt FORTRAN is going away any time soon.

      As you say, the compilers tend to be better. Part of that is network effect (since so many people demand FORTRAN, the emphasis is on FORTRAN...). Another part of it is that FORTRAN is a reletivly simple language that is easier to optimize. No need to worry about pointer aliasing for example.

      FORTRAN is very portable. My old F77 code will still compile and run just fine today. It will run w/o modification on Intel (32 or 64 bit), Alpha, SGI, Mac, Cray, etc. No need to worry about unexpected loss of precision, no mysterious variable overflows. No #ifdef around every declaration.

      As languages go, I prefer to write in C or Perl, but neither is really suitable where consistant numerical precision, speed, and wide portability is required.

  27. Good reference by Anonymous Coward · · Score: 2, Interesting

    Read the following book:

    Object-Oriented Implementation of Numerical Methods: An Introduction with Java & Smalltalk
    by Didier H. Besset

  28. Complex Number Support by WimBo · · Score: 2, Informative

    One of the items I've run into is that FORTRAN natively supports complex numbers. C doesn't support them, and I need to use the Standard template library in C++ to get the support.

    After I've used the STL, I then don't have the huge library of old code that I can draw from in FORTRAN.

    I much prefer writing in C / C++ to writing in FORTRAN, but there's lots of legacy FORTRAN code out there that'll get reused.

    1. Re:Complex Number Support by Anonymous Coward · · Score: 0

      > One of the items I've run into is that FORTRAN natively supports complex numbers. C doesn't support them

      Yes it does. Take a look at the C99 standard sometime.

      Most compilers, however, still implement C89.

  29. OOP == encapsulation ... by srealm · · Score: 4, Informative

    When you get down to it, every application, at some level, is a database of some kind. ie. it will end up storing many records of the same or similar type, usually in memory, and then go and do actions on those records. Weather each 'record' is a data packet, plugins for your application, records from some kind of file, whatever. In the end, it all acts a little like an in-memory database.

    The traditional way to handle this kind of thing is with a linked-list or array of structures. The main thing OOP gives you is not any 'special' solution to old procedural programs -- infact, a good blend of procedural and OOP is always the best solution, because every program is a combination of both. However, what OOP does give you is a nice way to encapsulate all data that is relevent, instead of into a structure, into a complete package.

    Instead of calling functions, and passing that object around, and then worrying about lost pointers, NULL's, etc. You take the more logical course of action, and perform the action directly ON the object. ie. instead of doing: do_something(mystruct, ....) you would just do mystruct.do_something(...). Which when you think about it, is a more logical solution. Almost every function you write, except for the straight out code-flow, and accessor functions, is some kind of operation on a data record in your 'in-memory database' (however it is represented). OOP's main purpose is to more link the functions doing stuff to the data, and the data itself. Nothing more, nothing less.

    Things like inheritance, templates, polymorphism, etc, are all just fluff to make coding easier, that has been added on top of the OO ideal. Granted, they make life ALOT easier (dont get me wrong, I use all of them all the time, and I'm an OO junkie), but the main purpose of OO is simply to create logical units, including code, and data in one block. So instead of having a bunch of structures, and then all functions to act on that structure in one .c file, and you know they're all related to that structure because they're in that particular .c file, you instead put all the functions in a class, and you know the funcitons work on that data, because the data, and function, are all part of the same logical unit.

    So I think you've mistaken the benefit of OO. As I said before, OO is not some kind of magical wand that will solve even the most complex of computing programming problems easily ... its just a cleaner way to group together data and functions that work on that data in a more 'binding' fashion, something that had to be done by the coder's memory and by hoping the previous coder's comments were good enough to make it clear what goes with what.

    1. Re:OOP == encapsulation ... by AdamBa · · Score: 3, Interesting
      OO as a way of thinking can be done in any language. What an OO *language* can offer is really two things that C can't, recovery of the "this" pointer and late binding.

      Recovery of the "this" pointer means that any function will magically have a pointer to the object it is working on available. Now normally this doesn't matter much because you can just have the function take itself as an argument (or a magically cast-to-void "handle" if you want to be opaque about it). But when you start to have inheritance, it can be tricky for the calling function to figure out what pointer to use. The OO language will do this for you.

      Late binding means you can link at runtime, not compile time. C++ offers this recovery but not late binding. Java and COM offer both.

      The rest is mostly OO hype. The big argument about how you can encapsulate everything inside a function is bogus because then you just convert it into a documentation issue, of knowing what exact random thing the designer of the function has decided it is appropriate to do. This is no different in OO or non-OO.

      The best, really the only successful realization of the OO dream of small interconnectable pieces so far is the Unix command line tools with pipes between them. Sure the data exchange format is trivial and limited, but the system actually works, and users can easily join together small reusable pieces of code to accomplish (most of) what they desire. The fact that this system is 30 years old and has not been improved upon just shows that <insert cliche here>.

      - adam

    2. Re:OOP == encapsulation ... by dakoda · · Score: 1

      I think this is the most relavant post i've read on this topic to date. you chop out the hype, and explain the benefits. its great, really.
      thanks for saving me a more lengthy post =)

    3. Re:OOP == encapsulation ... by Twylite · · Score: 3, Insightful

      One day, grasshopper, you too shall understand.

      You seem to have grasped one of the central concepts of OO, and a fraction of its usefulness. You have yet to come to terms with its real worth, or the Greater Picture.

      To a limited extent OO is the "reverse" of passing around a data structure. It is convenient, and to most people more logical. But most importantly it offers something that non-OO languages cannot provide: compile time type safety and encapsulation.

      The and is really important, because a non-OO language can offer either, but not both. This means than a function can never be entirely sure that its data is in a consistent or expected state, which an object can.

      Aside: to provide compile-time safety to must declare the entire data structure, and not do any type-casting. But to provide for encapsulation you must hide the data structure, so that a developer cannot at compile time reference any member of the structure by name (i.e. can't screw with the data without making assumptions about offsets that equate to hacking, and will not remain true if the data structure changes). Doing both is not possible without additional code in the function to calculate and check some sort of checksum of the data structure; and that does not provide for compile-time error checking.

      This may not seem important, but it greatly reduces bugs. You can code and debug a library of objects, happy in the knowledge that no other part of the program can screw with the objects' minds. Never underestimate the value of compile-time error checking; a well-designed program may most of its bugs in this fashion!

      And now we move on to more interesting stuff, like inheritence and polymorphism. (And no, "templates" (parametised classes, for the better educated) are not OO).

      OO is not about "making programming easier". It is about creating a more logical structure to allow the application of engineering principles to software design and implementation. This means improving robustness and maintainability.

      OO achieves this by reusing code in a more effecient fashion than procedural languages; as a direct consequence of inheritence.

      In any situation being modelled by software there tend to be a number of data-bearing entities (physical objects, processes, representations) with similar properties and having similar functions. OO allows the similar properties and functions to be matched, factered out and reused across all the entities.

      Non-OO languages can approximate some of this functionality by using embedded or chained data structures, but they lack a significant capability: to automatically adjust the function according to the entity.

      This difference is best illustrated by considering an office with a manager, secretary, clerk and some production workers. The manager walks into the office and says "all of you, do your job!". Simple, and OO.

      In the non-OO case the manager walks into the office and says "all of you, if you are a secretary answer the phone and do the filing, if you are a clerk total the books, if you are a production worker on the Toy line then build toys, and if you are a production worker on the Pen line then make pens."

      OO simplifies the procedural logic which controls a situation, because each object knows how to behave in an appropriate way in reaction to a more generic instruction.

      If you find no benefit in OO other than "it makes coding easier" then you are missing the point, and I would suggest getting a good book on the topic and reading it thoroughly.

      --
      i-name =twylite [http://public.xdi.org/=twylite], see idcommons.net
    4. Re:OOP == encapsulation ... by coolerthanmilk · · Score: 1

      I am a chemical engineer who uses OOP extensively for organization in engineering applications. I primarily work on a very large general process simulator which has many people working on it and continually has new unit operations and calculation methods added to it. It is a very large and wonderful beast. The wonderful part comes from the organization given to it. Much of the code I work with started out as C code with C++ wrappers added later, and most of the calculations are just procedural code. But the overall organization for combining units and calculations together is handled through objects in C++.

      I have written a lot of engineering codes in the past using both procedural and OO code (e.g. some molecular dynamic simulations) and in most cases you could go either way and get similar results. But when it comes to a really large process simulator, I would not want to give up a _good_ OO design for anything. It makes the code much easier to maintain and improve. At least that's been my experience as an engineer (and that's what was asked for, right?).

    5. Re:OOP == encapsulation ... by Ixohoxi · · Score: 1

      "Making programming easier" entails many things. Don't be too narrow in interpreting what "grasshopper" wrote. I see most of your points, such as less bugs, more code reuse, better maintainability, and simplification of procedural logic, as concepts which "making programming easier" would logically apply to.

      You do make good points and provide further examples of why OO languages can save alot of time and effort. Which is yet another result of "making programming easier". I wouldn't be so quick to judge how much or how little benefit grasshopper sees in OO languages, if I were you. Seems to me grasshopper knows more than you give him credit for.

      --
      What's a second? An hour? A day?
      It has much more to do with
      the Earth's rotation than with cesium.
    6. Re:OOP == encapsulation ... by Anonymous Coward · · Score: 0

      Well said! Somebody mod that up please!

    7. Re:OOP == encapsulation ... by Anonymous Coward · · Score: 0

      Ahem. Excuse me? Templates == OO?

      Templates are based on the generic programming paradigm. GP is more related to functional programming than OO.

      Inheritance and polymorphism is too big parts of OO. In fact, object polymorphism is a way to encapsulate implementation and inheritance is a way to delegate polymorphism. How can you throw that away? You are starting to sound like Microsoft when they claimed Visual Basic was OO. "Well.. ahmm.. at least it has encapsulation. And we decide that encapsulation is OO and OO is encapsulation. Therefore VB is an OO language".
      You are basically telling that the grandfather of OO, Smalltalk, is not OO. (I know some algol-related languages was around before Smalltalk that did not support polymorphism, but they didn't even coin the term OO, so how could it have been OO anyhow? That's just absurd.)

      Encapsulation is a term you find in pretty much all paradigms, they might just call it by another name. Take strict functional programming languages for instance. There you encapsulate functions as well as data (ADTs myfriend is not for you too look inside). Logic encapsulates logical rules. You can only ask a rule if a statement is true or not, you cannot and should not, know how the rule decides from your "calling context".

      OO is a way to describe states (fancy names for objects), how these state instances related to eachother (inheritance), in what context these states can be modified (polymorphism), and how they can be manipulated through commands.

    8. Re:OOP == encapsulation ... by ColinBlair · · Score: 1

      On my current project, I have to model the thermal characteristics of a house and its heating system. The existing mainframe system, which is in COBOL, was a procedural system which took anything from 5 to 30 minutes to complete depending on how many components (i.e. doors and windows) the house or apartment building has.

      Using set based programming, in the form of SQL and SQL Server 2000, I rewrote the calculations using stored procedures, user defined functions, and correct normalized table design. What used to take forever on the "big iron" now takes less than a second running on a quad processor Compaq server.

      The original calculations took over 100 steps, not including looping for each house component. My calculations take about 7 steps, again, not including looping.

      The reason this was possible was that I looked at the original calculations, broke it down to its component objects, and then normalized it. You don't have to actually write the program in OOP to get benefits from looking at your task from the OOP point of view. In my case, I prefer to write as much code as possible in SQL. It does a much better job of chopping a job up and running it on multiple processors then I can. Plus, the resulting code is much easier to read.

    9. Re:OOP == encapsulation ... by igrek · · Score: 3, Informative

      Interesting, but I disagree with some of your points. One by one:

      1) OOP != encapsulation, by definition.
      Hint: you missed inheritance and polymorphism :)

      2) Unfortuantely, not every program is combination of OO and procedural code. Sometimes OOP-ness is enforced.
      Hint: Java.

      3) Unfortunately, OOP is not helping to package code and data togethter. On the contrary, because of the inheritance it's often more difficult to trace what are the properties and methods of an object.
      Hint: read "Patterns of Software" by Richard Richard P. Gabriel. He has an exellent chapter on compression and reuse. By compression he means dependency on the context. For OOP it's non-localized dependency, which is usually bad.

      4) Your argument about NULL pointer checking is irrelevant. Before calling object methods, you have to make sure is's initialized. No difference with passing the pointer as an argument.

      5) There's more than just applying a function to a structure. Here it is: applying a function to two structure of diferent type. Where do you put this function? In OOP, it's a source of many arbitrary decisions on early stage. Projects evolve, but it's difficult to change such a decision once it's done.
      Example: LinkPictureToAlbum( Picture, Album ). Is it Album object method or Picture object method?

      In practice, another problem is need for multiple dispatch, but that's rather implementation problem. C++ and Java are popular OOP languages and they provide single dipatch only. It's not an inherent OOP problem - see CLOS for an example of successful multiple dispatch in OOP.

      6) Templates is non-OO feature of C++!

      I agree with your conclusion, though. The OOP is not a panacea, but it's definitely useful.

    10. Re:OOP == encapsulation ... by UnknownSoldier · · Score: 2

      > 5) There's more than just applying a function to a structure.
      > Here it is: applying a function to two structure of diferent type.
      > Where do you put this function?
      > In OOP, it's a source of many arbitrary decisions on early stage. Projects evolve, but it's difficult to change such a decision once it's done.
      > Example: LinkPictureToAlbum( Picture, Album )
      > Is it Album object method or Picture object method?

      Neither. Use composition, and make a new object.

    11. Re:OOP == encapsulation ... by inha · · Score: 1

      I agree with you mostly, but...

      > 1) OOP != encapsulation, by definition.
      > Hint: you missed inheritance and
      > polymorphism :)

      Sorry to say, but you are wrong here. First, the three most important aspects of an object are its state, behaviour and identity. To cut long proofing short, these three result to encapsulation, read for example Grady Booch's "Object-oriented analysis and design" for proof.

      Ofcourse, as "strong typing is for weak minds only", is encapsulation for weak minds only when speaking of encapsulation as data "hiding". So private, protected and public attributes, both data and method attributes that is, are just to ease coding. If the attributes are split to different interfaces of an object, it results to capabilities. That's another story, but an interesting one...

      If speaking of encapsulation as collection of the data and operations modifying the data, i.e. collection of behaviour and state under an identity, then it is essential to OO, imho.

      Polymorfism has nothing to do with OO. Well, OO can use polymorfism, and it really is a nice tool in OO, but no, it is not essential for OO. Polymorfism can also be found on other than object languages, for example in LISP.

      Inheritance is purely syntactic sugar.

      When speaking of inheritance, we must define are we speaking of type inheritance or behaviour inheritance. Former is the nice thing, but not essential to OO (typeless languages, classless object languages, remember type!=class). Latter is way too easy to implement in other ways (and seems to be the only thing that people preferring C to C++ as an OO programme implementation language can see).

      So, like the original author said:
      "Things like inheritance, templates, polymorphism, etc, are all just fluff to make coding easier, that has been added on top of the OO ideal."

      He couldn't have been more right.

    12. Re:OOP == encapsulation ... by igrek · · Score: 2

      Of course, you may use your own different definition of OOP. However, traditionally the inheritance and polymorphism are considered to be the essential parts of OOP.

      What you're referring to is an "object-based" programming language, something like Modula-2. It supports object encapsulation, but it's not an OOP language yet.

      Please read the comp.object.FAQ:

      1.15) What Is The Difference Between Object-Based And Object-Oriented?

      Object-Based Programming usually refers to objects without inheritance
      [Cardelli 85] and hence without polymorphism, as in '83 Ada and Modula-2.
      These languages support abstract data types (Adts) and not classes, which
      provide inheritance and polymorphism. Ada95 and Modula-3; however, support
      both inheritance and polymorphism and are object-oriented. [Cardelli 85, p481]
      state "that a language is object-oriented if and only if it satisfies the
      following requirements:

      - It supports objects that are data abstractions with an interface of named
      operations and a hidden local state.
      - Objects have an associated type.
      - Types may inherit attributes from supertypes.

  30. One example by bapya · · Score: 2, Insightful

    One example that comes to my mind immeiately is MMTK ( link) (Molecular modeling tool kit) developed in python by Konrad Hinsen.

  31. Maybe by JMZero · · Score: 1

    OOP isn't going to help you solve your math problems, for the most part. If you're dealing with a lot of objects, it could clarify things. For example, if you had physical objects with a list of properties like dimensions, temperatures, etc... you have a few options.

    You could have parallel arrays, like

    double nObjectX[100] (array to be clear)
    double nObjectSpecificHeat[100]
    ...

    This would certainly work, and you could write functions to work with data as it is here.

    But if you thought of all of these as properties of one object, (ie Object.X, Object.SpecificHeat), you could:

    - pass them to your functions more easily
    - make your code more clear
    - impress your programming friends

    It could be that none of the above will help you at all. There is, by definition of how computers work, nothing that you can do with OOP that you can't do without it. And lots of time it's more effort for the same product.

    .

    --
    Let's not stir that bag of worms...
    1. Re:Maybe by Anonymous Coward · · Score: 0

      If all you need to do is store related properties together, then an array of structs would do the trick.

  32. We may be human by jfonseca · · Score: 0

    Prakman, nice sig, I wake up listening that song everyday!

    --
    Broken Hearts are for Assholes. - Frank Zappa
  33. Depends greatly on the problem by gila_monster · · Score: 1

    There are some areas where OOP is considered undesirable. The avionics industry, for example, makes very limited use of OOP because certain aspects (garbage collection, dynamic allocation of resources, & others) raise safety-of-flight issues. Certification authorities prefer things more controlled, as plane crashes are generally considered a bummer.

    This is also why the aviation industry doesn't adopt new technologies quickly. It prefers to wait until they have a proven service history. The 486 is stilled widely used in the industry, for example.

    gm

    --
    Ad luna, Alicia! Ad luna!
    1. Re:Depends greatly on the problem by javahacker · · Score: 1

      It's funny, but I thought that all software produced for the US government, including (perhaps especially) the control systems for military aircraft, was required to be written in Ada. Ada is an object oriented language.

      Garbage collection, dynamic allocation of resources, and most other issues people bring up about object oriented languages are either language implementation details (C++ does not garbage collect, Java does), or developer choices (allocate all objects at startup, not dynamically while the program performs it's main function).

      Object oriented programming is a set of practices that most good programmers have been using for many years. An object oriented language is a tool that makes using these practices easier, not a cure all for the programming ills of the world.

    2. Re:Depends greatly on the problem by gila_monster · · Score: 1

      Ada95 is object-oriented. Ada83 is not, but it is still commonly used. It is also possible to use Ada95 without taking advantage of the OO features (which is what we do where I work).

      Ada is no longer required by the government. They dropped the requirement over a year ago. However, Ada was designed for aviation usage, so it's still by far the most commonly used language, as it's convenient to the task. We're doing things in C now as well, though.

      Your point about these features being language- or developer-dependent is correct, but certification authorities don't give a damn what we think. They're still pretty leery of OO usage, and anything we do use, we have to show unequivocably that we've avoided the problems they can cause. Frankly, they don't trust anyone (nor should they). This is neither easy nor cheap, so OO has been slow to enter aviation.

      gm

      --
      Ad luna, Alicia! Ad luna!
    3. Re:Depends greatly on the problem by javahacker · · Score: 1

      I just wanted to make that point. You can dynamically allocate memory in C as easily as you can in most object oriented languages.

      As someone who spent a great deal of time (about 13 years) designing and writing code for imbedded products, all of the issues relating to reliability are familiar ones. One of those projects was the monitoring system of a DME for the FAA, definitely a place where reliability is paramount (aircraft do need to know where they are). The key to reliability is always the developer, since anyone can write unreliable code in the language of their choice. It sounds like the aviation industry is still driven by people who have more hot button issues than real understanding of the technical issues, not that I really expected a change.

      You probably write code in C that works with objects (structs), and have code modules devoted to each type of struct in your system. This is object oriented programming, just without any help from the tool.

      In a similar way, you can write a program in Java, using entirely static methods, and create a completely procedural program that uses NO objects. In this case you would be fighting the tool.

      Good developers frequently use very similar techniques, whatever language they are working in.

  34. An example by Anonymous Coward · · Score: 1, Interesting

    This is "just" numerical code, but maybe will give you some ideas:

    http://www.oonumerics.org/blitz/ (Blitz++)

  35. Yes and no by renehollan · · Score: 3, Informative
    Functional programming is better suited to solving engineering problems.

    Not really, but there is an element of truth to that mantra: most engineers traditionally learned to program in Fortran, and there were some damn good Fortran compilers/libraries to handle the types of matrix manipulations commonly encountered.

    You don't need the overhead of OO design for your engineering programs. I would stick to C unless you are trying to do some kind of fancy GUI.

    While abstract classes will incur the hit of an extra level of indirection in a function call, and exception handling in C++ can be expensive (as can multiple inheritance), these features only cost you if you use them.

    Now, to answer the question at hand, I have helped to design and develop commercial speech recognition products using C++. Of course, there was plenty of C and hand-tuned assembler there as well.

    A more concrete example would be the VFS in Linux, as well as the classes of network, block, and character device drivers -- while generally coded in C, they represent the notion of abstract base classes unifying a common interface to many different implementations -- there's no reason C++ could not have been used there.

    --
    You could've hired me.
    1. Re:Yes and no by Zordak · · Score: 1
      While abstract classes will incur the hit of an extra level of indirection in a function call, and exception handling in C++ can be expensive (as can multiple inheritance), these features only cost you if you use them.

      Actually, I was thinking more in terms of design overhead. I've done a fair amount of both kinds of programming, and I find OO very useful for many kinds of tasks, but if I'm writing an engineering application, I find the overhead of creating a class and all of its members tedious when all I need is a function that will accept inputs and return the output. To use your speech recognition example, if I had to, for example, perform a mathematical transform on an input waveform that represents a word, I would much prefer to implement that transform as a function than write a class that has to be instantiated, have data members assigned, have a member function called, and then read out a member variable to get the result (which would be the proper way to do it if we stick to true OO theory). I'm no anti-OO crusader by any means. Objects definately have their place. I just think that they are more appropriate to the realm of Computer Science problems than Engineering problems.

      --

      Today's Sesame Street was brought to you by the number e.
    2. Re:Yes and no by renehollan · · Score: 3, Interesting
      Well, you naturally think that way, so it's not surprising that a functional model seams easier.

      The thing about an OO design is that object instances can have state (internal per-instance variables) that is implicitly available to member functions (this in C++). That's a big plus.

      In your case, if you want a purely functional object, you can have that too! In C++ you'd declare and define a member function operator()(). This would pay off big if you had an object that represented a function with several parameters, some of which you'd want to hold fixed, while you varied the others. You'd use "set" member functions to set the fixed parameters, and the () operator to call the function with the remaining variable ones. This is a slam-dunk if you always want to fix the same parameters.

      I can see you thinking, "Yeah, but I can use globals for that, or hard-coded constants." True enough, but then the nature of the function object is polluted by how you want to use it at this particular point in time. There is a price to be paid, of course, to reference the constants within the function proper by dereferencing this, but that's tantamount to deciding "Do I want to do this at compile time or run time?"

      Now, C++ templates let you do some neat compile-time hackery to pick the pre-optimized version of a function object class with known parameters as compile time constants or global fixed parameters (static members so as to not pollute the global namespace). And, unfortunately, I don't have time to go into a discussion about type traits and functors, but you can represent functions as objects in C++, and it is espescially elegant syntactically, when those functions have fixed-paramters states.

      As for the speech recognition work, the OO methodology came in handy when it came to phonemic graphs and quotient graphs of them divided by particular equivalence relations used for forward estimation functions driving an A* search (the forward estimate obtained by a full Viterbi search over the much smaller quotient graph) -- I could just tell the quotient graph, in it's current state, to digest the next acoustic input frame. Later, I'd ask it for a forward score from a given node at a particular point in time (which it would cache for me).

      --
      You could've hired me.
    3. Re:Yes and no by Mr.+Shiny+And+New · · Score: 1

      Another point about OO programming is that you can make an algorithm into an object. This makes it simple to drop in new algorithms, even at runtime. The algorithm itself might not be very OO, but how it fits into the system is OO. The goal of OO isn't to do stuff that is impossible, but rather to make it easier to organize what you're doing. Better organization means better code (and better maintenance).

      Of course, it's not a given that OO implies good code, nor that procedural/functional/assembly implies bad code.

    4. Re:Yes and no by asincero · · Score: 1

      > To use your speech recognition example, if I
      > had to, for example, perform a mathematical
      > transform on an input waveform that represents
      > a word

      I think, for this example, the transform function would be a method of the word object since its performing some sort of action on it.

      - Arcadio

    5. Re:Yes and no by frank_adrian314159 · · Score: 2
      Functional programming is better suited to solving engineering problems.

      Not really, but there is an element of truth to that mantra

      One word: SISAL.

      --
      That is all.
  36. Assembler then? by Anonymous Coward · · Score: 0

    ...............or Forth maybe?

  37. sure it can but by kaisyain · · Score: 5, Informative

    First off you're examples Monte Carlo simulations and differential equations aren't "engineering problems". They are math problems that are a component of an engineering problem. Engineers does things. It builds a bridge, drives a car, prints a document. The examples you give are parts of that solution. Every GUI needs to do things like interpolate colors and position, which are the same class of problems -- if orders of magnitude simpler -- as differential equations and Monte Carlo simulations. So it seems to me that you need to figure out what your real problem is and figure out what programming paradigms might help you out with that.

    As others have pointed out OOP doesn't let you solve things that are otherwise unsolvable. It is a way of solving problems that may be better in some situations and worse in others. The examples you give of solving equations are all better suited to a functional language than a procedural one like Fortran, so rather than asking "why use OOP" you might want to first ask yourself "why am I using Fortran?" Obviously there are a number of factors that go into how we pick our solutions. Maybe OOP per se isn't a good fit for your problem but you need it to be multiplatform and have a huge amount of available code and standard libraries so you end up going with Java. Or whatever.

    The kinds of problems you're talking about don't have a great mapping onto the traditional ways of describing OOP. However, OOP is really just a somewhat formalized kind of way of dealing with abstraction and data encapsulation. You can make a difference equation a class. Maybe it'll only have one method that immediately finds all the finite solutions. But once it is a particular datatype you can also do things like compare whether two user-entered difference equations are identical and just returned the cached solution. You can curry them. You can return partial solutions and then come back later and ask the object for more solutions.

    Don't you already have discrete data types for these things? And don't you already have functions that operate on those discrete datatypes? Then you're already doing OOP. Sure you're not using inheritance and multimethods and things like that. But not every OO program does.

    1. Re:sure it can but by rfsayre · · Score: 2

      OOP is really just a somewhat formalized kind of way of dealing with abstraction and data encapsulation.

      OOP is one way of doing this. The question the poster needs to ask himself is whether he needs to maintain state in his programs. Many engineering problems do not require this. If he doesn't need to maintain state, then OOP is needless overhead.

    2. Re:sure it can but by Anonymous Coward · · Score: 0
      Don't you already have discrete data types for these things? And don't you already have functions that operate on those discrete datatypes? Then you're already doing OOP.

      Nope, that's called modular programming and it's a lot older idea than OOP.

  38. Fortran already has most of the objects by tshoppa · · Score: 1

    Fortran already has most of the really basic objects used to solve engineering/numerical analysis problems: Integers, reals, arrays, matrices, subroutines, functions, etc.

    Object-oriented languages are so popular at the moment because it's a way of adapting a language to a new problem domain (keep in mind that C was written to write an OS kernel, and it's only through bad luck that folks are using an extended version to do everything under the sun today).

    But just as C++ and Java are (slowly) displacing COBOL for business applications, I think we'll see object-oriented code displace Fortran and C for number-crunching. (Remember, COBOL was written specifically for Business applications!)

    I honestly don't know of a good book on numeric computation that is truly object-oriented. The current edition of Numerical Recipes in C++ doesn't really take advantage of everything you can get from an OO approach. Maybe the new edition of Numerical Recipes in C++ will do a good job at this. Still, the current version shouldn't be ignored, there are some good ideas about how objects can really help in large computational challenges.

  39. "Engineering Problems" is awfully vague by avdi · · Score: 1

    To the question "Can OO programming solve engineering problems", I would answer an emphatic yes. However, the engineering that I do at my place of work has to do with coordinating RADAR tracks in an air traffic control system, among other things. OO principles are applied to this domain with excellent, elegent results. The problems you are talking about (though I don't pretend to understand them) sound like very specific mathematical ones which are probably best solved in a procedural fashion, perhaps packaged up neatly into a class. However, just because it's the only engineering problem you are faced with, don't make the mistake that OO design principles cannot be applied to any engineering problem domain.

    --

    --
    CPAN rules. - Guido van Rossum
  40. Computational complexity vs Conceptual Complexity by Mr.+Fred+Smoothie · · Score: 5, Interesting

    OO languages exist at the "high" end of the language-level spectrum. They're geared toward managing code complexity in the face of a problem domain which is conceptually complicated, primarily by encapsulating bits of the problem domain into digestible and self-contained sub-problems. The overhead of all of the OO constructs is worth it if the reduction of your problem domain into smaller chunks is neccessary to solve the problem (or advantageous in terms of directing the efforts of multiple team members in areas where some decoupling is possible).

    However, if you problem is "low-level" or conceptually simple (though not neccessarily computationally simple) -- a recipe like "apply transformation x to dataset y, then transform again w/ algorithm z", the OO features simply serve as a distraction from thinking about your actual problem domain and it's solution.

    So yes, IMHO, there are problems for which OO techniques are not ideally suited, and most importantly, if the techniques get in *your* way they are not the right tool for *you*. Rememer, languages and tools don't solve problems. People do. If a tool makes you task easier, use it. Otherwise, save yourself the time.

    --

  41. a turbine engine modeling application by Nehemiah+S. · · Score: 1

    When I worked at AEDC I spent some time involved in NASA Lewis (now Glenn)'s numerical propulsion system simulation project. The idea of this project was to apply OO principles to turbine engine modeling.

    Each component of a modern engine was viewed as an object (compressor, turbine, burner, etc). The solver could use helper aplications of any complexity to model components, then tie them together (very useful for integrating proprietary codes with a common architecture).

    I could talk a lot more about it but it has been years and it would be better for you just to follow the link...

    neh

    --
    ... and there is no doubt, that one day he will be
    where the eye of his telescope has already been
  42. Different Problems, Different Languages .... by Anonymous Coward · · Score: 0

    It could be that the OO methodology simply isn't applicable to the problem area you're interested in. OO is fine for describing/developing some parts of a system, but not for others parts. Just as functional or logic based formalisms are good at some parts and bad at others ...

  43. You sorta get it by KurdtX · · Score: 1

    Each of the examples you give is essentially a function (ok I'm not 100% familiar with everything you mention, but from what I know...). In OO design, each of these would be a discrete "building block", think of each as a specialized calculator. Now if you're just trying to solve a single equation, (in my opinion) yes it is too small for full blown OO.

    However, if you have a function that say, needs to do many integration, derivation, or whatever steps, you can write an object instead of just doing a function. The advantage of writing a integration object instead of just a function is that you are forced to pass in all of your data, and thus the object is reusable (it in effect becomes a library). You could include in the same object many different types of integration, single, double, Legrande, although I would separate out derivatives.

    I guess another (abstract) way to relate it is to buying a new computer. You can either go to Dell (or whomwever) and buy a new package every time and pay a premium, or you can just upgrade one module at a time - your hard drive isn't big enough, get a better one, not enough RAM, get some more, etc.

    And if anyone wants to flame me about how this will lead to a legacy system let me point out that: a) Linux runs on a 486; b) it's just an abstraction!

    --

    Kurdt
    I'm not anti-social. Just pro-technology.
  44. Math objects are objects, too by mblase · · Score: 5, Interesting

    For simplicity's sake, let's think about quadratic equations for a second. You can solve them easily, but if you want to use them in a larger program, you could create a QuadEq object in OOP with the following properties:

    • coef_A, coef_B, and coef_C as the three coefficients
    • root_1 and root_2 as the two roots of the equation
    • deriv_1 and deriv_2 as the first and second derivatives of the equation

    An OO programmer would then add methods to set, retrieve, and calculate those properties based on what's been entered. And the QuadEq object would be entirely portable and easily amplified for future equations.

    I don't think choosing OOP is a matter of being the only tool to solve certain problems. However, it is often the most efficient way to solve large, rapidly-changing problems. But like you said, other problems (like many of the ones I encounter in web development) will be small and uncomplicated enough that the overhead of OOP isn't worth the trouble.

    1. Re:Math objects are objects, too by Twylite · · Score: 3, Insightful

      I'm sorry, but this is a classic example of bad OO, except in specific circumstances. A simple calculation is expanded into 6 method calls (3 x setCoefficient, 1 x calculate, 2 x getRoot), and even if compound methods are provided the side effects grossly impede calculation performance.

      An object can represent anything that has a state which changes over time, in response to input or other events in the software. If what you are modelling does not hold with the above definition, it shouldn't be an object.

      Discrete calculations are especially suited to NOT being objects. They have no requirement for persistent information outside the function, and thus no need to be in an object. The primary reason for putting them in an object is grouping, which is a Really Bad Idea for common library routines because you can't export C++ objects from libraries (unless you assume that the library user has the same compiler and linker as you do...).

      Fortunately C++ (unlike some other OO languages) has a solution to this problem: namespaces. Any function which is self-contained (has no need for non-local data) can be placed in a namespace, logically grouped with similar functions, and if the header is carefully constructed can still be used in libraries using C name "mangling".

      The only situation in which I can imagine the object you propose being useful is as a data object behind a GUI which allows you to enter quadratics and fills in the other fields. And even in this case I contend that the correct model would be a QuadraticModel object (like the one you describe) which calls calculateQuadraticRoots() in a namespace or other library.

      --
      i-name =twylite [http://public.xdi.org/=twylite], see idcommons.net
    2. Re:Math objects are objects, too by Lux · · Score: 1

      I agree with the first responder on this one, you're kind of forcing this problem into a OO solution. A better example might be a polynomial object that contains methods to calculate roots and derivatives.

      Someone gets that done, so that problem's been solved, and later you realize that you need to multiply and divide polynomials too. That's the kind of situation where OO is really nice, because you can just extend your (or someone elses) previous polynomial class.

      This still isn't a large enough problem to fully show how OO is nice, but I think the revised example illustrates better the utility of OO for dealing with a situation where your needs from a piece of code are changing frequently.

    3. Re:Math objects are objects, too by Peaker · · Score: 2

      Since when does OO have overhead?
      The declarative nature of "OO languages" like C++ and Java have overhead to define classes, methods their argument types, etc.
      When using Python, I don't feel it takes any more time to write the proper OO solution than it is to write the procedural hack.

      For example:

      def operate_on_matrix(matrix):
      matrix *= 3
      matrix += 5
      ...

      def draw_matrix(matrix):
      c = convert_matrix(matrix)
      c.normalize()
      draw_screen(my_screen, c)
      ...

      matrix = [[0]*100]*100
      operate_on_matrix(matrix)
      draw_matrix(matrix)

      Isn't really much shorter than:

      class Matrix:
      def __init__(self):
      self.matrix = [[0]*100]*100
      ...
      def operate(self):
      self.matrix *= 3
      self.matrix += 5
      ...
      def draw(self):
      my_screen.draw(self.matrix.converted().normalized( ))
      ...

      matrix = Matrix()
      matrix.operate()
      matrix.draw()

      And I personally find the latter much more readable.
      Procedural code is really just OO code gone wrong :)

    4. Re:Math objects are objects, too by azgard · · Score: 1

      I like Python too, but it is really unsuitable to do numerics. Many people do, but their use c extensions for the real computation, and python as a frontend. Your example would be 20x or more slower than the equivalent in c.

  45. OOP numerics page by guybarr · · Score: 0, Redundant

    look here:

    http://www.oonumerics.org
    (not just blitz there)

    --
    Working for necessity's mother.
  46. You don't understand what OO is by Papa+Legba · · Score: 3, Insightful

    You seem to think that OO is some end all be all of the programing language. It is more on how you structure the code. You can do a hello world program using OO is you wanted. Instead of acting on the logic of the problem you design from the idea that the data is what must be manipulated and therefore is an object to be handeled. All the problems you are listed are easily solved by defining the class that is associated with the data inputs and then perform actions on those objects. It is quite a bit different in thinking over how fortran is programmed.Having programmed in both OO is a much more powerful solution.

    Here is an excerpt from www.whatis.com that may explain this better than I can.

    " The first step in OOP is to identify all the objects you want to manipulate and how they relate to each other, an exercise often known as data modeling. Once you've identified an object, you generalize it as a class of objects (think of Plato's concept of the "ideal" chair that stands for all chairs) and define the kind of data it contains and any logic sequences that can manipulate it. Each distinct logic sequence is known as a method. A real instance of a class is called (no surprise here) an "object" or, in some environments, an "instance of a class." The object or class instance is what you run in the computer. Its methods provide computer instructions and the class object characteristics provide relevant data. You communicate with objects - and they communicate with each other - with well-defined interfaces called messages.

    The concepts and rules used in object-oriented programming provide these important benefits:

    The concept of a data class makes it possible to define subclasses of data objects that share some or all of the main class characteristics. Called inheritance, this property of OOP forces a more thorough data analysis, reduces development time, and ensures more accurate coding.
    Since a class defines only the data it needs to be concerned with, when an instance of that class (an object) is run, the code will not be able to accidentally access other program data. This characteristic of data hiding provides greater system security and avoids unintended data corruption.
    The definition of a class is reuseable not only by the program for which it is initially created but also by other object-oriented programs (and, for this reason, can be more easily distributed for use in networks).
    The concept of data classes allows a programmer to create any new data type that is not already defined in the language itself.

    One of the first object-oriented computer languages was called Smalltalk. C++ and Java are the most popular object-oriented languages today. The Java programming language is designed especially for use in distributed applications on corporate networks and the Internet."

    --
    Papa Legba come and open the gate
  47. The act of learning by pdqlamb · · Score: 5, Insightful

    I've seen some truly awful procedural code (lots of it was Fortran, BTW). I've seen some truly gorgeous procedural code (lots of it was Fortran, BTW). I've seen some some wonderful, and even more pretty awful, OO code (mostly C++, but with some Java).

    Go ahead and study object oriented programming. You'll learn some new ways to do things. But I think it's the act of studying, and the act of learning, that will be the most valuable thing you get out of the process. Too many people never study how to program, how to document, how to design code. They learn one or more languages. Their code shows it.

    A few people have a natural tendency to write elegant code. A few more, but still not very many, study and try to learn how to write elegant code.

    But don't expect the object-orientedness to make much difference. A dozen or more years ago, a young whippersnapper got hooked on objected-oriented design. He derided all the existing Fortran we had as spaghetti code. To some of us, though, his "object-oriented" code was lasagna code. No overriding structure, code spread out all over the place, a single function scattered over three files. And this was still Fortran; I've seen C++ coders who took six files for a similar, simple function.

    I've also surprised myself! when some of my OO C++ code needed four lines to add new functionality. But it was carefully designed, after years of programmer improvement and study.

    Go ahead and try it; it can only help.

    1. Re:The act of learning by Allocutor · · Score: 1
      a young whippersnapper got hooked on objected-oriented design. He derided all the existing Fortran we had as spaghetti code. To some of us, though, his "object-oriented" code was lasagna code. No overriding structure, code spread out all over the place, a single function scattered over three files. And this was still Fortran; I've seen C++ coders who took six files for a similar, simple function.
      Amen. This is the smartest observation of all. May I quote this?
    2. Re:The act of learning by pdqlamb · · Score: 2

      a young whippersnapper got hooked on objected-oriented design. He derided all the existing Fortran we had as spaghetti code. To some of us, though, his "object-oriented" code was lasagna code. No overriding structure, code spread out all over the place, a single function scattered over three files. And this was still Fortran; I've seen C++ coders who took six files for a similar, simple function.

      Amen. This is the smartest observation of all. May I quote this?


      Be my guest.

    3. Re:The act of learning by bkocik · · Score: 1
      Too many people never study how to program, how to document, how to design code. They learn one or more languages. Their code shows it.
      As someone who is currently learning to code, may I ask how one would avoid the situation you've described above? I don't want to become one who has only learned languages, but not how to design software (documenting is actually a strength of mine, though). Do you have any specific suggestions toward the goal, or resources I should be looking into? A formal CS education would probably be a good suggestion, but that's not (currently) an option for me (maybe a bit later).

  48. Object-oriented programming was invented for this by cananian · · Score: 5, Informative
    SIMULA --- the first object-oriented language --- was specifically *designed* for engineering tasks: but the tasks in question were process *simulation*. And, indeed, any iterative difference-based approach to physics modeling fits right into modern object-oriented languages. You create an instance of the object Car, say, for each physical car in the system, then call Car.update(time) to have the car compute its physics to move itself to the proper location for the given time. This way the physics of each part is sensibly contained within the instance of the object representing the part. This also works is you have instances of Boiler, WaterPipe, or OxygenAtom, WaterMolecule, or UraniumAtom and Neutron.

    I think the "answer" to your question is that, yes, your examples are too simple. When you're doing some simulation where the "finite difference solutions to non-linear equations" all interact with each other, and with computed fluid dynamics and heat transfer, etc, you'll immediately see the benefit of separating all these concerns into encapsulating object types.

    --
    [ /. is too noisy already -- who needs a .sig? ]
  49. OO is better for big stuff by jpmorgan · · Score: 2, Informative
    'Your problems are two small and specialized to realize any significant advantages of OOP.'

    The kinds of problems you're trying to solve aren't problems object oriented designs are good at. While OO is a natural way of dealing with some concepts (for example, GUI concepts), its real power doesn't come from this kind of thing. It tends to be best for designing very large systems that are complex and may change significantly over their life-time. The kinds of problems you mention (finite difference solutions to differential equations, finite-volume computational fluid dynamics, iterative solutions to non-linear equations, Monte-Carlo simulation of radiative heat transfer, etc.) aren't really the kind of software engineering projects that require carefull design. They may be hard problems, but they're also understood and well studied problems.

    Take a step away from the scientific problems and consider something like an inventory management system for a pharmacy chain that needs to be solid and accurate, while at the same time collecting data and producing pretty reports for whatever statistic the company directors think is important on that particular day of the week. A slightly different kettle of fish, no?

    Another often stated advantage of object oriented programming is component reuse. It seems that most developers don't really try, but for a little bit more effort and thought, object oriented techniques make writing highly reusable software components easy.

    For my own personal projects, I have a set of classes that do all sorts of things for me, from a log file manager to a small LALR(1) parser which I have a generic config file parser built using (all in C++, no need for external programs). It's a pain in the ass to write the code originally, but it was all well worth the effort. :)

  50. different equations for different data. by Anonymous Coward · · Score: 0

    Using polymorphism if you have different types of data to solve certain problems you can use your objects to create multiple inputs with the same name, just different data type inputs.

  51. quants do it by the numbers by Rocky+Mudbutt · · Score: 1

    An excellent example of complex mathematical algorithms implemented with an object model is the quantlib project. Financial modelling is a kind of engineering, although usually more rewarding monetarily than electrical engineering.

    From their front page:
    The QuantLib project is aimed at providing a comprehensive software framework for quantitative finance. QuantLib is a free/open source library for modeling, trading, and risk management in real-life.

    QuantLib is written in C++ with a clean object model, and is then exported to different languages such as Python and Ruby. Bindings to other languages (including Java), and porting to Excel/Gnumeric, Matlab/Octave, S-PLUS/R, COM/CORBA/SOAP architectures, FpML, are planned for the near future.

    --
    Ethics II Axiom 2. "Man thinks." B. Spinoza
  52. A mech. eng. example by Xner · · Score: 0
    OO programming is just a though pattern, and it can be applied to almost any problem. Let's consider an example you're probably familiar with, a finite element program.

    In a finite element program you would probably have an object "Mesh" that holds all your elements. Now as you probably know you can have all sorts of different element types with different solution methods. These can all be implemented as subclasses of an abstract "Element" class. A method element->solve() (or solutionIteration() or similar) would then take care of hiding the different solution methods from the higher layers of the program.

    If you want you can extend this method even further, implementing a Node object that can be shared by multiple elements. By subclassing the nodes you can implement things like boundary conditions.
    You see, the problem now becomes a connected forest of objects that are rather uniform, but can have their own specific rules of behaviour when needed.

    I'm not saying this is not possible with regular procedural code, people have been writing procedural finite element simulations for years. What i'm saying is that if you want to bring some architectural sanity into the world of computational science (and god knows it needs it...) OO might help.

    Note that if for whatever reason you cannot/do not want to use an OO language, you can still think OO. You can then implement the thing using a regular procedural language that has some way of keeping data together in a logical way. Structs in C are perfectly suited for this task. This way you might miss some of the neat OO features, but the resulting code will at least have the advantage of keeping data and related code together.

    --
    Pathman, Free (as in GPL) 3D Pac Man
  53. Ought to Work by Anonymous Coward · · Score: 0

    From the 1920's through the 1960's it was quite common to solve engineering problems with analog computers. Some analog computers were mechanical and others were electronic. These machines were inherently object-oriented. One built the program by connecting together components (objects) into a model of the system of interest, and then observed the results. If O-O software hasn't reached this level of capability yet, maybe there's a problem with the way we do O-O.

  54. general software engineering practices by RussRoss · · Score: 1

    It's not necessarily a matter of mapping a specific engineering problem to an OOP model that will yield benefits. I see OOP as valuable for any large software project even if the problem itself is not particularly object based. User interface code maps better to OO designs and collaboration in a developement team tends to work more smoothly with an OO framework. I think it is in the general construction of an application that OOP will give benefits (if used properly) rather than in the specific solution to a specific problem. In that sense, any engineering application could benefit. For small problems (and small applications) I generally use an imperative language like C or Perl, but for larger projects I favor a OOP approach.

    - Russ

  55. Depends on what you define as a problem.. by zulux · · Score: 2

    A lot of engineers have trouble with the problem "Staying employed during a recession." OOP is the cure - every bit of code you create is now unmanagable to your cow workers. As such, you can't be fired.

    --

    Moneyed corporations, non-working 'poor' and criminal prisoners are turning productive citizens into tax-slaves.

  56. OO wins if the problem is subject to factoring by west · · Score: 2

    My personal experience has been that OO is a big win when a problem is subject to factoring. By factoring, I mean that when you take each element involved in the problem, you can find common factors between them. In that case, you get a natural class hierarchy by moving the common elements into parent classes with each individual element being a subclass. The reduction in code size decreases the number of bugs substantially.

    One way you can detect this is if you are doing a lot of cutting, pasting and modifying during development. Often this is an indication that a better design would be to have one copy of the base code. All the other elements that had copies would now essentially inherit the base code and then override the parts that need to be changed for that particular element.

    If your project is not going to involve a lot of inheritance, then OO is really only useful if you are in a large project, in which case it acts as a useful way of delineating responsabilities. (i.e. all I have to do is implement and test these interfaces and I don't have to worry about stepping on other people's toes.)

    This is all a great simplification, but it covers my experience in a nutshell.

  57. Depends on your situation by Hasie · · Score: 1

    I'm an electronic engineer and a little while back I was playing around with an algorithm for designing impedance matching networks (circuits that make one impedance look like another one). The network can consist of series inductors, parallel inductors, series capacitors and parallel capacitors. I implemented each of these components with an object. So OOP can be used for some engineering programs!

    On the other hand, heavy duty computations are probably not well suited to OOP because there is a very slight overhead involved with using objects. This small overhead can be multiplied a HUGE number of times for very large problem and can increase the computation time and memory requirements. That's one of the reasons FORTRAN is still so popular for heavy duty calculations: it's very simple and has no unnecessary overhead to speak of. Add to that the fact that it was designed for heavy duty mathematical work in the first place and you have a winner.

    Just my opinion mind you!

  58. to explore this in more depth. . . by mjackson14609 · · Score: 1

    . . .take a look at some issues of Computing in Science & Engineering; they have a website, although much of the actual content isn't free. You'll find some successful OO applications there.

    --
    I decided that behaving ethically was the most nihilistic thing I could do. - Paul Pavel
  59. Sure -- What about FEM codes by Perldivr · · Score: 1

    For my Master's Thesis (in ME) I created a FEM applet written in Java. OOP works well for this application since elements can be treated as objects. In theory, you can add new element types to your code by creating a new object with an appropriate interface.

    OOP also helps with mathematical entities. Java lacked a suitable Matrix class for Force and Stiffness matrices. Luckily, OOP made it practically trivial to create new classes to not only hold the numbers, but to also encapsulate matrix algebra. Want to multiply a matrix by another? You can easily do something like this:

    myForceMatrix=myStiffnessMatrix.multiply(myDispl ac ementMatrix);

    In short, I found OOP concepts very helpful for my Java finite element applet.

    - Perldivr

    1. Re:Sure -- What about FEM codes by Anonymous Coward · · Score: 0

      I also have an engineering background and acquired "naive" OOP skills through OSMOSIS (no formal training per se, but I think the basics are all an engineer needs. I've never really needed multiple inheritance, for example).
      I have also written an FEM code in C++. I started with 1D, went to 2D and could have gone on to 3D without rewriting from scratch. I think that you'd find this a useful exercise for getting to know the OOP approach better and see the advantages in implementing it in C++ (which enforces it better than writing in C).
      Generic programming is also worth learning. I've used the STL heavily to solve topology problems in characterizing FEM meshes (for automatic translation from design to photomask).

      I think that any problem based in geometry (i.e. most engineering problems) is best programmed with OOP. You know that if your program is successful, you'll be asked to add more features and an OOP design makes it easier

  60. OO in engineering by obuyukis · · Score: 1

    There are quite a few finite element programs in OO. Some CFD code too.

  61. An instance where OOP helps by truck · · Score: 1

    I use various methods of solving partial differential equations in large scale applications like segmentation of medical images. As I am sure will be expanded upon by others, OOP methods do not help to solve the problem per se, but they can make coding and debugging much easier. With complex algorithms that can be the difference between a single researcher applying the algorithm in a month versus 6 months and having to get 2 or 3 others to help code.

    An example:
    I have a Data class that can store itself (serialize) in a standard scientific data format, like HDF and can perform other various tasks (get, set, null all values, add, subtract, etc). Now I might have subclasses that specialize to vectors, 2D arrays, N-dimensional arrays, etc. The basic functionalities are inherited and once tested will be less likely to cause problems in other classes. Lets further say that these classes are parameterized, i.e. templates. Now the basic functionality works for floats, doubles, unsigned char's etc. I could of course get this same functionality with normal procedural programming, but in the end my colleagues and I will be more productive.

    OOP is a tool, just like an oscilliscope or a strain guage. Not using it when appropriate is not good engineering practice.

  62. Objects are things by battjt · · Score: 1

    I've done programmnig for truck engineering support.

    Objects are things like engines, axles, gears.

    "finite difference solutions to differential equations, finite-volume computational fluid dynamics, iterative solutions to non-linear equations, Monte-Carlo simulation of radiative heat transfer" are process to be run on objects. They may be objects also, but OO is best at helping you organize you data.

    My experience with IT supporting engineers is that engineers first think of the process, then the data (data may be denormalized data sitting in some table somewhere, but here is the math that we want to perform on every row) and IT concentrates on organizing the data (here is an efficient datamodel for that data that you want to perform some operation on). See how OO would better fit the needs of the IT staff?

    The trick is understanding what engineering wants to do with data, so your object models facilitate their computations, not get in the way.

    The work I did was to model the truck, then using math supplied by engineering, we performed simulations with our models. The advantage was that engineering couldn't do the simulations alone because they couldn't get their minds around the vast amount of data and we couldn't do the simulations, because we didn't know the behaviors of the materials.

    We acutally had objects like a transfercase that had a bracket location, gearRatios, input location, output location, currentGear, inputRPM, outputRPM, etc. Some of these values were calculated and some we given depending on the type of simulation. The trick was deciding when to calculate values and when to use cached values. (we used a dependence graph that was implicitly constructed) Are simulation would include activities like running the engine through the RPM range and each gear of the transmission, and articulate the rear axle through its positions to find binding in the drivetrain. Using these simulations we were able to select some parts (is this axle better than the previous?)

    Joe

    --
    Joe Batt Solid Design
  63. Stuff by Anonymous Coward · · Score: 0

    OOP is good for big programs with complex workflows. When you have 50-1000 developers working on a single product you need to devide their job. For these projects OOP is a must. Even if you work on a project alone you will be more organazed by using OOP. OOP can also be used to improve reuse of the code, but I rarly see a library that is designed well enough to use it. Well designed libraries usualy designed in such way that mistakes are not easily made. If you not sure why OOP might make you program better, you probably will be better off not using it. This exspesialy true if you procedural way of programming gets job done..

    1. Re:Stuff by TheShadow · · Score: 1

      exspesialy?

      especially

      --

      --
      "What do you want me to do? Whack a guy? Off a guy? Whack off a guy? Cause I'm married."
  64. Pragmatics... by Yoda2 · · Score: 2, Insightful

    If your primary job is engineering and not programming, and you're getting the job done in FORTRAN, then by all means stick with FORTRAN. If on the other hand, you are building software systems from scratch that will need to be maintained over time and have components that might need to be reused then maybe OO is the way to go. In any event, it is good that you are exploring OO because even if you don't use all the techniques explicitly, you are probably picking up some good design ideas through osmosis.

  65. Industrial Engineering Example by jstarr · · Score: 1

    Although Industrial Engineering (IE) reflects different problems than your more mechanical examples, IE is definitely engineering and its problems can be solved (conceptually) better with OOP. Why? Because IE deals with large-scale simulations involving multiple discrete parts. The systems cannot (typically) be represented by a system of differential systems, and instead must be modelled as independent parts communicating with each other. In other words, these are complex systems.

    For example, I'm a research assistant in a project studying realtime promising. (Essentially, this project is looking at ways to determine the due date of an order quickly and accurately. This way we can avoid saying 6-8 weeks to deliver...) Although the different algorithms and heuristics could be included in a procedural or functional paradigm, the overall size of the system (>10,000 lines) along with the complex data types (some with more than 20 attributes) lends itself best to OOP. Earlier versions of the code were written in a more procedural fashion, but by moving toward a more OOP framework the code has become simpler and easier to manage.

    Additionally, since this is research software, ease of making changes is a high priority. It is easier to be able to make changes to key systems without disturbing other code within an OOP system than with procedural or functional code. If the system was already well-understood, then a straight-forward procedural solution might be preferable.

    I would like to add that my statements about functional programming do not include functional programming with objects (ala CLOS).

  66. We do it! by Bill+Barth · · Score: 5, Interesting

    Imagine for a minute that you don't know what problem you want to solve yet. You know that that you want to apply a Galerkin Finite Element Method (for instance, though this particular method isn't required) to a whole class of problems on unstructured grids on a whole class of distributed and shared memory parallel computers. Imagine that you want your user base to be able to specify their equations like they would in LaTeX or some other markup language. Now try imagining that you have only FORTRAN77. Not a pretty picture. We're in the process of completing a rewrite of major sections of our parallel code to do exactly this. Our code started out (7 years ago) as an extremely efficient parallel (3D) C/F77 code for Navier-Stokes + Heat Transfer and is quickly growing into a multi-purpose, multi-physics code written largely in C++.* We extract considerable advantage form C++'s ability to hide implemenations so that as long as interfaces don't change the guts can. We also make good use of the ability to run code before main() in order to register the exisitence of routines (hash tables are your friend). If the routine isn't there you can't call it, but the code still compiles and runs otherwise. We also make use of base class/derived class relationships and polymorphism to allow, for instance, one base mesh class for the rest of the code to interact with, but with two separate derived classes: one to generate meshes internally, and one to read meshes from other programs. Etc., etc. I'm not sure our website can take the /.'ing, but you can look here for some hints. * I say largely b/c there's a few struct's still left over from the code's C days, but all the F77 is gone. There are still calls to assembly coded (vendor supplied) BLAS routines, though.

    --
    Yes...I am a rocket scientist.
    1. Re:We do it! by Bill+Barth · · Score: 1
      I know a self-reply is taboo..... But, I thought I'd mention noweb as well. If you're not doing literate programming in a language independent way for a major, multi-person programming challenge, you're doing it the hard way. For the record, I also prefer:

      emacs

      autoconf

      make

      and a few other things. :)
      --
      Yes...I am a rocket scientist.
    2. Re:We do it! by foxcub · · Score: 1

      We also make good use of the ability to run code before main()

      How does one do this in C++? Can you give a very simple example?

    3. Re:We do it! by Bill+Barth · · Score: 1

      Here's a stupid one:
      The basic idea is a <gasp> global variable (a class more specifically) which needs construction. Its constructor will be called before main runs. In fact, even if you use the default constructor for a global class, it will get called before main, but it just doesn't do much.

      #include <iostream>
      class A
      {
      public:
      A() ;
      ~A() {}
      private:
      int foo;
      };

      A::A()
      {
      cout<< "In A Ctor" <<endl;
      foo=1;
      }

      static A sA;

      int main()
      {
      cout<<"In main"<<endl;
      A a;
      cout<<"After A decl"<<endl;
      return 0;
      }

      ariel(119)$ g++ -v
      Reading specs from /vol/gnu/gcc/2.95.3/lib/gcc-lib/i686-pc-linux-gnu/ 2.95.3/specs
      gcc version 2.95.3 20010315 (release)
      ariel(116)$ g++ -o test test.C
      ariel(117)$ ./test
      In A Ctor
      In main
      In A Ctor
      After A decl

      Hope this helps.
      Bill.

      --
      Yes...I am a rocket scientist.
  67. Speed of OOP... by Bonker · · Score: 2

    Remember that OO code tends to compile into slower and larger executables than structured code. This is not always the case, and optimizing compiliers can do a great deal to mitigate this, but the fact of the matter is that OO code was developed to give coders more power and shorter development times.

    Most of the engineering problems that I've ever seen solved in code are math intensive. One such problem was calculating the drag on a certain aircraft wing. If I remember correctly, the coder who was showing me her code indicated that the math involved broke down into a repetitious series of a few hundred cross-section integrations. These equations had to be solved for several hundred thousand cross sections to get a final result and a chart. At the time ('91) there was no 3d model, and the calculations were being conducted on a desktop computer. As you can imagine, it took a very.. very long time. One of the people I was with asked her what she was doing her math in.

    C. C++ had too much overhead, she complained, and the C compiler she was using was slightly faster than Pascal or Fortran. She was very seriously considering trying to translate her equations to register-based assembler code to speed up the process.

    If you have an engineering problem, and you're happy with the results you get from a funcational language, it's probably not worth your time you'll lose from switching to an OO language.

    If you

    --
    The next Slashdot story will be ready soon, but subscribers can beat the rush and slashdot the links early!
    1. Re:Speed of OOP... by glyph42 · · Score: 1

      This is blatantly false, derived from blatant misunderstanding. Do you know what the C++ compiler does to objects and classes? Have you ever looked at the machine code that is produced? If you did you would know that you can use OOP in C++ with nearly zero, and often exactly zero, overhead, because the OOey stuff is done at compile time, not at run time!

      Sure, a newbie C++ programmer doesn't know this stuff, but when you do, the code is not slower and the executable is not larger! There are real people using C and real people using C++ to do really intensive math, and they both work nice and fast. The OOP just helps you organize your code. Saves developer time that way. It's not some bloated piece of crap that gets added to your executable file.

      --
      Music speeds up when you yawn, but does not change pitch.
  68. Design Analysis, not Problem Solving by franimal · · Score: 3, Interesting

    From your post is sounds like you're solving single solution problems where you write a 'disposable' procedure (probably reusing some code) for each problem. OOP isn't designed for that.

    OOP really starts to shine when you actually have objects to work with. If all you're doing is trying to solve a single solution problem a simple 'disposable' procedure is the best route. For larger, evolving, iterative projects OOP is a godsend. In my case, I'm designing a MAV (Micro Air Vehicle).

    I'm using Python instead of C++ but the OOP example still holds. Aircraft design is a highly non-linear process, and for myself at least, counter-intuitive. I could write a single procedure to run the analysis but that's not nearly a flexible as an OOP solution.

    Basically, I'm using off-the-self components (i.e. motor, batteries, propeller) as a starting point for my design. Each of these components is considered an object. These components are combined in such a way as to make another object: the entire MAV. By using OOP it's rather easy to try different component configurations and design conditions (flight altitude, cruise, loiter, velocity, etc).

    If I was really cool (I'm not) I could add in some simulation stuff (Larger aerospace corporations do a lot of this, as it's cheaper and quicker than an experimental approach).

    One thing that this sort of OOP approach lends itself towards (especially in my case, is genetic algorithms). Since aircraft deisgn is so non-linear, and counter-intuitive the best solution is not easy to find. So many different designs need to be analysed. OOP and genetic algorithms were born for just this sort of thing.

    If you have a single problem that needs to be solved once for one set of conditions, then use a procedure. If you have a larger project that requires the solution of many smaller problems for various conditions (instances to use the OOP term) then OOP is an easier route. Anything in between is a judgment call and really depends a lot on your specific case.

  69. It depends on the data by jstott · · Score: 1
    I do programming for physics problems in a variety of languages and I've found OO programming techniques work best when the "data" can be represented as objects. This makes OO approaches very natural in GUI's, where all the different widgets share certain common traits (position, isvisible(), drawing, etc) and some traits that are unique to the object (is the button pressed, etc). It also comes in handy for both multi-threaded applications and talking to hardware where the thread/hardware can be encapsulated in an object and the object will handle the details of allocation, deallocation, etc.

    For most physics/engineering problems, though, you only have a single type of object. For example, in a FEM heat transfer problem you would have

    1. A vector that relates actual position (x,y,z) to node index
    2. The thermal conductivity at each node (a REAL)
    3. The current temperature at each node (a REAL)
    There is no hierarchy of data here to exploit, so proceduraly progamming will be the easiest to work with (especially if that means using a language you're already familiar with).

    Let the data determine the language you use, not the other way around.

    -JS

    --
    Vanity of vanities, all is vanity...
  70. OOP vs. C++ by Rohan427 · · Score: 2, Interesting

    Many people confuse OOP with C++. The two are not the same. C++ contains enhancements that are _supposed_ to help OOP, but often don't.

    I've been programming for more than 24 years and have dealt with languages from assembly to FORTRAN. I learned to program in assembly before PC's were even invented. I have always written code as modular and reusable and in a sense in an OO style. I've solved many problems, some large, some small, using OO programming without using C++. In fact, I try to avoid OO C++ for many reasons, though I prefer to use a C++ compiler and a smattering of C++ functions/keywords and style.

    I think you will find that many problems have been solved using OOP, but that the definition and composition of OOP is often misunderstood. For a good example of an application that is written using OO techniques, but does NOT use OO C++, see the Quake II source code.

    The reasons I avoid using OO C++ is due to inefficient compilers, the tendency to generate hard to find/fix bugs, excessive overhead, and the tendency for other programmers (if I'm working in a team) to overuse/misuse OO C++ features (e.g. - operator overloading). To date I have been able to accomplish the same tasks, with the same OO designs, using straight C, with less hassle and greater efficiency.

    - Rohan

  71. It helps manage code, not engineering by dnoyeb · · Score: 1

    OOP will help you manage your code, not your engineering.

    1. Re:It helps manage code, not engineering by Anonymous Coward · · Score: 0

      this shows that people skip right to the comments without reading the article.

      "what are we discussing again?"

    2. Re:It helps manage code, not engineering by dnoyeb · · Score: 1

      I read the article in Full prior to my reply. Please explain how you came to your conclusion.

    3. Re:It helps manage code, not engineering by Anonymous Coward · · Score: 0

      It was obviously an allusion to what the article said about being satisfied with an answer "blah blah blah". It was obviously a joke. He quoted "blah blah blah" exactly.

      Replying seriously to it would hint that you did not read the article or at the very least did not get the joke.

  72. Ptolemy project by rfischer · · Score: 2, Informative

    I'd recommend that you check out the Ptolemy project (http://ptolemy.eecs.berkeley.edu/). It brings the most powerful features of OO design (encapsulation, polymorphism) into an engineering modeling environment. Applications? Signal processing, simulation of hybrid electronic and mechanical systems, embedded control, etc. Also the basis for many electronic CAD tools.

  73. Particle Simulations by McBeth · · Score: 2, Insightful

    As part of a project I was on, we needed to do a bunch of simulations of particles moving subject to physics. Unlike what you usually see in games, these needed to be real simulations (reproducable in the lab).

    We ended up doing a bunch of OOP so that we could handle many different kinds of particles, and many different PDE solvers, each selected for the particular task. Because of polymorphism, we were able to write the engine once, and plug in what we needed fairly easily. In the end the code ended up being much cleaner, readable, and faster than the Fortran we started with. We have gone on and are using it for a completely different kind of simulation now with minor changes.

    This was all in the Chemistry Department, but I certainly think it applies.

    I would guess that most engineers use Fortran in part because of the book "Numerical Recipes in Fortran". Although there exist C and C++ versions of the book, they certainly don't take advantage of the languages, and for the most part are direct ports of the fortran. They are very disparaging of the languages in those books, and even spread FUD about C, C++ and the numerical stability of the compilers.

  74. You must be joking. by Anonymous Coward · · Score: 0

    What about games? Without object-oriented programming, IMHO FPS game programming would never have come to being. What did OOP do for you, you ask? It made such wonders as Doom, Quake and Unreal Tournament. I'll give a few examples, but since I'm only an aspiring amateur game programmer, no flames for my ignorance plz.

    The concept of OOP objects comes to life in highly visual games:

    You have monsters that maintain certain attributes: when you shoot different monsters in certain ways with certain guns they fall down or gib in varying ways according to the monster's size and whether its guts are green on red. Each of these monsters is an object.

    Each weapon has its own attributes to keep track of: ammo, range, accuracy, etc. Each of these weapons is an object.

    A grenade flies through the air a certain way only if gravity is such a level and it bounces 5 times. That grenade is an object.

    And so on.

    When a team is writing a game, or any program for that matter, communication becomes very complex. If a scripting language is used, it's much more difficult to keep track of variables and subroutines than with OOP because with OOP you can say, "Ok, all you need to know is that if you create a new object of my class, this is what goes in and this is what comes out." This "solid state" style has greatly streamlined software development and has allowed developers to more easily reach goals and set assignments for themselves.

  75. numerical analysis by hding · · Score: 2

    There's an intriguing book called bject-Oriented Implementation of Numerical Methods: An Introduction with Java & Smalltalk which might give some pointers. I haven't read it (just browsed it in a bookstore), so I can't give a personal recommendation one way or the other. It does seem rather intended to address just your question, though.

  76. OO is the way to go-o by nuffle · · Score: 2, Informative

    Don't listen to the guys saying engineering problems are best solved with procedural programming. That's a ludicrous generality.

    Both methods (and basically all programming paradigms) can be used to solve your problem. Which you choose depends on factors other than just "which will work". Readability, reuse, maintainability, performance, and ease of design are some of the issues you'll have to weigh do decide whether to use OO or procedural. In my opinion, OO programming beats procedural in all these matters except performance (but C++ ain't too bad, right?).

    My company does a great deal of mission-critical engineering software development (satellite command and control, for example), and we approach every large project with OO design and implementation. We find it insturmental in managing complex systems.

    If you ever have to show your code to someone else, they'll thank you for having partitioned your project into smaller entities each with their own responsibilites and personalities. This modeling concept is much easier to follow than procedural's interweaving threads of execution.

  77. stupidest article EVER by Anonymous Coward · · Score: 0

    To illustrate clear lack of understanding for both engineering and OOP in the title commands my certain respect. That is the stupidest slashdot posting I have ever seen. For fuck's sake, any language can do anything but some do it with less pain.

  78. Stupid topic... by stank · · Score: 1

    Plenty of people use OOP every day to solve all different kinds of problems, end of story. This same discussion happens at least once a month on Slashdot.

    Please stop posting these kinds of questions, because it just baits everyone into another useless OOP war.

  79. I have written one a few years ago. by Anonymous Coward · · Score: 0
    I can dig and send you my PDESolver class which you can inherit and solve partial differential equations. I don't remember the numerical method I used, it was partial difference method with adaptive step size, but what exactly it was, I don't recall. Anyway it sucked. I can still send it as a proof of concept though. The code went like this:

    class MySystem : public AbstractSystem { ... }

    MySystem MEKReactor;

    MEKReactor.Init(...);

    PDESolver MySolution(MEKReactor);

    MySolution.InitBoundaryCond(...);

    MySolution.Solve();

    MEKReactor.Dump();

    It was a student project, and all OOP crept in was just to add a little fun to a utterly boring reactor design (not to mention impressing friends) and it was very limited. I doubt anything like it might be used for a real application, since you will have a performance hit. But some coder (which I am not) under directions of a real programmer (which I am not either) and an engineer can build something like it both flexible and high performance. The problem is, as long as most engineers know and use fortran exclusively, such a thing would be of little use.

  80. Here are several examples of the type you mention by Flat5 · · Score: 1
    An AMR Simulation Framework in C++

    A CFD Framework in C++

    A Multiphysics Simulation Framework in C++

    and many more. I have more to say but I must leave for work to get back to hacking my own OOP engineering code.

    Flat5

  81. OO great for systems, overkill for small tasks by kitts · · Score: 1

    (sorry if this sounds like I'm talking down to you -- I don't mean to, I'm just giving the same shpiel I give to my students when they want to know generally about what OO is about)

    Object Orientation is really great when you want a complex system of different components working together, and you need to design the entire thing from scratch. Also, knowing OO is great when you have to repair or upgrade a system that's already OO.

    At the risk of sounding arrogant, from a systems design point of view, there's little these days that's as complicated as your high-end software application, which is the purview of OO. Some systems try to do this without OO (or quasi-OO, like Gnome with C), and it often ends up looking muddled.

    But just because your proposed system has a lot of components doesn't mean it's a good candidate for OO. What you need to do is start thinking in terms of the complexity of the individual components themselves. Do each of these components keep track of lots of state variables? Do the components have lots of different ways of accessing them? Do some of the components share a common design parentage? Do you want to keep some component information hidden? Do they need to communicate with each other using a unique protocol? Do you think you might want to reuse these components in other applications? If you can see that this might be the case, you might have a candidate for OO.

    There's also something that a prof told me once -- that 97% of all C++ programs aren't OO. I don't know how valid the stat is, but it highlights the problem that an OO language doesn't necessarily translate to an OO setup, so seeking out an OO system to look at isn't necessarily as simple as finding some C++ source code.

    For the problems that you've outlined, you're talking about pretty simple math, and by "simple" I mean, can probably be solved using a few lines of code, a few recursive functions, a couple of complex data structures, etc. This stuff can be solved in any number of high-end languages -- at worst, you might want to learn C. If, on the other hand, you want to develop a software application around these calculations, to streamline the input and output of data, you might potentially have something that can take advantage of what OO is all about. For instance you might have objects that have private attributes for the different operators and public methods for doing the calculations or redirecting the results to a database or graphing suite, etc. You might also have an abstract base class so that all the objects have the same feel to them, even though they do different calculations...

    --
    -------------------------------------------------- ----
    charlton heston is more of a man than yo
  82. Promise of OO, and failure by SmurfButcher+Bob · · Score: 1

    My old CS instructor said that OO would help make design and implementation easier and cheaper, when it was appropriate. And for a large part, that possibility exists.

    However, as MS repeatedly proves, OO is useless when it comes to actually doing this... GIGO code is now simply encapsulated and inherited.

    --

    help me i've cloned myself and can't remember which one I am

  83. Managed code by ZaneMcAuley · · Score: 0

    Not only OO, but also managed code will solve issues in software engineering.

    --
    ----- Whats wrong with this picture? http://www.revoh.org:1234/whatswrong
  84. I use it by BenjyD · · Score: 1

    Here at the CPSE at Imperial College, London, I use a set of C++ class libraries called ooMILP (Tsiakis/Pantelides). They basically provide an OO wrapper between the integer/linear program solver (eg CPLEX) and your code. I find them really useful for my PhD work in process scheduling.

  85. Yes it can by Anonymous Coward · · Score: 0

    OO is a way of organizing code.

    There are 3 basic axioms with any programming: i) coupling - clearly defined and small interfaces, ii) cohesion - related things (code/data) stay together and iii) localization - changes to the program should not propagate out of control.

    These principles/axioms are true for any programming OO or otherwise

    OO is a good way to achieve these goals.

    It is difficult to build a system with low coupling, high cohesion and perfect localization of changes since it not only requires an understanding of the problem but also of the tools used to solve the problem.

    Again, OO is a great tool to achieve these goals, if you know how.

    1. Re:Yes it can by Anonymous Coward · · Score: 0

      How about a fourth - fucking. For instance, you're a fucking idiot.

      Go fuck yourself,
      AC

  86. Motion control by wiredog · · Score: 2
    I worked in that field, and it is very susceptible to OO solutions. A motor, for example, has a max speed, acceleration, position. It moves. Has a set zero position routine. It may move to far or it may stall (error handling routines). It may be a stepper or servo motor (subclasses).

    Pushbutton switches can be on or off, lights likewise (same class, sanity checks to ensure you don't read a light or turn on a pushbutton).

    Remember, you are dealing with real world objects which have attributes. Look at them from that perspective, and see how you can model them in software.

  87. OO by ShrimpX · · Score: 1, Insightful

    Object Oriented problem solving is not a "rival" to procedural problem solving; it encompasses it. The OO core notion doesn't "solve" problems, it organizes them into more intuitive and maintainable forms, so that they are easier to solve. It is best suited for larger scale applications, where it makes most sense to have your problem broken down into tiny self-contained units that are flexible and easy to manipulate.

  88. Can be faster by EnglishTim · · Score: 2

    There are many instances where C++ can actually produce faster code.

    For a simple example, compare the C qsort with a C++ template Quicksort function. In the C++ version, the comparison operator would likely be compiled inline to the function, meaning that you don't get the overhead of a function call for every comparison. In C the only way you could do this would to be to write quicksort yourself for every data type that needs it. C++ templates allow a lot of work to be done at compile time, rather than at runtime.

    Check out http://www.oonumerics.org/blitz/ for fast C++ scientific applications.

    cheers,

    Tim

    1. Re:Can be faster by Kamel+Jockey · · Score: 1

      For a simple example, compare the C qsort with a C++ template Quicksort function...

      Interesting comparison, I am wondering though, in many general purpose compilers, such as MSVC++, gcc, etc., aren't many of the built-in functions, such as qsort, etc, internally optimized (through whatever magic means needed, which would be outside the normal scope of what a programmer would do) so that they would automatically run more efficiently than anything that a programmer could write on their own?

      --
      In case of fire, do not use elevator. Use water!
    2. Re:Can be faster by xkor · · Score: 1

      Not exactly.

      While microsoft probably optimizes their functions as much as possible (possibly even resorting to assembly for often-used functions), the problem is that qsort compares the items by calling a user defined function pointer. Thus, each comparison has the overhead of a function call. Instead of function pointers, the STL's std::sort algorithm uses the () operator on a template parameter, which can be easily inlined as part of the generated code (the compiler will generate a new sort function for each data type / comparator combo). If the comparator is simple enough, the std::sort algorithm can be 2 or 3 times faster than C's qsort function.

    3. Re:Can be faster by sigwinch · · Score: 2
      In C the only way you could do [polymorphic quicksort] would to be to write quicksort yourself for every data type that needs it.
      Not true: Multi-line macros are your friends. Or is it enemies? I forget which. Anyway they're powerful. ;-)
      --

      --
      Kuro5hin.org: where the good times never end. ;-)

    4. Re:Can be faster by cakoose · · Score: 1

      That (STL sorting) seems like the equivalent of running a code generator to generate a quicksort function for every required data type. A C-code generation program along with some Makefile rules could do this, right? (though to some, this may be unforgivably lacking in elegance)

      I was wondering if it is possible (and reasonable) for a C compiler to inline functions at runtime; could a compiler leave a blank space of maybe 50 no-ops and copy the code for the comparison function into that section at runtime? Then C programmers could program with the rough equivalent of Lisp macros (or the rough equivalent of what I think Lisp macros are :-)

      If the comparison function is greater than 50 (or how many ever) instructions, the function call overhead will be relatively insignificant and a function call can be plugged in instead. I don't know anything about current caching, branch prediction and no-op handling schemes and was wondering if runtime inlining would work well (if hardware was optimized to deal with it efficiently).

    5. Re:Can be faster by xkor · · Score: 1

      Templates in C++ are code generators--a C code generator could do the same thing, but it may not be type-safe. One of the purposes of inline functions and templates is to give developers an alternative to using unsafe C macros. A huge advantage of templates is their type safety; the STL's std::sort algorithm is much less error-prone than comparing void pointers from qsort.

      Since a function call is usually only a few instructions, the cost of a function call is usually negligible for everything except simple expressions (like comparisons). In fact, many C++ compilers will refuse to inline functions that contain a loop. Mindlessly inlining non-trivial functions results in code bloat, increasing the code size as well as the chance of a cache miss.

      Many virtual machines (Java and possibly the CLR) do runtime inlining. If a function is called often enough, the Java Hotspot VM will generate new JIT'd machine code with the function inlined. Because the code is generated on the fly, there is no need to reserve space for the dynamically inlined code.

  89. Multi-Threading Much Easier Under Oop by snatchitup · · Score: 1

    As well as inter-process communication.

    If you want to take advantage of SMP, etc., OOP to me seems like a natural fit.

    Let me also underscore the point that it manages your code better.

    To, me the question would be, "Why should I use FORTRAN that my old professor so dearly loves."

  90. Design by PSL · · Score: 1

    You must put alot of initial design in a OOP to make it re-usable. Start with making functions more universal. Where there's a will there's a way. It's just going to take more time initially to code a reusable program than one just designed to solve one particular task.

    --

    "Times may change, but standards must remain the same." - George Carlin.
  91. Used OOP in PLC simulation by mx90 · · Score: 1

    In my final year of Comp. Eng., I hooked up with some Comp. Sci buds of mine in a senior thesis course. Ultimately I didn't take the course, but I still had a hand in the project, and laid the ground work for it (I had some summer jobs working with PLCs - programmable logic controllers).

    [long background, but there is a point to this:]Anyways.... In traditional software development, the general process is design, code, then test, test and more test. In automation, the rule seemed to be (at least it was where I worked) spec --> code ladder logic --> install. Test? Not really.... testing [on the plant floor!] was limited to turn it on and cross your fingers. If it doesn't work, run around the floor resetting drives and e-stop buttons, hack the PLC code to cover unforseen scenarios that the original logic writer didn't think of (who would have thought that the guys on the line would have tried to do...?). Ugh. Wrong on so many levels. Expensive, time consuming.

    But what if you could simulate the plant floor off-site? Test your ladder logic before hooking up the PLCs to the equipment? True, PLC ladder logic simulators exist, but these really only verify that your code is syntactically correct.. not that it does what the spec says it should. They just run the ladder logic you wrote outside of an actual PLC. But what happens when an e-stop is pressed, and THEN a drive faults? etc. Does your ladder logic consider this?

    So what we did is propose that you could model things you'd find on a plant floor with C++ objects. For our demonstration, we modelled a really basic and trivial setup. We had a few lights, a few emergency stop and start push buttons and a cheap simulation of an AC drive. Each object lived in its little process... it wasn't truly *realtime* per se, but it was close enough for demonstration purposes. The point of the exercise was that we were able to send the simulator dozens of scripted test scenarios like:
    [time] [object] [action]
    00:10 start_pb PUSH ON
    00:30 ac_drive SIMULATE CURRENT FAULT
    00:45 ac_drive VERIFY SHUTDOWN
    for example... check that your PLC logic to see that it monitors correctly for a fault... the last line would check the drive object to see that it got a shutdown signal (from the PLC)

    The second part of the project (which we didn't get to) was to actually build an interface through a multi-channel I/O board so the simulated objects could talk directly to the I/O on a real PLC using +/-12V, 24V analog and 5V TTL digital signals.

    But the idea was that equipment manufacturers could write simulation objects for their real devices. Installing a new AB drive on the line? Test out your PLC5 code before hand... go download the sim object from allenbradley.com, and throw your test plan into the simulator. Could find out that the new drive uses a different range for output speed, and you have to rework some conversion in your ladder logic. A new sensor has faster response time so you have to adjust a PID loop. Or whatever. All this before wasting time and money on the plant floor.

    So.. ok, we never get very far with it (although my buds did get a good mark for the course) but the idea of having these objects was good. You could do something similar with procedural code of course, but you'd have to rewrite the code for every setup you wanted to test.

  92. Nature of engineers by cholokoy · · Score: 1

    By nature, engineers are lazy. I say this in the context of one that is not demeaning but rather in the sense that engineers will try to solve a problem in the easiest and most economical way possible. I say so because i'm also a mechanical engineer like the poster.

    solving a problem using OOP will require more initial effort than using a traditional language like FORTRAN so you see why OOP is seldom used.

    Also, engineering software is not as mainstream as say a spreadsheet so that it has a very limited market thus is not very appealing to the software makers and tend to be niche markets.

    --
    Return the bells of Balangiga.
  93. I don't know what you mean by MSBob · · Score: 2
    I don't know what you mean when you talk about an engineering application but there are some significant C++ applications written for the geoscience industry. I worked for a small company that does a 3D structural restoration and C++ was just fine for the purpose. We had our own scene graph/utility library and a GUI that exposed the toolkit's functionality.

    The reason for using OO was code maintainability and compartmentalization. It is generally easier to divide work up once you're able to break your application down to classes.

    OO also means extendibility. With the right class hierarchy it was easy for us to add a new node to our scengraph to support a new type of data. For example, initially the app supported horizon data only, later on we added support for faults just by extending one of the base classes. OO will help you write any application if your class structure is sane.

    --
    Your pizza just the way you ought to have it.
  94. OOP by AlgUSF · · Score: 1

    OOP is suitable for large software packages that evolve over time. Such as a Word Processor, Inventory System, etc.

    If you are writing a program to calculate the trajectory of a rocket or something, where the code probably won't change over time, then a quick procedural program is probably the best. For engineers, something like mathcad was probably designed using OOP, because it is a software package that is changed often between versions.

    --


    I want my rights back. I was actually using them when our government stole them after 9/11.
  95. NASA uses java by Anonymous Coward · · Score: 0

    I know that NASA has used java for control of the Mars Rover and with some sensor applications. That by default is OO. I think that there are quite a few other companies taking advantage of java for engineering applications (especially in the wireless arena). For M.E. I think that simulations applications could (and likely do) take advantage of OOP.

    1. Re:NASA uses java by Anonymous Coward · · Score: 0

      So that's why NASA sucks lately... Billion dollar paperweights running Java are no endorsement of OO Design.

  96. Use OO for the Objects, Procedures for the loop by ericbusboom · · Score: 2, Interesting

    The applicatations that you listed primarily deal with physical systems, so they are very well suited to OO, where an object can be used to represent some real-world thing. Molecules, machine parts, elastic elements, or magnetic domains are all things that have behavior, state and identity, so they are perfect cantidates for objects.

    But, the physical simulations are also iterative, so the code will have a loop, and loops feel like procedural code. That is not a conflict -- you are allowed loops in OO code! Your simulations would likely have a loop that iterated over time, space, temperature, or energy, and for each iteration, you would examine the state of each object in the system and call some methods on them to simulate their behavior.

    For instance, if you were building a solar system simulator, each planet would be an object, with properties for position in space and mass. Your loop would iterate over time and over each planet. For each planet in a time step, calculate the force on the planet due to other planets, and move the planet in response to the forces. ( More likely you would use an adaptive iterator and use another loop to do several iteration steps per planet per timestep. ) The benefit of OO here is that it makes it easy to organize your code and move simple things like F=Ma, 3d vector manipulations and your Runge-Kutta integrator out of the main algorithm. Plus, your code is easier to read, since you don't nned a lof of comments for things like planet.mass() or planet.move(vector)

    OO makes physical simulations much easier because it allows you to organize the program according to the physical structure of the system, and those object remove a lot of basic code from the algorithm, so the algorithm becomes simpler and easier to work with.

    I have built simulations for packet networks, simulated anealing, Ising glasses, Newtonian mechanics and finite element analysis in both OO and procedural style, and OO worked so well that I would never consider writing any of them in procedural style again.

  97. Thoughts... by S1mon_Jester · · Score: 1

    It sounds like (to me at least) that you are asking how can I use OOD/OOP to solve a single small piece of code that's only going to be used once.

    You can use OOD/OOP but frankly, you won't find any benefit. OOD/OOP is not for throw away code. Use perl and be happy. :-)

    Now, if you want to take a set of common engineering problem, and write a generic solution for them, then OOD/OOP are MUCH more useful. Especially if you have coders in different areas working on different sections of the code. (OOD/OOP seems to really favor breaking up large development project into smaller managable chucks.)

  98. A book to get you started by Kryptonomic · · Score: 1

    John J. Barton and Lee R. Nackman, "Scientific and Engineering C++", Addison Wesley Longman, Inc., 1994. (ISBN: 0-201-53393-6)

    1. Re:A book to get you started by J.+J.+Ramsey · · Score: 1

      C++ does not necessarily imply OOP programming. One might simply use it for features like function overloading, or to use it to make a more useful array class (which would use C++ OOP features without making the number-crunching code necessarily OOP).

  99. paradigm shift/expanding your toolbox by gimpboy · · Score: 1

    i believe the poster is trying to think 'out of the box'. while i hate that term, it does have some uses. in engineering we are taught methods to approach problems. these are very procedural and also very useful. the problem with this is that we tend to get stuck in a rut and are unable to see other perspectives.

    i think the person who submitted the article wants some insight on how to look at engineering problems differently. by looking at problems in a different light (eg. variable transformation) you can make an untractable problem solveable, or you can simplify something that was very complex.

    it could be that oop will not help this person. alot of the tools we are taught as engineers have no immediate benefit, but rather their applicability becomes obvious in the future. if you are never exposed to these tools then you might not be able to solve the problems when they present themselves.

    --
    -- john
  100. Only you have the answer. by carlosh · · Score: 1

    No matter how many OO books or code you read, adapting those to your specific need is never straightforward (I guess that's what engineering is all about) don't mention if the kind of problems you are trying to solve are rather procedural as opposed to the more classic OO examples, usually based on modeling interactions between objects in the real world.
    You have to come up with your own ways to apply OO to hide complexity and increase reusability, in fact some of those solutions are so devishly clever the got a name of their own: design patterns. Some research into patterns is likely to give you ideas on how to scratch your own itch.

  101. Sample Functional/O-O code for finite elements by Brad+Lucier · · Score: 1

    If you following the links to CS 615 from my home page then you'll find some functional/object-oriented code to solve finite elements with various iterative solvers (conjugate cradient, multigrid, etc.) for various problem domains (symmetric elliptic problems, transport-dominated diffusion problems, parabolic problems, nonlinear elliptic obstacle problems, etc.) .

  102. Don't look in books. by AeiwiMaster · · Score: 1

    You wouldn't find this type of code in books you will have to read the source.

  103. Curly Quotes by Anonymous Coward · · Score: 0

    "This is a test of cross-platform 'curly quotes.' Can you Unix users out there see curly quotes?"

  104. It Depends by chairmanKAGA · · Score: 1

    If you are just trying to solve an equation or have a program do one thing it is necessary to use OOP to get this done. Although OOP is more of a concept then anything. It's a way to look at the world. Dividing everything into the smallest possible bit it can and then stacking all your objects together to create a specilized thing.....like nature does with us.

    OOP is intended for larger applications and not necessarilly just for programs that only require a function or so.
    But, let's say you are an architect and are designing buildings. It would be nice to have a heiarchy of objects similar to the tools used to build a house and then be able to use you electronic tools to simulate real tools. This way you have a collection of tools that you can "pick up" and use at will without worrying why they work.

    Also, since when is C++ OO? At least a good OOP language. Sure, I guess I was fooled into thinking it was in my programming courses but if you want a *real* OO language that works how OOP should try Small Talk, and if you want to stay in the C world try Objective C, the best OO C. Just because you have to subclass like mad doesn't make it OO. =)

    --
    "Allez Cusine!"
  105. The advantage of OO... by wowbagger · · Score: 5, Insightful

    Preface: I've been an embedded systems software engineer since 1987. I've been programming in C for almost all of that time, and C++ since '91. I've designed systems with over 250kloc, hard realtime.

    The biggest single advantage of OOD is that you can say "This sort of thing will have a function that does something like this, but I won't make the final decision on exactly HOW to implement that function until late, when I have more information on what needs to happen."

    Let me give you a concrete example. I had to design the code to reprogram the flash in one of our devices. I faced the following problems:
    1) the way the data got to us could either be Xmodem or Ymodem.
    2) The file format could be either OMF or raw binary.
    3) The types of memory devices could change - they could be Intel type 1 flash, AMD type 1 flash, or Intel type 2 flash (or RAM), all of which have different programming requirements.
    3a) In addition, the types of flash could be changed by the production line (based on what was available - most of those parts were "on allocation", meaning "you take the quantities we give you and you like it - you ain't IBM so you don't matter".
    3b) The types of flash on a given unit could be mixed - you had to probe at runtime to figure out what you had.

    So, here's how I decomposed it:
    1) I had two file type objects: OMF and Binary. They each HAD-A Input object, which provided data , and HAD-A Memory object, which would program memory. The OMF object read OMF records from the Input object, parsed the OMF records, extracted the data, and commanded the Memory object to program regions of memory.
    2) I had an Xmodem object, which WAS-A Input object. It read data from the serial port, handled the checksum or CRC verification, block counting, and made the data available to the user (the file object).
    3) The Memory object HAD-A pointer to a Memory_driver object. When the Memory object was commanded to write to a block of memory, it verified that the write was in the current block, and if so passed the request to the Memory_driver object. If not, the Memory object HAD-A list of Memory_driver_list objects, which each HAD-A pointer to a function that would probe a given memory address and return either NULL or a pointer to a newly created Memory_driver object. The Memory object would iterate through the list, asking each Memory_driver_list object "Can you program this?". When one of them returned a non-null value, the Memory object would delete the old Memory_driver, and use the new Memory_driver.
    4) I had Intel_series1, Intel_series2, AMD_series1 and RAM objects, all of which WERE-A Memory_driver. Each class HAD-A static instance of a Memory_driver_list object, which automatically linked itself to the driver list. Each driver HAD-A static member function to probe memory and return a pointer to a newly created driver if needed.

    First, this let each routine be focused on what it needed to do - the Xmodem routines didn't worry about OMF format, the OMF didn't do Xmodem handshakeing, the Memory routine didn't care about the specifics of programming memory. I could test each object out in isolation, get it working, and move on. Now, you can do this with proceedural programming techniques too.

    Second, when a new type of memory was added, I was able to just write the driver for it, and not touch the OMF object, the Memory object or the file transfer objects. They automatically picked up the new driver. Now, you can do this in a proceedural language like C, but how do you do so? You make each driver have a table of function pointers, and you have the upper level code keep track of a void * that contains your driver information. Guess what - that's OOP! The function table is the same as a C++ vtable, the void * is your this pointer. Except that in C, you have to track all that stuff yourself, in C++ you can let the compiler worry about the BS and you focus on the code design.

    In short, OOD helps, but you still have to use it correctly.

  106. OO is Hard by karb · · Score: 3, Insightful
    I'm a software engineer. However, I lost you at the "I'm having trouble doing ...". I'm assuming this means you are some sort of real engineer :) :) OO is great. It does what it promises. It makes everything a whole lot easier to manage, makes your code more reusable, blah blah blah.

    However, I have lots of bad experience trying to get engineers to write good OO code. Nothing against y'all, but, conversely if you forced most software engineers (aside from a few savant freaks that I'm sure will chide me) to deal with the engineering problems you mentioned (that I have never heard of or forgot) we would probably die.

    What I'm getting at, I guess, is that OO rules. However, it's like linux, or repairing cars, or (ad infinitum). Being an expert rules, but it's not always worth the time to become an expert. You can't just jump in. Reading a few books helps, but I've read a few books, been doing this full-time for two or three years, had a very OO college experience, and most of the stuff I design and code is still crap.

    In addition, the code you are writing seems really unlikely to change. Write it procedurally, and write it well, and your grandkids will still be using that code because it would be too much of a pain to rewrite it to OO.

    I think you might be looking for an exemption. Here it is : use procedural programming for things that are tough for you to imagine in OO terms. Don't feel guilty. You will still never have as much crap code lying (laying?) around with your name on it as I do, and I do this for a living ;)

    --

    Jack Valenti and the MPAA are to technology as the Boston strangler is to the woman home alone

    1. Re:OO is Hard by LoveMe2Times · · Score: 2, Insightful

      Wow, I see one actually sane comment in this whole thread, and it's not even modded up. First off, let me state that the people that post on /. aren't necessarily the technological savants that you might presume them to be. You've asked a loaded question on a forum where you're guarunteed to have a poor signal to noise ratio: a lot of people have something to say, but the moderators can't tell who knows their arse from a hole in the ground. It might be fun for everybody to come out and rant or give you advice, because, hey, everybody likes to rant or think they know better than you. Ok, not everybody, but enough people to keep /. lively.
      Anyway, point is, as per usual, most of the posts here are arguments that probably aren't real helpful for you. I'm going to read between the lines hear and guess that you're real question is, "Should I bite the bullet and learn OO?" Now, you kind of have to make a choice (unless you're one of the lucky few that can have it all): do you want to be an engineer that programs, or a programmer that knows engineering? Let me put it to you this way: most professional programmers are average. Early proponents of OOP mistakenly believed that OOP would make programmers better, and this thought still lingers in many places. OO, like any problem solving paradigm, will help those who use it well and hinder those who wield it poorly.
      I'd like to try and clarify one other thing, too. A problem solving methodology like OO is just that. A problem solving methodology. And like any problem solving scheme, it has a lot more to do with how the problem solver thinks, and not so much the problem being solved. So, if you like OO, go for it. If not, don't. Either way, unless you really care a lot (or again, if you're one of those lucky ones), you won't be good at it. It won't help you get work done easier and there's a good chance that it will make your work more difficult.
      Besides that, all I can do is describe how *I* would solve your problems, which doesn't help you much. It would take you a long time to gain the expertise to understand my solution, much less how I got there, much less being able to get there yourself. There is no One True Way. Good luck!

  107. Engineering with OOP by epperly · · Score: 2, Informative
    My previous employer, Aspen Technology, Inc., markets some programs written in C++ using the concepts of object-oriented programming. They also market some programs that are largely written in FORTRAN. The C++ and FORTRAN programs are used by real engineers to solve real engineering problems.

    Many engineering programs use a combination of languages. For example, C++ is used for the high level programming and FORTRAN for low level the numeric kernels. Of course, you can write low level numeric kernels in C++ because it supports both OO and procedural programming. Often FORTRAN is used because

    • the code has already been written and tested
    • FORTRAN compilers can be optimized better due to simpler loops and different aliasing rules (note C may improve with the introduction of the restrict keyword in the C ISO 99 standard).
    • numerical methods gurus are more comfortable with FORTRAN
    • C++ is still not considered as portable as C or F77

    My present employer, the Center for Applied Scientific Computing, has Overture and SAMRAI written in C++.

  108. Sure it can by inspace · · Score: 1


    Just look at the speech synthesis project at sun.

    You can make your design to have plugable algorithms with OO design by applying the Strategy design pattern.

  109. Re:It Depends(ERROR CORRECTION) by chairmanKAGA · · Score: 1

    This line:
    "If you are just trying to solve an equation or have a program do one thing it is necessary to use OOP to get this done."
    should read like this:
    "If you are just trying to solve an equation or have a program do one thing it is NOT necessary to use OOP to get this done."
    Thanx.

    --
    "Allez Cusine!"
  110. DIffpack by rasmusb · · Score: 1

    Diffpack from Numerical objects: http://www.nobjects.com/

  111. Confused - need more data by Mandelbrute · · Score: 2
    OOP can be useful if you're trying to model something ... but it's not that great for say, solving a system of equations
    I don't know about you, but I see a mathematical model of processes or objects as a system of equations. How else do you describe them? If you are talking about sequences of events you should recall that those are also described by equations.

    I'm sure that OOP is useful in modelling, but more detail would be nice. Most people don't realise that the engineering problems solved on supercomputers are usually approximations, and increasing efficiency or available resources can improve those approximations. Even a mundane problem like the temperature distribution of someone jogging in wet trousers on a humid sunny day would need serious computing power, and there are a lot of problems more complex than that which can give useful results.

  112. OOP doesn't change the inner loop by iabervon · · Score: 2

    OOP is mainly useful for the design of large systems. Unless your language is being overly intrusive, there won't be anything OO inside the solution of an engineering problem like the ones you describe.

    The way OOP would apply to your problems would be when you're looking at the problem from more of a distance. You might have a situation in which some code wants the solution to a problem; the problem is specified by some other code, and it is solved by some other code, but there is a chunk in between that is doing something with the two parts (e.g., graphing them or something). You could make a "problem" interface, with a "solve" method, and various methods for getting information about the data. Then the intermediate code doesn't need to know what procedure to call to get the solution, because the problem object knows that.

    As for things like "solve a differential equation" or "solve a set of linear equations", OOP means that you're writing a big method instead of a big procedure. It's not a big deal. The real jump is switching to a functional language, where you write your code without side effects, and the compiler can do optimizations which change when code gets run and do not run the same code with the same data more than once.

  113. Not in the core.... by Anonymous Coward · · Score: 0

    I am using OO for an engineering problem (delphi). The core is just a bunch of functions. But the material-models are seperate objects and interchangeable.

  114. C++ is a bad language for understanding OOP by defile · · Score: 2

    I'm sure plenty of people use C++ to kick butt, but I personally never appreciated OOP until I used it in more high level languages.

    For something that's much more OOey, and easy to learn, try Python. I don't see any reason for new applications to be written solely in C++ nowadays. And the speed issue is irrelevant since you can rewrite portions of code in C (and quite easily, I was pleased to find).

    1. Re:C++ is a bad language for understanding OOP by tobe · · Score: 1

      A bit 'me too' but I figured I might as well..

      I *totally* agree with your comments re: no reason to write in pure C++ any more.. i'm finding it incredibly frustrating at the moment going back to working in a pure C++ shop after coming from a far smarter 'mixed-mode' environment.. it just seems *so* labour intensive...

      Actually.. does anyone out there use this kind of mixed-language mode of development succesfully.. I certainly have and was extremely impressed with the results.. or do we all still cling to the notion that pure C/C++ is the only 'pure' way to be ??

  115. Large Scale OO Engineering Programs by Anonymous Coward · · Score: 0

    Actually I work for a company that has a mix of PL/1, FORTRAN, VB, C, C++ and probably a few other things that are used to solve engineering problems.

    I have been working on the same project for eight years now and it was written in C++ from day one.

    The original engineering routines where written in PL/1 sometime in the 1980's. They involve an iterative solution for minimizing the end-user's cost and while maintaining at least minumum profit level to our business. The computations are very complex based upon what can be sourced by each of our manufacturing plants, optimizing material usage, minimizing freight costs and many other things. All of this is while meeting the design characteristics specified by the user and staying within all of the pertinent regulations.

    Initially the PL/1 was ported to C and involved a lot of straight table lookups. C++ was primarily used to encode the business rules and UI. There is a very complex set of rules as to what can be used in various situations and the user has great flexability in what they can request. As an example we may have three different products that can fill the same role for a particular component of a project, but due to certian engineering constraints only one may be available in that situation. If the user really wants to use one of the unavailable products then the software must direct them to how to make it available. This would not always be clear or obvious to the user. Each part of the product line has their own rules, requirements and costs. All of this is handled very nicely through class hierarchies and the polymorphism of C++. A well designed C++ architecture allows us to query our model for why a product is unavailable. Imagine clicking on a disabled control or menu in a MS Windows application and being told why it is unavailable and what your options are to make it available. That is just a part of what our software does.

    Now you are probably saying, but your engineering is still done in the ported functional PL/1 code. This is not entirely true. Over the years much of it has been replaced with OO C++ which has allowed us to offer a much wider choice of products and solutions to the end-user. Without the C++ infrastructure I would not want to try to fit new regulatory requirements or design methods into the software. But the way it is designed, doing this is simple. We have changed various components of the design engine over the years with very little impact to the overall software architecture.

    Our application has a very complex (from the programming standpoint) user interface, but it is very simple for the end user to sit down with, even if they only use it a couple times a year. The C++ UI and interface to the business rules and engineering components is very clean, provides an abnormally high level of feedback and information to the user including but not limited to drawings, reports, and renderings.

    It is worth mentioning that due to the OO nature of our model the same code is used for engineering drawings and for presenting an interactive 3D model on the screen. Once a programmer codes how something should be drawn, it may be presented in ways they never anticipated. The interactive 3D modelling was added six years into the project without having to make changes to the drawing routines for the various products and parts.

    Given the complexity of the software an iterative approach is the only one that is feasible for handling the engineering of out projects, but it benefits greatly from the OO design of the application. It does not have to know specifically which product is being used for a certain component, nor does it have to know what that products constraints or requirements are, it just asks the product for the information that it needs given certain criteria.

    I hope this makes some sense without explaining exactly what the software is or does. I wish I could go into specific examples and details but my employer would have a cow. I will try to review this posting and see what other responses crop up.

  116. CLOS object system by Anonymous Coward · · Score: 0
  117. Numerical Recipes and stuff by KjetilK · · Score: 2
    Well, I wouldn't recommend Numerical Recipes. It lacks rigor.

    I haven't looked at NAG, but you're not getting all the source code? Actually, I find it weird that one does rely on closed source in science, when science depends on the full disclosure of all relevant material. Well, the computations done is arguably the most important aspect of most analysis done today, so all source code should be available for public scrutiny.

    I would recommend R for many applications. It has some lightweight OO that is very efficient, it's a really beautiful language. It is also very rigorous, you will find the best things in Numerical Recipes there, but there is also a lot of code that has been through formal peer review.

    --
    Employee of Inrupt, Project Release Manager and Community Manager for Solid
    1. Re:Numerical Recipes and stuff by krlynch · · Score: 2

      Actually, I find it weird that one does rely on closed source in science, when science depends on the full disclosure of all relevant material.

      There's a very good reason much scientific computing is done using commercial libraries (very few are actually "closed" in the sense that when you purchase a site license, you actually get the source, just not the ability to redistribute or disclose changes you make, and you actually compile the source into your program; this is certainly not always the case, but it is for a very large number of specialized, closed libraries). For most of us scientists, code is a means to an end (getting a certain calculation done), not and end in itself (if I never had to write another line of code again to do my calculations, I wouldn't). Since coding ISN'T the goal, but a means to get there, we don't want to be bothered with "figuring things out" (like, how to use the software, whether the results will be reliable, etc. etc.) when we don't have to. We're generally looking for well documented, very reliable code, with a real programmer on the other end of the phone when the going gets tough, and we want the code fixed immediately when we find a problem or a place where an enhancement or extension will shave time off of our work.

      These are things that you really can't get in the vast majority of open source software (there are some exceptions, most of which are in the public domain at this point), but which is readily available from a most closed vendors that cater to the scientific community (NAG, ABAQUS, and one or two others come to mind as outfits I've personally dealt with that had excellent documentation and support. One time we needed to be able to produce curves in some MEMS, and the IC layout software didn't do that, as no one had ever asked for it; I called them, explained our predicament, and the next day they called back with a URL to download the updated library including our desired functionality. It was sweet :-). "Time is money" is no less applicable in the sciences than it is in business... perhaps even more so when careers can be so easily ruined by "computer glitches" that cause you to publish incorrect results....

    2. Re:Numerical Recipes and stuff by KjetilK · · Score: 2
      You're missing my point entirely. I know perfectly well that most of the software scientists use are open source, not in the sense of OSI, only that you get to see the source. Numerical Recipes is an example of this. Most of the code in IDL is open, so is most of Matlab.

      However, scientists should validate their results, and if they don't, referees should reject their articles.

      But you seem to have a much too high faith in the ability of refeeres to find such computer glitches. Most don't care, and even fewer have the ability, why? Because they aren't more concerned about it than the other scientists. If you've ever joined a conference in a relatively narrow field, you've probably met all the people who can possibly review your article. Do any of them look like they will make a big effort to check if you've used flawed code to you? There is a lot you can get away with, and computer glitches is certainly one of them. If you don't care about the code, why is it that you expect the referee to do it? You know, it's called peer-review.

      OK, an example: IDL is open source, most of it. IDL has the funny feature that it is supposed to detect underflows. Great. Well, I did a look around and found that a really reliable underflow detection system is either very difficult or very slow. So I did a look around, a long time ago, to see if I could find out how this was implemented, but I couldn't find something I could identify as "it".

      Yet, most put blind faith the underflow control. How can you do that?

      whether the results will be reliable

      I'm sorry, you can't get away with the attitude that "I don't care about the code". That's something for the suits. It is your duty as a scientist to check if the results are reliable. Even if coding isn't your goal (it isn't mine either, I'm an astrophysicist, and my code is just a few hundred lines, and I have carefully chosen the software I use to make my own coding simple but transparent), you have to understand the basics of computer science no less than you need to understand statistics if you use statistics, physics if you use physics, or biology is you use biology.

      For example, if you can't appreciate the flaws in Numerical Recipes, you shouldn't be using Numerical Recipes. Yeah, and does the penetration of NR tell you anything about if enough people care about the rigor of their computations?

      --
      Employee of Inrupt, Project Release Manager and Community Manager for Solid
  118. OOP is Good for Control Systems Problems by linuxdoctor · · Score: 1

    In engineering applications, I have found the principles of OOP to be most useful when my problem is not simply to solve a problem in modelling something, but in creating a system.

    Let me give a simple example. You have a vessel containing some liquid. This liquid must be maintained at a specific temperature and a there is a certain level. At the same time you have to allow for some liquid to be removed and new liquid to replenish it. This liquid must be removed at certain times, controlled by a certain algorithm, and replenished at other times. As well, the level of the liquid in the vessel must only be allowed to be now lower than (say) half full and no higher then (say) 75% full.

    You have guages and valves to control and monitor. As well you also want to be able to display what's going on in your system and have certain control over it (like overriding the low/high levels or the times that liquid is added and removed) as needed.

    This, in other words, is a control system. In my experience, control systems make ideal applications to be considered as OOP candidates.

    Naturally, this is a simple example, and in so-called real-life applications, the requirements are usually more complex. My experience tells me that the more complex a control problem, the easier it is to solve it using the OOP model.

    There are commercial packages you can buy that allow you to build control systems using OOPs and to be able to programme guages and set alarms points and what not.

    But all you were looking for was an example of an engineering app that are suited to OOP.

  119. Engineers aren't taught OO, so they don't use it by ajboyle · · Score: 1

    True, most engineering problems are solved with procedural code. But this is not necessarily because procedural code is the best tool for the job. At the University attended, the CS programmers were taught OO, and those with an engineering major were taught no more and no less than how to write procedural spaghetti code. But just because the majority of engineering classes teach procedural code doesn't mean that it's the best practice. - objects are great for maintaining/encapsulating state. - as problems get larger and more complex, they are much more easily solved/maintained using a basis of simple objects. "Complex systems that work are invariably built on simple systems that work" (paraphrasing Booch). - true, you can write lots of simple procedures, but they will almost always be more complex than they have to be because of lack of inheritance, encapsulation, etc. Of course, I know lots of people who write objects that are really nothing more than a bunch of spaghetti-code procedures packed in a class. But once you learn to do it right, there are very few problems that are better solved procedurally.

  120. Check out VTK by monopole · · Score: 0

    The visualization toolkit (VTK) (www.kitware.com) is a technical visualization tool with bindings to C++, tcl and Python. It is completely object oriented and modeled on a dataflow structure. You may well find it indispensable to visualize your results. VTK also provides an excellent model of how enginering data structures may be represented in a purely OO form. My personal experience in OO programming is primarily Python based with a strong emphasis on the use of mathematical operators to define objects and classes.

  121. Seems workable to me by Salamander · · Score: 2

    A lot of people seem to be forgetting that objects can be used to represent algorithms or protocols instead of GUI widgets or physical things, and that subclassing still applies. It's very easy to imagine, for example, a MonteCarlo class or a FiniteElement class with virtual methods for the equations to be applied to each element/unit/whatever. It's much cleaner and more maintainable than explicit dispatch tables and function pointers, and never even mind the cut-and-paste approaches that many scientific code is still based on. Various notational conveniences such as function overloading and default arguments could also be useful.

    Sure, the OOP literature tends to give different sorts of examples, but the basic tools are still useful if you just allow yourself to think in terms of relationships between algorithms instead of between actual objects.

    --
    Slashdot - News for Herds. Stuff that Splatters.
  122. OO Numerics is a research topic by CaptCookie · · Score: 1

    The short answer to your question is yes, OO techniques can be used to build better engineering (i.e. numeric) codes.

    The longer answer is that applying OO techniques have been adopted very slowly by the numeric computing community because there are some difficult problems in marrying the two that are still being actively researched.

    A very good resource for OO numerical computing is here

  123. Really, This is pretty easy to answer, by $0+31337 · · Score: 0

    just stop doing mechanical engineering problems.
    BAM! problem solved :)

  124. managing complexity by mauimaui · · Score: 1

    IMHO the value of OOP techniques is mostly for the management of complexity. In my experience these techniques are most useful when complexity arises from
    a) the problem domain for which you are writing software
    b) the process of software development and *maintenance*

    Loosely defined the problem domain is the environment into which your software will be deployed. The users of your software may be mechanical engineers, bank tellers, etc. They understand the elements of their environment quite well and frequently do not understand computer systems. OO design and programming techniques facilitate embedding the translation between these concepts into the software (as opposed to training the users of the system to do so).

    Two (related) exaples of engineering applications that benefit from OO techniques are computer aided design (CAD) and process simulation. OO techniques make is easier to create classes that represent the various elements of a chemical plant and proposed VLSI design and can evaluate interraction using different modeling techniques like those from the original example. I'm not claiming that one couldn't develop either type of system without OO techniques, they just make it easier.

    The process of software development can create its own complexity depending on the size of the project and resulting size of the development/deployment team. OO techniques facilitate the division of labor required to distribute a large amount of work over the members of a large team. In addition, by grouping code into segements that have similar rates of change maintenance effort can be reduced reletive to monolithic, procedural coding efforts.

    As someone has already stated the use of OO techniques is not limited to OOP languages. I'd argue that most of the value of the features added by these languages (reletive to their procedural ancestors) existed in techniques that predate them. Mostly these newer languages (C++, Java, et al) provide more efficient syntax and better enforcement for these techniques.

    In the end, however, if you a creating a few simple tools for your own use I think you should develop your software in whatever environment is comfortable. Also, these OO techniques do have a performance cost. Of course, software tends to last a whole lot longer than the original developers think (remember Y2K :)

    Ciao,

    Maui

  125. OO does not help with heavy number-crunching by Theovon · · Score: 1

    Number crunching and productivity apps are in two different worlds. The latter benefits greatly from OO because OO encourages consistent interfaces and code-reuse. The former often has no use for it. In some cases, where you are using things like matrix algebra libraries or any number of other tools, it may be of great benefit to use an OO language, just because the tool set benefits from being written in an OO language. But when you want to throw together a one-time use program which does a bunch of number crunching and where you're pretty much writing all of the code yourself, then it's better to use a procedural language which cuts away all of the OO wrappings and lets you get down to business. Furthermore, FORTRAN has been around SO LONG that it's hard to find a C compiler which can optimize as well. FORTRAN has always been used for heavy number-crunching, and as a result, its compilers have been optimized almost exclusively for that purpose.

  126. Books about OO programming for engineers by VegeBrain · · Score: 1

    I don't have any experience programming engineering problems period, much less doing it in C++. I read somewhere that strictly numerical problems don't translate very well into OO terms, so you might just be trying to apply a design technique that doesn't fit. On the other hand, it seems some people are programming engineering probolems using OO and publishing books about it. I went to the Barnes & Noble website and searched the book section with the keywords "numerical C++" and turned up half a dozen titles. Numerical Recipes in C++. There were links at the bottom of the web page that even looked more interesting, like C++ and Object Oriented Numeric Computing for Scientists and Engineers. Good luck!

  127. NASA uses Python by gragg · · Score: 0

    from <a href="http://www.python.org/psa/Users.html">pyt hon.org</a>

    <blockquote>
    Johnson Space Center uses Python in its Integrated Planning System as the standard scripting language. Efforts are underway to develop a modular collection of tools for assisting shuttle pre-mission planning and to replace older tools written in PERL and shell dialects. Python will also be installed in the new Mission Control Center to perform auxiliary processing integrated with a user interface shell. Ongoing developments include an automated grammar based system whereby C++ libraries may be interfaced directly to Python via compiler techniques. This technology can be extended to other languages in the future.
    </blockquote>

  128. C isn't functional; LISP, Scheme and Haskell are by Anonymous Coward · · Score: 0

    C's style is procedural or imperative.

    The terms are confusing, but functional implies more than just functions.

    Other examples of languages that _can_ be used in a functional style are Perl, Python, and Ruby.

  129. C++ vs C by h4x0r-3l337 · · Score: 1
    Why can't anyone show me an engineering application that is solved with an object oriented program?

    Because there is no engineering problem that can only be solved by OO programming. In my experience though, OO programming allows for much faster development and easier maintenance. As an example, I recently started a new job, and there, using C++, was able to do in a matter of weeks what the company had been trying to do for many months. The code is much cleaner than it would have been using a C-only approach. Unfortunately many people look at OO and/or C++ either as a solution that they want to use (for no apparent reason, they just want to use it), or as something that should be avoided because it is perceived as slow or bloated. Both viewpoints are incorrect. C++ is neither slow nor is it a tool that you *must* use because it is "better". It is simply a tool, and as with any tool, you should only use it when you a) know how to use it and b) it is suitable for the job at hand.

  130. I'll take a shot by f00zbll · · Score: 2
    Ok, using the example you gave the following comes to mind. Say you wanted to build a generalized engine that could support multiple business models and run n number of algorithms n number of times. From an OOD/OOP perspective, one might encapsulate the data with a generalized interface, and have engine that takes x object, x algorithm and execute the calculation or report back an error.

    Now the real question is "should you?" Probably not if you're doing scientific calculations. You're better off optimizing the code and writing detailed documentation than generalizing the structure. Like others have said, "OO is a tool." That's all it is, nothing more, nothing less. Try to think of it as building a house or an office building.

    There are reasons why office buildings have large open spaces with cubicles. This allow reconfiguration of the furniture to fit each renter's needs. For the same reasons you wouldn't try to cram 50 person company into a 4 bedroom house, you shouldn't force OOP principles on a problem that doesn't call for it.

    From your post, it sounds like you're interested in OOP, so maybe the question really is "should you get a new job that gives you an opportunity to find out first hand what OOP can do for you?"

  131. think about this by small_box_of_stuff · · Score: 1

    What is OOP? Its a way of abstracting a problem in to something simpler that is easier to work with.

    What is mathematics? Its a way of abstracting a problem into something simpler that is easier to work with.

    Rather than work with the actual quantities of things in question, we can abstract them to numbers. Rather than work with actual processes and physical things, we can work with mathematical representations of these things, equations and procedures.

    This is very similar to what oop does. Rather than work with piles of unabstracted data, we work with abstracted data in the form of objects.

    But if the problem you are trying to solve has already been abstracted after years of work in to a nice set of equations and processes, whats the benefit to abstracting it further? The math is already an abstraction, and a good one at that.

    So in this type of problem, the most natural abstraction is already there, the math, and can be used directly in a non oop way. adding an unnatural layer of abstration overtop of that one will likely just make things more work.

    Thats not to say that the overall structure of the program cant be improved by the abstraction and orginization that OOP can bring to the table, but the actual calculations, the math, is already a huge level of abstraction over the real entity anyway. Why add more to it?

  132. mathematica? by Anonymous Coward · · Score: 0

    What about mathematica? I swear that bad boy can solve any problem...

  133. OOP/Procedural/Functional by mikera · · Score: 5, Informative

    I have always thought of OOP as fundamentally a procedural programming technique but extended to give you better ability to organise and manage larger projects. C++ is a superset of C - you don't have to use the OOP features but they can help you enormously in the right situation.

    OOP also encourages good programming practices like producing well-defined interfaces, implementation hiding and code re-use. I actually think these are crucial to the effectiveness of OOP. These are all good things, and I'm sufficienctly lazy that I would never write anything other than a trivial program in purely procedural style.

    However, OOP is still best suited to particular domains. Modelling, GUIs, enterprise applications, games etc. are perfect because they all require the manipulation of discrete and readily identifiable "objects" that map onto the OOP model very well.

    If you're writing network drivers, you could use OOP, but as other posters have been keen to point out the (very small) overhead of most OOP languages actually becomes a problem for very low-level code. Hence OOP isn't so well suited for OS kernel code, network protocols, hand optimised inner loops and embedded applications.

    The difference between procedural and OOP is mainly a trade-off between low level control of the machine and having a semi-automated system to manage the complexity for you. Interestingly, for larger projects, good programmers in procedural langauages often end up having lots of function calls that take the "object to be acted on" as an argument and are therefore effecively emulating method calls. Once they start putting in switch statements in those functions to branch on the type of object encountered, they have effectively emulated virtual methods.

    Your case is an interesting one. You are dealing with mathematical/engineering problems that are often tackled in a procedural style.

    If you're feeling adventurous, I would actually suggest you head off to look at functional langauges. Reason is that these langauges are ideally suited for representing functions and other mathematical constructs, just as OOP is geared towards representing and manipulating "objects". Haskell would be my no.1 choice if you're looking for elegance and flexibility, O'Caml if you are more concerened about raw performance.

    If these seem too radical a departure, then I still think that OOP could make sense for a major project. You probably wouldn't need inheritance, but implementation hiding can be very useful. Let's say you're modelling fluid dynamics, and do it procedural style with a big array. Works fine until you decide that in fact you want to store the data in an octree so that you can get a couple of orders of magnitude better resultion in the particular areas you are interested in. At that point you have to change everything that accesses the data structure, including the 100 or so simulation programs you've been developing. Not fun. If OTOH you had encapsulated it all in an object, you would just change the object's private implementation, keeping all accessor methods the same (e.g. getFluidVelocity(x,y,z), getPressure(x,y,z) or whatever, I'm not an engineer :-). In this case, all the code that used the object would remain the same, possibly saving you a load of work.

    It's also often useful to have data represented as objects just so you can do useful things like pass the around, build larger data structures etc. Not that you can't do this in procedural style, but OOP takes away all the pain. I've lost track of the number of times I have taken advantage of all the useful features like object serialization in Java, which saves you all the hassle of having to write import/export functions to store your data structures on disk.

    Ultimately, use what seems right for your application. But remember that OOP and other techniques such as functional programming aren't just fads, they are ways to solve problems that procedural style just isn't well suited for. If you find yourself spending too much time writing the "glue" to hold a big application together, then it's a good sign that you've actually picked the wrong tool.

    1. Re:OOP/Procedural/Functional by elflord · · Score: 2
      I was hoping someone would mention functional programming. I'm developing a system for numeric computation, and one of the difficulties is to create a user-friendly interface in an interpreted language for doing various forms of function composition, and binding. One of the problems is that the users will want to use friendly, dynamically typed interpreted programming languages, but iteration in those languages is slow, and that means that it's necessary to think about things like applying functions to ranges (or bounding boxes) While the implementation languages I'm using are non-functional (C++ and python), I'm learning SML/OCaml, and trying to think like a functional programmer.

    2. Re:OOP/Procedural/Functional by marcovje · · Score: 1


      A lot of problems in engineering still use a lot of
      computational time, contrary to other domains where
      speed isn't an issue anymore.

      OOP programming is often slower than purely procedural, though a lot depends on the programmer (but will eat into ease of use)

      I'm not 100% sure about the intrisic speed of functional programming, maybe you could make some comments on that?

      How fast are current implementations, and are there reasons why proper functional programming would be systematically slower than proper functional programming?

    3. Re:OOP/Procedural/Functional by mikera · · Score: 2

      Some functional languages can have a quite large overhead depending on which advanced features they implement.

      Haskell, for example, uses lazy evaluation, which means that calculations are done "on demand". This has a memory/performance overhead because it needs to save the calculation to be performed at a later time.

      But this also buys you big convenience / elegance advantages that you don't get in other languages. With lazy evaluation you can define and manipulate infinte-size lists and trees, because you know that the actual values will only get created when you ask for them.

      Other non-lazy functional languages can get very near to optimal speeds. Check out O'Caml for example, which is much more tuned towards creting very fast functional code and can certainly match C++ if you know what you are doing.

  134. There just very expensive!!! by Anonymous Coward · · Score: 0

    A 4/5 years ago I took an open university corse on software design and the like... (computing and object oriantated approach).

    The main content of the corse was small talk.
    I remember a video for the corse where someone was using a OO CAD application for designing buildings, each object not only new about it's cost etc.. but health and saftey regulations, construction time.

    The whole thing ended up in detailed construction and deconstruction plans for the building, all the health and saftey documentation.

    I can't remember what the application was called, but it seemed very good, especially for 4/5 years ago.

  135. Please, say it with me by Xenophon+Fenderson, · · Score: 1

    _technology_or_methodology_ is not a silver bullet. It will not magically turn bad managers into good managers, or poor programmers into competent programmers. It will not stop balding. It will not improve my sex life. I cannot solve the halting problem in polynomial time using _technology_or_methodology_.

    What _technology_or_methodology_ is, is a useful tool for certain problems, and I will use it as appropriate to improve my communications with other human beings, which is what programming is really about. I will not dogmatically use _technology_or_methodology_, and I will keep an open mind to new ways of expressing myself and solving problems.

    --
    I'm proud of my Northern Tibetian Heritage
  136. Use Object Oriented technology for maintainability by mscherotter · · Score: 1

    We use object oriented technology (C++) specifically for its constructs that allow a better large-scale, long-term project development cycle. Ideally, it lets us develop software by addition and subtracting code modules instead of modifying existing ones.

    --
    Work as if you might live forever, Live as if you might die tomorrow.
  137. OOD or OOP? by flumps · · Score: 1

    'scuse me, but are you interested in OOP, or OOD?

    These are completely separate topics. You can design a program using the OOD approach, and not write it in an OO language, and you can write an OOP in C++ but not use any OOD.

    So which is it?

    Assuming it's OOD, you can use this technique in engineering problems to solve things like concurrency or identify interactions between/properties of "objects" or systems that would be too difficult to identify if another approach was used. However, like any tool, it will only be as useful as the application of it will allow; hammers and screwdrivers come to mind. If you're looking into things like RTS (real time systems) OOD may have its uses but nothing beats a good circuit diagram for clarity.
    Assuming its OOP, what are you trying to acheive? Obviously, you will have to use OOD to design your system (one would hope so, anyway) but what is your system trying to acheive? Its no good trying to force a screw in where a pin would do. OOP allows reuse of code, clarity of code, and happens to be useful for organising your program as well. However, if you only have 2k of memory, whats the point?

    You need to think about your application before you commit to a design/programming methodology. Sure, OOD and OOP don't always fit the bill, and they may not be right for you. But thats why you have to do an analysis of the system, perhaps applying OOD to it, and if you fail, try some other approach. After a while it comes with experience.

    --
    "So there he is, risen from the dead. Like that fella, E. T." - Father Ted Crilly
  138. Inertia by karlm · · Score: 1
    I think the main problem is inertia. There's still lots of libraries writen in FORTRAN77 and C. Were you even taught F90? I think my brother was taught F77 two years ago.

    There's also inertia in the teaching world. What percentage of the Mech. E. professors were arround before OOP was widely accepted? How many of them have gone back and learned to do OOP properly? If the profs and masters of industry haven't learned OOP, then the advanced codes will be in C/F77. You go to learn about the advanced coding, and you end up learning how to do all of the advanced stuff in functional languages.

    For the beginning student, the fastest way to learn to code up some problem is C or Java with only one object. Once a student is proficient in one language, most of them will push as far and fast as they can in their subject matter instead of learning to code better or learning a new language.

    OOP is mainly necessary as a tool to clean up large programming projects to make them manageable and to help keep you from hurting yourself through disorganization. OOP really shines when you're doing a lot of dynamic allocation and freeing of data, as destructor methods are a big help in preventing memory leaks. The really big Mech. E. codes (FEA) are gigantic matrix inversions. (There are some other methods, but FEA is by far dominant.) There are plenty of C and F77/F90 libraries out there to handle the messiness of matrix manipulation for the coder. And, truth be told, matrix manipulation is not messy at all by comparison. You have a large ammount of memory allocation at the beginning of the executable, but then you just manipulate the data you have for a while, save your results, and exit, perhapse without even free()ing your matricies.

    On the extreme end, some people may not want to take the small performance hit in going from C to C++. For compuationally intensive tasks, I believe you still take a 10x hit going from C/C++ to Java. The MIT 6.270 Lego robotics contest still gets won by teams that use purely mechanical methods of steering (the winner ~3 years ago) or use a single java object and do functional programming inside that object. The boards are still a bit too underpowered to pull a full JVM on top of NetBSD and not care about the various OOP overheads. Some teams use huge switch statements to virtually illiminate method calls. For small projects, this can be done without sacrificing too much robustness, and the performance gains are noticable.

    --
    Copyright Violation:"theft, piracy"::Anti-Trust Violation:"thermonuclear price terrorism"<-Overly dramatic language.
    1. Re:Inertia by rarose · · Score: 1

      You nailed it on the head. There are multiple tons of debugged Fortran code for solving all sorts of engineering problems. The people using this code are looking to solve problems, not write neato computer code to solve problems and so there is actually a disincentive to write new code.
      Remember these folks are concerned with the elegance of the resulting bridge... not with the code that tells them said bridge will survive. :-)

      --
      --Rob
  139. What I've used OOP for. by Christopher+Thomas · · Score: 2

    Problems of the type you descripe wouldn't benefit much from OOP. I'd solve them myself in C, but that's mainly just because I don't *know* Fortran (fortran is very good at math problems with straightforward methods of solution, and parallelizes easily).

    My most recent project, on the other hand, involved simulating a computer system (I won't go into detail; wait until after I've published). This is a perfect scenario for OO - a computer system is built up out of many parts, many with similarities, but with different implementations. If you need a cycle-by-cycle or event-by-event simulation of a computer system, it makes sense to build up models of all of the parts that will be interacting and put them into an OO hierarchy. This lets you avoid copying code, and lets you change things much more easily than in a straight C environment.

    In a previous project, I was building the skeleton for a program that would have to be rewritten for many different purposes. Some parts would stay the same between instances, and these were what I was building. I made the mistake of writing it in C, with the idea of upgrading it to C++ later. I ended up faking OO-isms by calling function pointers hither and yon to abstract things. When maintenance of the project was finally turned over to someone else, they started the migration to C++.

    In a complex program where you have a lot of abstraction going on between different types of component, an explicitly OO language will almost always make life much easier.

  140. MOD THIS GUY UP!!! by Dan+Ost · · Score: 1

    This guy has described OO in as clear and
    accurate language as I've ever heard.

    Moderators, do what you must do.

    --

    *sigh* back to work...
  141. One Word - Labview by zappaforpresident · · Score: 1

    Engineering solutions via GUI

  142. Re:OO isn't Hard by KjetilK · · Score: 2
    Well, I'm an astrophysics student, and not really even a hacker, though I have made a couple of hacks that people have thought have been good. But I think that given a language where the concepts are clear, OOP isn't hard at all.

    The reason why I learned OOP is pretty much that I had to. I'm at the University of Oslo in Norway, and OOP was invented here and implemented in SIMULA. So they really forced us to use SIMULA and program OO, but in just a couple of basic courses, so I didn't a prolonged forced exposure.

    Examples where OO concepts are clear include SIMULA and the S system (my favorite implementation R). SIMULA is a full-blown OOP system (but there are various reasons why it failed), while S has just a few OO features, but the features that have been implemented are easy to understand, they incorporate some essential concepts, and they are very powerful.

    Then, you have C++ which is also a full featured language, but where the concepts are not that clear and easy to grasp.

    When OO gets muddy is usually when it is built on the top of existing languages. Perl OO is a bit muddy, but not too bad, but if you look at e.g. IDL it gets rather bad IMHO.

    --
    Employee of Inrupt, Project Release Manager and Community Manager for Solid
  143. Here's a Real Life example: by Doug+Merritt · · Score: 2
    I found OO and C++ to be very helpful in a signal processing package I did some years ago. It performed FFTs, fast cosine transforms, correlation, cepstral analysis, graphing, etc to support experimentation with audio and voice analysis/recognition.

    I started out in C, but converted to C++ when it became clear there would be a serious advantage for that particular code.

    Looking at the header file, I see that I ended up with a class SampleInfo that contained basic info like the sampling rate and a dozen other items of interest. This basic type was useful as a parameter to constructors and converters throughout the package.

    Then there was a class HeaderInfo, which inherited from SampleInfo. It added information such as whether the data was a stream of bytes, complex numbers, or in phase-magnitude form.

    Using that starting point, several other classes inherited from HeaderInfo to add still more specialization: VectorHeaderInfo (information about an array of arrays of samples) plus associated implementation classes: ByteVector (just an array of samples of type byte), ComplexVector, ComplexVectorOfVectors, etc.

    The class hierarchy and associated inheritance doesn't sound especially impressive, but it immediately cleaned up the code and made it easier to experiment and easier to find certain kinds of conceptual bugs.

    Actual transformations were made easy by always returning a pointer to 'this', so a typical usage would look like:

    Audio recording(SampleRate);
    ByteVector bytes_in.record(recording);
    ComplexVectorOfVectors data(bytes_in);

    // Slashdot formatting is peculiar here,
    // read as "data.zeropad()":
    data

    .zeropad()
    .window()
    .fft()
    .accentuate()
    .scale()
    .show_color_spectral_analysis();
    exit(0);

    This style of pipelining data through transformation stages makes experimentation a breeze...just insert/delete pipeline stages.

    Even design of core algorithms like fft() itself benefited somewhat from reimplementation in C++, although the benefit there was a little smaller.

    Basically the added value of OO is small (but non-zero) if you look at converting just one function implementing a single numeric technique, but becomes larger and larger as you implement a family of related techniques, such as matrix arithmetic, multiple transforms, diff eq techniques, etc.

    P.S. the biggest optimization advantage for using Fortran is on things like vector processors. And in any case, the right way to optimize is to re-code only inner loops. Thus one could have a package written mostly in C++, but with inner loops recoded in Fortran, if necessary.

    Coding whole apps in Fortran is neolithic.

    --
    Professional Wild-Eyed Visionary
  144. Other folks work by Anonymous Coward · · Score: 0


    The information technology guys at NIST (Pozo et al.) have done a lot.

    http://math.nist.gov/tnt/

    The template numerical toolkit is supposed to allow one to write C++ that looks more mathematical in appearance.

    e.g. X=A*M*B;

    where A and B are vectors and M is a matrix.

    OOP, in a broad sense, is used to abstract away the actual implementations of vectors and matrices. Since the naive and most general implementation is too slow, something like the strategy pattern is used to call the most efficient algorithm. For example, if M is huge, but upper diagonal, you can save yourself a lot of time by picking the right method. TNT does that for you depending on how you instantiated the vectors and matrices.

    C++ buffs may get a kick out looking at the source. Numerical people should look at it to understand that templates, although tempting, don't solve every issue and create a lot of their own!

  145. Re:Perhaps the computational power is to be questi by Anonymous Coward · · Score: 0
    I am repeateadly reading this '..OOP must be useful for GUI/UI/anything-but-what-i've-been-doing-in-C' mumbo. I guess that people think that C++ must be good for something but since I'm not using it for the stuff I do, it must be good for the stuff I have no idea about. Well, I've done a bunch of C++ and C. Both are good for GUI as well as computation. After all, classes can easily be emulated in C with structures with pointers to functions.


    There is but one small difference between the two languages. Speed is not it. Granted C++ does have a small overhead. But nothing compared to the difference between other languages like java and some others... For my purposes, and yes I do use C++ and C in large scale programs that take weeks to run, I make no distinction in speed.

  146. time by Anonymous Coward · · Score: 0

    time is a mjow advanage in oop, you can save days for every week of work.

    1. Re:time by giantsquidmarks · · Score: 1

      yeah... Not only is OOP unable to solve engineering problems... it cannot even quickly and efficiently solve computer programming problems.

      Just learn C and Perl... then call it good.

  147. Absolutely, OO == features that sell! by FloatingBlimp · · Score: 1

    Been there and done it...
    I wrote CAD software for five years and simulation sofware for another six and I guarantee that if you master what makes OO useful, you can shine. The main difficulty is getting this type of code past the old timers who swear that fortran is it and will be it for ever but then start using the latest OO construction that exist in fortran 90 (or who knows what the latest number is).
    Using OO you can create bridges that would cause a complete redesign in a procedural language. Those bridges end up as features and that is what makes the difference! Look into the leading commercial CAD or simulation software out there, I would bet that most is OO because that is what allowed the features that people bought

    1. Re:Absolutely, OO == features that sell! by Anonymous Coward · · Score: 0

      Performance performance performance... that's one of the many reasons we old-timers swear by Fortran. And yes, it is entirely possible to do OO design with Fortran 95, and Fortran 200x will add even more capability in that area.

  148. Flowrate: Re:Complex Question... by angel'o'sphere · · Score: 2, Interesting

    You wrote:
    squarepipe.calculateFlowrate
    seems no easier to remember than
    squarePipe_CalculateFlowRate()
    or
    CalculateFlowrate(SQUAREPIPE,...)
    Also, if you have generic functions across all classes, you are left with a bizarre model of pipes, bowls, steam generators, and anything else having to be under some umbrella so you can attach a "SurfaceArea" or "Volume" calculator or some other generic routine.

    Well and what about this:
    // I don't know if you use square pipes
    // or round pipes ...
    // or oval pipes ...
    calcTotalFlowRate(Array_of_Pipe* pipe) {
    double sum = 0;
    for (int i=0; i leth_than pipe.length; i++) {
    sum += pipe[i].calculateFlowRate();
    }
    You wrote:
    I've also never been a big believer of the whole "code-reuse" argument.

    I say:
    Then write my above loop in C ... ignore the fact that I used a template ( angle brackets got stripped by the formatter :-( )of course ...

    For the problem you are bringing up: adding later a SurfaceArea calculation, OO is exactly THE solution.

    And if you are to tired to modify all classes where a calcSurface method would be needed write a Visitor. OOPS, thats a design pattern ... read: "Design Patterns", Elements of Reuseable Design, Gamma et al., Addison Wesley, 1995.

    Regards,
    angel'o'sphere

    --
    Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    1. Re:Flowrate: Re:Complex Question... by geekoid · · Score: 2

      except different thing need different formulas for real world flow rate.

      This is a problem with every OO, they mimic the world on a perception basis and not on an actual use bases.

      The only use of OO I have ever seen that makes it practical is in big contracting house where they have so many class you can can find something you need, buteven then they still require "tweaking"

      --
      The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
    2. Re:Flowrate: Re:Complex Question... by PD · · Score: 2

      The way he described his solution, he HAS allowed for different formulas for the flow rate.

      To put things into C terms, he's got a whole set of functions that do different calculations. He's also got a whole set of pointers to those functions.

      At run time, the type of the object is examined, and the right function pointer is used to call the right function to do the right calculation.

      This is very standard practice when programing in C. I used to do it all the time. The only difference here is that C++ gives a language construct to make the bookkeeping easier.

    3. Re:Flowrate: Re:Complex Question... by taliver · · Score: 1


      calcTotalFlowRate(Array_of_Pipe* pipe) {
      double sum = 0;
      for (int i=0; i less_than pipe.length; i++) {
      sum+=calculateFlowRate(pipe+i,pipe[i].type);
      }

      Done.

      --

      I demand a million helicopters and a DOLLAR!

    4. Re:Flowrate: Re:Complex Question... by dmelomed · · Score: 1

      And a functional language makes this even easier with pattern matching where a different function is executed if it matches a set of parameters, for example:

      -module(mathStuff).
      -export([factorial/1, area/1]).

      factorial(0) -> 1;
      factorial(N) -> N * factorial(N-1).

      area({square, Side}) ->
      Side * Side;
      area({circle, Radius}) ->
      % almost :-)
      3 * Radius * Radius;
      area({triangle, A, B, C}) ->
      S = (A + B + C)/2,

      math:sqrt(S*(S-A)*(S-B)*(S-C));
      area(Other) ->
      {invalid_object, Other}.

    5. Re:Flowrate: Re:Complex Question... by Mr.+Shiny+And+New · · Score: 1

      This type of programming is not really a good style. It works, and the calTotalFlowRate() function is nice and small, but it makes it hard to maintain. For example, let's say you know of 10 kinds of pipes. now you want to add a new pipe. with your code, you have to examine each function that operates on a pipe, and add a new case to it. with OO programming, you just add a new class. The new pipe can be totally different from the old pipes, or it can be similar (in which case it might make sense to inherit... round pipe is a special case of oval pipe).

      Also, another big advantage of OO programming is that someone else who uses the code (not the original author) can add new kinds of pipes. Let's say you are selling a modelling tool. Your customer might want to model their own, special pipe with your tool. with OO programming it's easy: just add a new object. the modeling tool doesn't need to care. with procedural programming it's hard, since every procedure needs to know how to deal with every type of pipe at compile time.

    6. Re:Flowrate: Re:Complex Question... by taliver · · Score: 1

      with procedural programming it's hard, since every procedure needs to know how to deal with every type of pipe at compile time.

      No, only the procedures that you need to use need to be modified. If you don't need them, you don't change them. And changing procedures vs. writing new ones is an argument of a different sort, and can go either way as far as ease of use/ease of change.

      You haven't saved any time in either case, and if you are using special cases, you can easily write macro wrappers (for example, making a round pipe from an oval pipe by

      #define ROUNDCALC(r) ovalcalc(r,r)

      )

      So, yes, there are certain places OOP is a nice way to do things, but I think tying yourself to that mindset is a bad plan.

      --

      I demand a million helicopters and a DOLLAR!

    7. Re:Flowrate: Re:Complex Question... by angel'o'sphere · · Score: 1

      taliver wrote:
      calcTotalFlowRate(Array_of_Pipe* pipe) {
      double sum = 0;
      for (int i=0; i less_than pipe.length; i++) {
      sum+=calculateFlowRate(pipe+i, pipe[i].type);
      }

      Done.

      And I say:
      Either its wrong, sorry I did not ask for a correct and working solution, or you have a huge switch inside of your function calculateFlowRate switching depending on the type.

      So, question as excercise to the reader: what is faster, the original loop I posted some comments before or the loop calling the function with the big switch.

      Another question: what is faster for 100 cases? And how does it scale if the cases increase? Lets say to 1000?

      Regards,
      angel'o'sphere

      P.S. the true question is: what is faster to write initialy to get it to market and what is cheaper to maintane ...

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    8. Re:Flowrate: Re:Complex Question... by angel'o'sphere · · Score: 1

      You wrote:
      So, yes, there are certain places OOP is a nice way to do things, but I think tying yourself to that mindset is a bad plan.

      And I say:

      I brought up the loop example calling a virtual method of teh pipe for one reason:

      Its a perfect example whre OO makes fully sence. I find it funny that you try to sue my perfect example to convince us that OO makes no sence.

      In fact oyu are right: there are situations where class you do not use a object and a virtual fucntion/method.

      However finding a place where OO is wrong applied and procedural programming is BETTER is hard.

      I did not see any in my last 12 years of programming.

      And I say it again: give me a procedural program and I write you an equivalent one using OO which is FASTER.
      I also write you a different one which is more maintane able.

      To complete the ironic circle: give me any OO program and I write you a procedural one which is FASTER :-)

      However, its hard to write a more maintaneable procedural program than a OO program written with maintaneability in mind.

      I emphasized in a different post: not having the mindset of OO is a bad plan, I admit trying to IMPLEMENT in OO what is complicated to implement in OO, is wrong. Thinking in OO is definitly the easyer and better and faster way to craft software than thinking in procedures. Functional gurus would say: yes, and thinking functional is even better. You can implement it anyway in procedures AFTER you designed it with OO.

      And my loop example proofs me right, my loop is easyer to read than your loop.

      My loop is easyer to maintane, than your loop.

      My loop is faster than your loop. If the number of cases in fact meets the 1000 range it is significant faster. (BTW: my loop is constant fast independend of the number of cases)

      Regards,
      angel'o'sphere

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    9. Re:Flowrate: Re:Complex Question... by taliver · · Score: 1

      Well, let's compare.

      For the C++ version, I have to do a lookup of what the object is, and then a lookup of where the function is that is being called, and then run the code. So, we're probably looking at 2 memory references, and an indirect jump.

      For the switch case, I have one memory refernce to determine type, and then a second refernece into a jump table. Thus I have 1 memory reference and 1 indirect jump, plus the original call to the function.

      So they seem to be very similar in the number of jumps and lookups required. Thus I don't think it would even matter if there were 1000's of cases (but my function would be very long and messy).

      And if the true question is to write faster, you'd have to look at your programmer's style, which is the same for maintaining. If I spread by objects around 50 different files in some haphazard method, then it really doesn't matter which language you're coding in, they both suck for maintanance.

      --

      I demand a million helicopters and a DOLLAR!

    10. Re:Flowrate: Re:Complex Question... by PD · · Score: 2

      You are correct. Increasingly, I am programming C++ in a functional style. It all started when I learned STL and its generic programming.

      So, nowadays when I want to apply a class of related functions to many different objects, I am just as likely to use a function object coupled with a STL container instead of a polymorphic solution.

    11. Re:Flowrate: Re:Complex Question... by angel'o'sphere · · Score: 1

      Hm ...

      you are right regarding an oo dispatch.

      Basicly you have an array with pointers to functions.

      An object has a pointer to that array.

      So the C++ code would be 'translated' to C like this: object->function_array[method_index]();

      That means of course two memory accesses to get the adress of teh function.

      However with your analyisis for the switch statement you are wrong.

      Lets assume the simple case: you have consecutive indices: e.g. 7 cases from 3 to 9.

      Then of course the compiler can be smart enough to also generate an array with 7 entries of jump addreses.

      However it is very likely theat you will have non consecutinve indices, especialy if you are working in a team and you are realy approaching the 1000 mark.

      Then the compiler will generate an array of tuples, compare value and jump adress.

      If the compiler is smart, the tuples are sorted by compare value and you can use binary search to find the correct entry to jump to.

      However even with only one single entry (well to force the compiler to generate such a table you would need two entries) that approach is slower than a function pointer table.

      Lookup:
      One access to fetch the table, like the fetching of the table of methods for an object.

      Find Entry:
      One access to fetch the value to compare with.
      ---> here we allready ahve the function pointer in case of C++.

      One access to get the function pointer in case of a match.

      Go back to "Find Entry:" in case of missmatch.

      You need three memory accesses for imeditaly success and ld n accesses plus two in case of n cases.

      For a virtual function call you allways only need *two* memory accesses.

      Your argument about maintance is in some cases right and in others not.

      In the cases where it is right you would use a design pattern: Visitor.

      That one doubles the number of memory accesses in case of an OO approach but would still be constant and independend of the number of classes or methods involved.

      Amortized over big method numbers per class and number of classes (greater 8) a Visitor design pattern is faster (especially as procedural approaches increase in time complexity with the number of cases).

      Regards,
      angel'o'sphere

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    12. Re:Flowrate: Re:Complex Question... by taliver · · Score: 1

      Then do the loop with pointers to functions, since you can just as easily implement it in a procedural language.

      In fact, you can carry around any information want, call it whatever you want, and then do it however you want to. (Although this has more to do with weak typing than procedural).

      OOP is a mindset. Another poster mentioned that you can write OO style in C. He's right, you can. About your example, sure, you can add up the flowrates across dozens of different types of pipes. And if you want "constnat fast", then set up a function table.

      I will also point out, that these function tables of yours must always be used. So EVERY call has two references. Now we kind of need to look at what the common case is, and determine if this "add across all pipes" is what we do most often. If it isn't, then we have a lot of pain all the time for not much return.

      And it could also be the case, as it is in most instances, that only one procedure is needed, since we hand in a finite element mesh to begin with. We might also note that there are two cases:

      1) We have a butt ton of procedures, and thus a butt ton of calls. Most likely in loops. Now we have to pay for your constant lookup. And I still have a bunch of functions that don't make sense to apply to every object.

      2) We have very few calls. In this case we have very few procedure, and thus don't have to worry about maintaining across groups of functions.

      Something that has gotten lost in this argument is that often in engineering, you don't have functions that apply across large groups of objects. You simply take data, put it through some matrix operations, render it, and then spit it out. Thus you don't need "render class" and "matrix class" and any other class to get things done. Procedures in engineering are often to break up one long piece of code into smaller chunks, but they aren't called randomly or otherwise.

      --

      I demand a million helicopters and a DOLLAR!

  149. OOP Is Not A Magic Bullet... by Greyfox · · Score: 3
    There's still a lot of hype out there about how OOP can solve all your problems and it can actually solve a lot of them. The problem is it introduces a completely new set of problems that you will be completely unfamiliar with. The folks pushing OOP don't tend to mention that.

    OOP requires a different organizational view of the problem you're working with. I've seen a tiny few people coming out of college who appear to have been introduced to the necessary concepts in college. For old school programmers or people whose degree program was still geared toward 1970s era, there's going to be a learning curve. Moreover you can't just go off on your own and start programming in C++ or Java willy nilly. You'll just reinforce bad habits while not developing any good ones. A year in a shop with good solid programmers who are willing to mentor you would probably give you a pretty good feel for what works and what doesn't. Assuming you're willing to really study the dicipline.

    One of the first things your mentors will probably tell you to do is go out and get a few books. Design Patterns, Antipatterns and Refactoring books make good introductory reading. None of these things are magic bullets either, and you should refrain from viewing them a such. If you don't have Programmer Nature, none of that stuff will help you.

    After all that you'll be able to write code that should be easily maintainable and flexible for new problems. Whether or not that will actually solve the problems you want solved is another question entirely.

    --

    I'm trying to teach myself to set people on fire with my mind... Is it hot in here?

  150. Use FORTRAN 77 and C++ in the same project! by coult · · Score: 1

    The primary advantange of Fortran is its incredible compilers. Fortran compilers can handle all sorts of optimizations automatically that can't be done by most C or C++ compilers.

    On the other hand, managing complex data structures is a beast with Fortran (who wants function calls with 75 arguments? I've seen it done).

    The best solution is to use OOP languages (C++ being the prime example in scientific computing) for handling the data structures, dynamic memor management, I/O, UI, etc. and use Fortran for all the inner loops where 90%+ of the execution time is spent.

    --

    All is Number -Pythagoras.

  151. As long as econometrics is a science... by doublegauss · · Score: 1

    you can actually gain a lot from OOP in scientific applications. Beware: IANASC (I am not a serious coder). However, I am an econometrician (for the majority: roughly speaking, halfway between an economist and a statistician) who often does his estimations in high-level languages such as Gauss or Ox rather than using prepackaged solutions.

    In the last two years I have been using Ox quite a bit, whose syntax resembles C++, and encourages the use of objects. My eperience is that performance and ease of code writing are comparable, but what really makes the difference is code maintainability: once you've got something that works, WHAM!, you wrap it into a class and forget about it. With other packages, the population of global variables and such made it a nightmare to go through code you had written months earlier and re-use it for a related task.

  152. Using Objects by fm6 · · Score: 3, Informative
    What makes OOP powerful is its ability to create powerful application frameworks and component libraries. Now few programmers have the interest or skill to create these things, but we all can excellent use of them. The hard part is understanding OOP systems from the later point of view. They tend to be designed and documented by people who think in terms of building the system, rather than making things with it.

    The first OOP system I ever used was Digitalk's Smalltalk V, a quite successful adaptation of the ur-OO language to DOS, and later to 16-bit Windows. I was impressed by its power and expressiveness -- and frustrated by the difficulty of dealing with the huge mass of new concepts. It would have been much easier if there were a clear distinction between things I needed to know in order to extend the framework, and things I needed to know in order to create applications.

    Anyone interested in OOP should download one of the many Smalltalk implementations available just to play with it. But there's a limit to the serious work you can do. There are still Smalltalk developers out there, but most people just don't have the mindset.

    Modern OOP systems are mainly extensions of procedural programming languages. This disgusts OOP purists, but makes for a more shallow learning curve, and helps sharpen the distinction between features for designing objects, and features for using them.

    C++ is the fanciest of these. But it's extremely complex, and should be approched slowly, if at all. C++ enthusiasts never seem to tire of finding new and obscure idioms to invent.

    There are lots of OOP languages out there, but I think two recommend themselves to the newbie -- especially the newbie who wants to actually makes things. There's Java, which no longer seems likely to change the world, but is still a dominant force in some applications.

    And there's Object Pascal, which outsiders consider an antiquated curiousity, but which is considered a powerful and highly usable tool by its rabid fans. OP compiles very quickly, which makes it particularly useful for RAD tools.

    Which brings me to the commercial: I help document the two big Object Pascal RAD tools, Delphi (Windows), and Kylix (Linux). Both are extremely accessible to the OOP newbie, while having all the power and expressiveness of a serious OOP system. And both have versions you can download for free.

    Some people down the hall do a similar tool for Java. I hear its pretty good.

  153. Just another tool by DotComVictim · · Score: 1

    Yes, of course OOPLs can solve engineering problems. Does that mean you need to use it to solve engineering problems, or that it is always the best solution? No, in fact a lot of time it is unwieldy to design an object framework, and it complicates the problem. If there is a clear objectification of the problem, an OOPL would be a good choice.

    Languages are just a toolbox - pick the right tool for the problem. People too often jump on the newest hyped language and think it will make everything easier and better.

  154. How are you defining OOP? by Nelson · · Score: 2
    It's not a well defined term. What exactly are you expecting? Some "problem solver" object you can just drop in to any program and reuse?


    At it's most primitive layer, OOP is a coding thing, a syntactic sugar as so many professors like to say. A way to keep code clean. It's quite nice in that capacity, I don't mind writing "c = a + b;" and under the covers mpz_add is getting called and adding the arbitrary precision number a to the arbitrary precision number b and storing the out put in c. This isn't true OOP, I only include it becuase it's the OOPLs that have made it popularly available.


    The next level is encapsulation and reuse. It's pretty damn nice to be able to write "d = {}" in python and create a hashtable dictionary. I do that is literally dozens of python programs. I could easily produce the same thing with list primitives or vectors and what have you and I might even be able to make it better for my particular use but for the most part the dictionary object in python or any of the STL objects are insanely useful, they are easy to use, quick and they are building blocks you can use to build bigger programs. You're already using this kind of code whether you know it or now, the C library is the same thing, it doesn't have the same syntactic sugar though and the things it does are generally more simple where some of these objects are higher level components. I wouldn't call the C library object oriented, per se, but might call a component that does the job of half a dozen C library calls an object.


    The final layer of OOP as I see it is modeling. Again it's not well defined outside of a few circles and even then Grady Booch and Bertrand Meyer and the other gurus spend countless hours and books bickering about it. The modeling part is how we break a problem down and implement a solution for it. This I would say is a universal area where OOP has won and will continue to. When programs reach certain sizes, the human mind can really only deal with the complexity by building heirarchies and mapping the problems to solvable isomorphs and then trying to reuse ideas as you move through the heirarchies. If you're trying to multiply a few matrices and then hit them with the Gauss stick to tell if the bridge is going to work, it's probably not a good example of a problem to model that way. A GUI on the other hand is a perfect example where you can have a very clean hierarchy of windows of different types with different functions that behave differently. In my experience, I haven't seen any large scale projects started in the last 15 years that weren't object modeled, even if they were implemented in C or some other non-OOPL, I have seen a fair amount of code from the 1960s and 1970s that was very very complex because it didn't have any real object modeling. The linux kernel has a fair amount of object modeling in it, there are abstract block devices and character devices and they can all be treated the same way, buffering is an abstract concept regardless of the device. Even functionally implemented programs have some degree of object modeling in them.


    Now what kind of OOP are you looking for? If you're looking for some kind of advanced object model with reflection and a complex object hierarchy, then maybe it's not being used to solve some engineering problems, it takes a certain size problem before that kind of effort really pays off in the implementation. If you're looking for code reuse then there are numerics packages and probably tons of other packages the will do that.

    1. Re:How are you defining OOP? by Tablizer · · Score: 1

      (* The modeling part is how we break a problem down and implement a solution for it. This I would say is a universal area where OOP has won and will continue to. *)

      OO is not the only org game in town.

      http://geocities.com/tablizer/bizmod.htm

      The 3-graph model is more consistent among practitioners than OOP modeling. OO modeling methodologies come and go with the wind and hairstyles.

  155. OOP is a tool that most benifits complex problems by dloyer · · Score: 1

    OOP is just another tool. It is a tool that takes some time to master, but can greatly simplify complex software projects.

    For a very simple program such as a numeric program that executes a tight loop, there is probably not much benifit. It might be more important to be compatible with some library that meets your needs. If the library was not designed with OOP in mind or was implemented in a languge that does not have strong support for OOP, then it may be more trouble than it is worth.

    If the program is more complex, then if you take the time to master OOP, you might find the program is simpler and more logical. But, watch out for the trap of trying to go overboard on OPP. Many programers that are new to OOP get tangled up in trying to do it the "right" way and wind up with a program that is very complicated and slow, defeating the point.

    I like to to use OOP tools like C++ and Java because I have used them so long, it is simpler for me. But, I could acomplish the same thing using K&R C.

    Either way, the job gets done. Sometimes it just comes down to what you prefer.

  156. OO and Engineering by geekoid · · Score: 2

    I have been on projects that insist on OO for there engineering projects. its good for reuse within THAT project, but thats about it.
    Very few people can write good OO. but even the good ones often end up with too much indirection, which can seriously hurt a "low level" program.
    Each project had specific needs for that chip set, or product, so anything but the most basic needs wasn't reusable without more tweaking.
    Compilers are pretty darn good these days, so thing that use to be a selling point for OO aren't anymore.

    In my real world experience, there is nothing OO can give you, that good coding practices don't.

    The main advantge thats bandied about these days is re-use, but That can be done with a function just as easily.

    --
    The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
    1. Re:OO and Engineering by Baby+Duck · · Score: 0

      In my real world experience, there is nothing OO can give you, that good coding practices don't.

      Such a vacuous statement. OO will force you to be disciplined and will catch you when your discipline slips way more often than on non-OO projects. OO helps you write contracts that other parts of the code must follow. If this contract is broken, it will let you know at compile time.

      Even if you think you are a hot shot and never slip in your discipline for a single second, can you say the same about your teammates? And when you do slip, how long does it take you to find that slip when not using OO? How much debugging code did you have to write to find what an OO compiler would have found for you?

      The point of programming is to solve a problem once. Once! Further applications of that found solution will be automated by running that solution. Wouldn't it be nice if a programming paradigm solves the problem of finding contract violations for you? OO does this.

      An example of using a non-OO oriented language to simulate OO concepts is GTK+. Now that is highly disciplined! GTK+ uses C instead of C++ because the problems they are trying to solve are too runtime in nature. Too much is unknown at compile-time so the compile-time safety of C++ would have only gotten in the way. However, just looking at GTK+ libraries is very scary because you can see how easy it is to break the contracts they are trying to establish. Finding such a violation is an arduous task.

      I fail to understand how being forced to be more disciplined of a programmer is a benefit of moving away from OO! It's like arguing for reading Slashdot on a monitor that can only display one character because it forces you to remember a helluva lot more to be able to read a single line.

      --

      "Love heals scars love left." -- Henry Rollins

  157. Re:OO isn't Hard by karb · · Score: 2
    I guess I shouldn't say "OO is hard" so much as "figuring out the best way to design your system with OO is hard." Understanding your domain is usually pretty hard. Figuring out the best formulation for an OO system to represent that domain is nigh impossible. That's why we have design patterns, and why this engineer might be better off going procedurally.

    I've been doing java and C++ programming. Your experience with simula holds true for them too : very rarely do language issues make much of a difference in terms of difficulty of an OO design. (although they surface occasionally) You usually face language limitations in the coding phase (because, if you're like me, you aren't smart enough to recognize them in the design phase). Or in the maintenance phase, when you realize a section of code could be much more elegant with the help of some language feature not present in the current language.

    --

    Jack Valenti and the MPAA are to technology as the Boston strangler is to the woman home alone

  158. Re:Perhaps the computational power is to be questi by Anonymous Coward · · Score: 0

    You can use OOP without a noticeable slowdown.

    You just have to program efficiently.
    (Procedural applications won't run quick either without efficient code)

  159. Engineering C++ by asrb · · Score: 1

    Try the book:

    Scientific and Engineering C++: An Introduction with Advanced Techniques and Examples. John J. Barton and Lee R. Nackman.

  160. Simulation in C++ by Animats · · Score: 2
    As someone who writes simulation systems, I can say that it's better in C++ than in C or FORTRAN. Some notes:
    • A big advantage of object-oriented programming for numerical work is that there's a place to put all the bookkeeping information you need to carry along.
    • Collection classes are a big help. Understand and use valarray. Write your code so that the size of the array is obtained from the array object, rather than passed as a separate parameter.
    • C++ multidimensional array support is still inferior to that in Fortran.
    • You can't create local temporary arrays of unknown size on the stack in C or C++, which can result in unnecessary memory allocation calls just to get workspace.
    • Numerical Recipes in C is a transliteration of Numerical Recipes in Fortran, and it shows. They even use a hokey memory allocation scheme so they can count arrays from 1.
    • Microsoft is sloppy about testing their compilers for correct numerical results in the "all optimizations on" mode. I know people at a large engineering company who run a sizable test suite on each new Microsoft compiler service pack and release, and don't use it until Microsoft fixes all the bugs. I can't speak for GCC.
    • Use "inline" on small numeric functions.
  161. Are you a robot? by TheRain · · Score: 1

    You see OOP is not a solution to an engineering problem- it is a solution to a people problem. It helps people to see and design solutions more efficiently. People have trouble seeing a link between the technical and the practical problem at hand. OOP helps people bridge the gap in their mind so that they can model a solution to a problem in a more understandable "natural" way. You could argue that this is a cop out.... that people should overcome the blocks in their mind between the technical and abstract to the practical, physical problem... but the truth is, people have limitations..... companies have deadlines... and not many people are intelligent enough to overcome these boundaries without significant cost.

    --
    Please help! I'm stuck inside my virtual reality headset!
  162. 2 books by coltrane99 · · Score: 2, Informative
    There are a couple of books I read a while ago that contributed most to my understanding what the big gains were from OO programming:

    Object Oriented Software Construction by Bertand Meyer - don't be put off by examples in Eiffel, this book very thoroughly runs down all the standard OO features and demonstrates/explains why the features are useful. Personally I don't know a lick of Eiffel and have no intention of ever learning it, but found it very easy to follow the examples and map them to my language of choice.

    Design Patterns by Gamma et al - This book simply runs through a lot of problems and demonstrates at a nice high level how one might use OO design to solve the problems in elegant ways.

    If you read these 2 books, you should 'get' OO programming, and understand where you will and will not reap benefits in using OO techniques.

    1. Re:2 books by Tablizer · · Score: 1
      There are a couple of books I read a while ago that contributed most to my understanding what the big gains were from OO programming: Object Oriented Software Construction by Bertand Meyer ....

      A critique of Meyer's work can be found at:

      http://geocities.com/tablizer/meyer1.htm

      (sorry 'bout the popup ads)

  163. OO is alive and well in engeering problems by imp · · Score: 2

    You've described good OO boundaries in some ways. I've seen good OO and bad OO in the engeering field. I've seen good OO where the stats stuff was written once and everybody used it. I've seen bad OO where stats were rewritten all over the place by people of different skill levels.

    Stats is just one example of several. We do control systems and have control system base classes that allow us to model the control system by breaking it up into a measurement side and a control side and treating things generically. It works very well.

    As you gain a wider experience, you'll find that most systems can be modeled with a good set of abstract concepts. We've found it has helped up tremendously. For example, when we write a new control system, generally all we need to do is to write measurement and control objects for the hardware that we don't already have these objects for and then write some custom plumbing code to tie all the objects together to match the wiring of the actual system (well, more or less, but that gives the right flavor). We don't have to write PID controllers each time, or simple alignment operations or any of the more complex data filtering algorithms we use to keep the control systems stable.

    Yes, I know I'm being a little vague, but to fully describe things would take more space than is appropriate for this forum. Then again, the question was kinda vague...

  164. OOP can help parallel also... by kvandivo · · Score: 1

    It just depends on how you look at it. There can be significant advantages in going OO. One is that it can simplify parallelization of the code if written correctly. Take a look at the molecular dynamics program NAMD and you will see what I mean.

    --
    http://www.WinWithRealEstate.com/
  165. Software Engineering issue by SleezyG · · Score: 1

    I don't think it really matters whether you're writing an engineering program, a game, or even an embedded application. It's a question of execution speed and code size versus the ability to manage the project. If you want something quick and dirty, procedural languages are the way to go. However, as the complexity and size of your code increases, the benefits of OOP (ease of debugging, high level of abstraction) far outweigh the extra development time and additional execution overhead in the compiled code.

    Assuming that one agrees with the above statements (they are only theories about OOP vs. procedural languages), it should also be noted that the most expensive aspect of developing software is man-power. Thus, if a project is large, with lot's of people working on it, it becomes crucial to reduce the amount of time programmers spend communicating with each other. It follows that if OOP is easier to understand than procedural code, then you want to lower your costs by using OOP to reduce development time (because time == dollars paid to programmers). Naturally, there is an antithesis to this idea. If your project is small, with few programmers and already easy to understand, then using a procedural language will get the job done quickly, once again mimimizing programmer time.

  166. static member functions work for this by Anonymous Coward · · Score: 0

    We did this by creating classes containing only static member functions. One class worked on matrices, one on polynomials, etc...

    This is basically C with some grouping of related functions.

    It also allows you to do high level objects for math objects and then do C like low level computation routines.

    Also gets rid of all of the C++ to C name mangling time wasters.

  167. Re:Perhaps the computational power is to be questi by Malc · · Score: 1

    "maybe OOP is mostly used for its inheritance in data structure"

    A lot of bad OO programmers seem to use inheritance for inheritance sake. Personally, I find OO is more than just how you express something in the language, but rather a complete way of thinking or a mind set.

  168. Come back and solve the same problem in 6 months by hacksoncode · · Score: 1
    The big advantage of OOP is not in getting a job done the first time, it's in working with the code 6 months from now (and again 6 months after that).

    OOP, when done correctly (and when you don't go overboard and forget that you're using it to make your life *easier* :-), encourages programming in a general way, and organizes things so that they are easier to morph and add to later without breaking your original sound design.

    Contrary to what many OOP zealots would tell you, my experience is that this actually takes more time up front (again, if done right), rather than less. You spend a lot of time on seemingly useless activities, such as coming up with good names for your objects (if you can't name it succinctly and accurately, you haven't designed it properly).

    There is one situation in which OOP can result in faster implementation, and that is when the project gets big enough that you need multiple programmers in order meet the schedule. In many ways, OOP is a reaction to "The Mythical Man Month". It's an extremely useful paradigm for splitting up tasks and defining interfaces that can be independently implemented. This is probably why people tend to think of it as only applying to large projects.

    But even small projects need maintaining, upgrading, and resuing later on in life, and OOP helps tremendously with this.

  169. Cultural differences by geophile · · Score: 2

    I think the answer to your question is cultural. We all know many OO
    weenies who have spent years improving their programming. They have
    jobs, and build useful applications sometimes, but I think the thing
    that really motivates these people (hey, I'm one of them), is the goal
    of becoming a better programmer, and writing ever more beautiful code.

    I think that folks working on engineering problems spend similar
    amounts of time trying to solve the real-world problem.

    From my own educational background, (undergrad, grad school, faculty
    member before joining the real world), I observe that the split between
    these two approaches to software occurs pretty early. People who focus on the
    advanced numeric stuff spend their time on that. People who focus on
    the underlying tools seem to have a better chance of becoming object
    weenies.

    Can OO help out with (non-software) engineering problems? I'd be
    surprised if they couldn't. Personally, I don't know enough about that
    set of problems to offer an opinion. I think the reason that OO isn't
    used more in mechanical engineering (for example) is that there are
    many more people like me who specialize in one or the other, and very
    few people broad enough to have enough of an understanding of both
    worlds to know how they can be combined.

  170. OOP used in designing Airplane engines by Anonymous Coward · · Score: 0
    When I was still working at Pratt & Whitney back in 1996, one group of developers (not my group, but one that worked near me) were developing object-oriented, distributed- and parallel-processing thermo-hydrodynamic simulation programs (using C++, if I remember correctly) so that the design engineers could come up with more efficient jet engine designs.


    While the guts of the programs were well-established FORTRAN routines (inverting huge arrays, solving difference equations and partial differential equations, just like you described), there where vast layers above that that used OO concepts to organize things like MaterialProperties, Geometries, EngineComponents, Assemblies, and other elements of the problem set. Different classes broke the simulation down into three-to-twelve simultaneous sub-simulations, distributed them accros the Unix network, ran them in parallel, and coordinated each iteration's results with the other parts of the run.


    Basically, both functional programming and OOP were used where each works best: OOP provided reusable software components and levels of abstraction that allowed the engineering problem to be rapidly mapped to these components, and functional programming routines performed the well-understood mathematical processing.


    As stated in a previous post, OOP is a superset of functional programming, because (in the end) each method must be coded using functional programming techniques. OOP is a way of abstracting related, underlying functions into a coherent object (or class of objects) that maps more easily to the problem domain.

  171. Discrete Problems/Solutions and OOD by hackus · · Score: 1

    Engineering problems are problems that fall under a domain of discrete solutions, which have very specific algorithms by which they are solved.

    Object Oriented Design doesn't work to well with discrete solutions because, in part, the design philosophy is one of generalization.

    That is why Linus for example holds to the belief that OOD principles in system level software is wasteful, for a variety of reasons. Primarily because there is no need to write the functions of a scheduler for as OS anything other than what it is.

    However, that doesn't mean that all aspects of OOD, such as reuse, simplicity, and maintainability don't have anything to offer to discrete solutions. Just that OOD can't realize all the benefits a discrete solution to a problem can give you. Also, should you decide to choose an OOD for a discrete solution for an OS kernel or tracking asteroids, you have to realize hopefully through experience what the relative meager benefits are in doing so for your discrete OOD solution.

    That doesn't mean you can't try though!

    For example, at the moment I am writing an extension to a number of problems to track asteroids for a telescope via computer automagically.

    Most of the tracking software was or is originally written in FORTRAN and is in the book "Fundamentals of Celestial Mechanics" by JMA Danby. Publisher is William-Bell by the way.

    RK5 methods are highly specialized mathematical algorithms specifically tailored for N body problems in calculating or predicting orbits. They are for the most part functionally reduced to FORTRAN IV in the form of highly NON OOD function libraries.

    (It is not OOD because the functions rely on a number of shared data structures which is a no no in OOD. As a result, since code is not easily isolated between data and function calls, it is VERY hard to figure out the source code by hand and very structured design oriented.)

    Also, might I add, checking the answers are literally BEYOND your ability as a human being EVEN WITH a calculator! For example, an RK5 method might have over 1,000 iterations of a integration or differential mathematical procedure. There is simply no way you could check it by hand. I solve this problem by using Mathematica, from Wolfram Research. I transpose the algorithms from Fortran into Mathemtica until I get the right numbers and to make sure I understand exactly what the algorithm is doing.

    I then transpose it to Java, which is the target platform and Object Design language I am using to forever banish the constant rewriting of code from computer to computer!!!

    Java has been a GOD SEND to astronomy by the way in cutting costs! Especially for a society that woops and screams about cutting all scientific research while at the same time spending hundreds of millions too see Harry Potter. (How sad. I hope one of these rocks doesn't fall on your city anytime soon.)

    However, lets not be decieved. For although OOD and OOP practices in generalization of programs yields better reuse, in principal, each specific method of an object is built using well known Structured Design practices.

    So, with that I set out to generalize a highly specific piece of code and layer on top of it, an OOD that would attempt to turn what appears to be a highly specific set of functions in FORTRAN that solves a standard N Body problem, with a set of Objects which define what an "N-body" IS as well as the functions that can give the solution to that bodies orbit.

    The goal is to maximize the ability of OOD to simplify the understanding and theoretically increase the reliability of the very complex code. This is the benefits I am looking for rather, that OOD promises and delivers in building complicated programs. Notice I am not interested in reusability.

    So although resuse is meaningless to me in this context, I still want those advantages of an OOD design, maintainability, and more reliable code on a level that structured design/functional approach can't give me.

    What is interesting is the "IS" part. In standard structured design which FORTRAN is readily able to implement any algorithm, you have isolated discrete function calls that operate on global data sets.

    With an OOD approach, however, I found at least that OOD does provide the following benefits:

    1) Taking the simple FORTRAN function library and building it around a unified object that represents the many different properties of the asteroid simplifies the understanding of the algorithms involved.

    I wish it could do the same for the mathematics, but that part is still very hard, no matter what language you use.

    2) The OOD principles of reuse don't really help here. Primarily because in the context of the problem, there is only one solution. I highly doubt people could reuse this in other ways than it was intended. Except of course, to calculate the orbit of another body.

    3) The OOD characteristic of privatization of data organized the code in ways that made the source code, not only easier to understand, but also unexpectedly suggested ways to improve the implementation of the computer algorithms to do the mathematics.

    Unlike a GUI library, the spectrum of reusability is much narrower in this case. As I said before, because the computing requirements for the application in question are so highly specific. It is highly unlikely they could be used for any other purpose, except calculating the orbit of a different body. I guess that is SOME reuse.

    A GUI library however, you can use a OK button code in all sorts of applications from word processors to web pages, to spreadsheets...using Java for example which is what I am using.

    So to summarize this is what I have learned:

    1) OOD principles in discrete areas of engineering or system level operating system design have lots of pitfalls, and require a careful consideration of the clear benefits of OOD vs the performance requirements of the application.

    Primarily, because OOD is expensive upfront, and lets face it. If you are not going to get all the benefits from that expense, why use it? In may case, I didn't benefit from the generalization of code, for other application use other than the very strict focus on other specific applications of orbital calculations.

    2) Reusability in the broad spectrum of coding using OOD in discrete applications in certain fields don't buy you much, because it is rarely a requirement that the code be generalized for resuse. In fact, it is just the opposite, it is highly specific, and only for a given solution.

    Such is the case with Operating Systems and discrete engineering applications or scientific applications, for the above reasons.

    3) Finally OOD can however, provide clues into relationships of an algorithm to its data not normally gleemed through the narrow lens of structured design. Specifically, such as cited above such revelations may provide clues in how to store data more effectively and reduce memory consumption.

    Therefore even if you are specifically choosing structured design as an implementation framework for your computer algorithms, OOD might shed new light on how to code a structured design solution more effectively to handle data storage and its reuse.

    Which coould save disk space, cpu time, memory requirements..etc.

    Then again, it may not!

    -gc

    --
    Got Geometrodynamics? Awe, too hard to figure out? Too bad.
  172. Granularity by gwayne · · Score: 0

    I think what you're really questioning is the granularity or detail of the solution to your problems. Remember, at the assembly level, there really aren't any OOP constructs.

    Basically, all software boils down to binary, from assembly. Then you have higher level languages like C, which can be used to create other languages and constructs, whether they are procedural or OOP. The higher you go, you begin to form reusable objects, design patterns, frameworks and architectures. Think of this as an inverted pyramid.

    It may be that the solution to your numeric problem is best coded in assembly, in which case you don't need OOP. However, if you are creating several modules that each solve a specific problem, you may want to combine them into a generic application framework. If this is a batch processing application that uses a particular module based on the data it encounters, you might use polymorphism and abstraction to deal with objects generically.

    At this level, you are concerned with reusability and maintainability. When your boss sees this wonderful application and asks you to add a GUI for non-3133t5 or to add additional modules, you can say "No problem!"

  173. Why, I have one right here... by jabber01 · · Score: 2

    It's an industrial boiler design system in which each meaningful component is modelled as an object.. Then these objects are parts of subsystems of the boiler, and the subsystems all comprise the boiler itself..

    I put in a bunch of data files read by the loader object, and used to set the parameters of the internal objects.. Then I simply look at boiler.getEfficiency(), and the necessary computations in all the subjugate objects are done, and there it is..

    OOP is more about the architecture of your program and about the way you concieve of the data.. If you think of it as ripping through tables of numbers, you'll at best have a procedural, iterative solution that uses arrays or structs..

    If you extend the concept of a struct to be an analogue of a 'thing', and then tell the 'thing' to solve for some attribute of itself based on other internal, and external, factors, you're thinking in OO.

    That's all there is to it, in a nutshell.

    --

    The REAL jabber has the user id: 13196
    What you do today will cost you a day of your life

  174. OOP for Earthquake Engineering by sfpedro · · Score: 1

    You might want to check out the OpenSees Project - they've built an OO tool for structural analysis.
    An API listing is available at:
    http://opensees.berkeley.edu/OpenSees/api/contents .html.
    Have fun, Peter

  175. Not Really by JohnsonJohnson · · Score: 1

    First of all, I'd like to apologize for the "I can't believe someone asked this question!" tone most of the replies have.

    Secondly, there seems to be a lot of confusion over object oriented programming versus languages which allow one to program in an object oriented style. It's been a while, but as far as I can remember there are three characteristics which define object oriented programing: encapsulation, polymorphism and inheritance. I am not going to define them here; any textbook can do that, but in general they are not terribly useful in a scientific/technical computing environment. For example, a lot of people get excited about making matrices or complex numbers into "objects". This is a poor choice in the case of matrices because it precludes the ability of a compiler/interpreter to make intelligent decisions about space/time tradoffs. For example A=A+B+C where A, B and C are matrices should avoid teomporary storage for B+C and simply accumulate the result in the storage allocated for A. Within the traditional object oriented paradigm there is no way to do this. Futhermore in packages which operate on values from the real, integer and complex sets the number of methods that need to be defined to handle the mixing of types is so large as to actually increase programming effort when done in a pure object oriented style. In general, binary operations and operations which change type like absolute value of a complex number are difficult to use efficiently in an object oriented style.

    Generic programming which C++ supports through its template facility and therefore often gets lumped into the object oriented paradigm is generally more useful in these cases as one can define a single function like addition for example and not have to worry about the nature of the types being added. Functional languages also generally support this style hence the frequent recommendations to use that paradigm as well. However in my experience with languages that support a functional programming style: Mathematica and LISP primarily, you generally pay a price in memory usage for the ease of development.

    That said, for programs with a lot of function entry points (ie, a large API), which is not generally the case in scientific/technical computing. The organizing principles of OO can be useful. Similarly for problem sets in which there are a few general operations applied to a wide variety of types functional programming techniques are useful, especially when intermediate results can be discarded. Scientific/technical programmers should be aware of all programming styles (as any programmer should) but the better programmers are aware of the tradeoffs involved in each style.

  176. Its just a way of thinking about the problem,yeesh by Com2Kid · · Score: 1

    The only difference between the OO methodology and a procedural methodology is how the /HUMAN/ on the other end has to think about the problem.

    Then again, isn't that how everything is? Convienent metaphores to keep poor little humans from having to comprehend too much stuff at once.

    Hierarchal file display VS flat file display. If humans could take in data faster the flat display would work better, albiet with a bit more waste in data tranfer (excess data on each directory listing.)

    Hell, the only reason you have to WRITE DOWN the intermediate steps of design and brainstorming and such is because the human mind (in most cases) is unable to deal with all of the complexities of, say, a motherboard, mentaly.

    Hell get a smart enough brain and you could design anything Fast As Shit.

    Annoying sucker that brain is, on a thirty minute math problem it can take me 5 minutes of actual math and 25 minutes of writting down the intermediat steps. . . . . bleh.

  177. OOP && C++ vx 'procedural' && C by josepha48 · · Score: 2
    The problem is that when people think of OOP they think of C++. Truth is that you can do OOP in C but it does not have all the features that you get out of C++. Also C++ is generally though of as slower than C. In many engineering applications they want the speed so they do C or ASM. In other cases they use ada. The goverment uses lots of ada still or at least that is what my brother tells me and he works for them as a programmer so he should know.

    Think of it this way, a C++ class is basically a C structure on steroids. Functions in the class are like pointers to functions in a structure. Both can do signals and callbacks. The difference is that one was made to make doing OOP easier (C++).

    Ada is another option for OOP programming as well as Java.

    Do you think that mathcad is all C? I'd imagine that it contains C++ and possibly com objects and it is an engineering program. I'm sure there are others, in fact I remember when I used to read spectrum magazine from IEEE they had adds for many engineering programs and some of the newer ones were in C++.

    I think it is your application probably does not call for it.

    --

    Only 'flamers' flame!

    1. Re:OOP && C++ vx 'procedural' && C by Anonymous+Brave+Guy · · Score: 2
      Truth is that you can do OOP in C but it does not have all the features that you get out of C++.

      You can do OO in machine code. The difference is that languages like C++, Java and Eiffel support OO programming.

      Also C++ is generally though of as slower than C.

      Your statement is true. However, the statement that C++ is slower than C is not.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    2. Re:OOP && C++ vx 'procedural' && C by josepha48 · · Score: 2
      "However, the statement that C++ is slower than C is not. "

      You obviously never read the slashdot article about how C++ at runtime must instantiate all the objects and do some other funkiness that makes startup time slower than C. This has something to do with the way the compiler compiles the C++ code. There was talk about the kde and how they overcame some of the startup issues with kde 2.x so that kde startup would be faster. They have the kdeinit process running which makes starting up other programs faster. I'm not sure about all the details. They said that a compiler could be improved to make startup time better.

      Oh and here is an article you may want to read -> http://www.gamedev.net/reference/design/features/w hatlang/page3.asp It talks about some of the tradeoffs of using C++ vs C.

      Also there are other reasons why C++ is not that good a programming language and here is a guy who was talking about creating D programming language -> http://www.digitalmars.com/d/ and some of his reasons for this.

      Personally D is looking better and better. No VM like Java. Built in garbage collection which is better than C or C++.

      --

      Only 'flamers' flame!

  178. STL and Bloat: Alexander Stepanov by alacqua · · Score: 1

    Real bloat comes from libraries like STL...
    First let me say that I have not used the STL much at all. However, I remembered reading an article about the design and goals of the STL which claimed that STL code, when compiled, was almost as efficient as a version written in assembly. Can any more experienced STL/C++ programmers comment on the validity of the claims? I dug up what I think is the article in the byte archives. Its by Alexander Stepanov. Here's an interesting quote from the article:
    "I found that efficiency and generality were not mutually exclusive. In fact, quite the reverse is true. If a component is not efficient enough, it usually means that it's not abstract enough. This is because efficiency and abstractness both require a clean, orthogonal design. A similar phenomenon occurs in mathematics: Making a proof more abstract makes it more concise and elegant."

    --

    Move on. There's nothing to see here.
    1. Re:STL and Bloat: Alexander Stepanov by Cato+the+Elder · · Score: 1

      I believe that he was talking about speed efficency in this case. Templated code tends to size bloat because each template instantiation is a seperate codebase.

  179. OOP Is Not an Algorithm by dbretton · · Score: 1

    Seems to me that you would like to see OOP, really more OOAD for that matter, manage to solve equations or systems of equations.
    What you are asking is analagous to asking if you could use an assembly line to tighten a loose nut.

    It can't be done. It doesn't work that way.
    OO is a technique for handling and solving more general problems than that of solving a system of equations for optimizing a dampening coefficient (pick your favorite problem).

    OOP allows engineers and programmers to create systems/simulations/programs/etc. that are less prone to error, and easier to adapt and modify.

    The common mistake many engineers and programmers make is to think of computer programs as entirely either a little whipped-up something that can get you the answer to a particular problem, or as a system that is put together to solve every problem under the sun (or to be capable of being easily modified to do so). Programs come in many flavors, really.

    OOAD (OOP) allows people to create solid designs of solutions to engineering problems. For example, let's say you are creating a simulation for determining the signal quality for an output from a particular circuit. Basically, you model the circuit, then monte carlo over some noisy variants in the system, average your results, and Viola!: there's your answer.
    That's all great and swell until you start getting fun things, like feature creep (aka "Make it do this, too", ... "What happens when we swap this part that has a 3db loss?", etc.) This is an example of where OOP can help. Basically, OOAD can help people to design solutions that may better relfect real-world systems, or will be easier to modify.
    OOP is not a panacea.

  180. C++, efficiency, and OO by ttfkam · · Score: 5, Informative
    I feel like clearing the air of half-baked comments and know-nothing OO detractors.

    First of all, for those individuals who refer to C++ as an OO language, please stop. You're wrong. C++ can be used for an OO project, but it is a multi-paradigm language. At least that's what Bjarne Stroustrup calls it. But what does he know about C++?

    Second, use of C++'s STL does not equate to OO programming. It is an example of generic programming. Here's a hint: the STL has very little inheritance except for iterators and iostreams -- most evaluation is handled at compile-time. And even iterators and iostreams are just as much generic as OO.

    Finally, please dispel the rumor that C is automatically faster than C++ because of C++'s excessive overhead. Need proof? Please read this article about treating C++ as its own language and not a variation of C. Yes, it's a PDF. Get over it.

    Think the article is FUD? Prove it! Take the examples from the article and tune them better than he did. Compile them with trusty ol' gcc and g++ on your box. Measure the results. After you do so, can show that C is faster, does not contain any potential buffer-overflow bugs, handles error conditions, and wasn't at least five times more code to do it, then reply back with your results. I have a feeling I won't be getting any replies from people who actually try it.

    That said, use whatever language you like best. Studies have shown that people will always perform better in languages they know intimately well than languages in which they have a general familiarity.

    But if you want to use OO and C++, check out this numeric library

    Have a nice day

    --

    - I don't need to go outside, my CRT tan'll do me just fine.
    1. Re:C++, efficiency, and OO by goon · · Score: 2

      Please read this article [att.com] about treating C++ as its own language and not a variation of C. Yes, it's a PDF. Get over it.


      or googlise it into html

      ps: it's not perfect

      --
      peterrenshaw ~ Another Scrappy Startup
  181. NASA is doing it by Ristoril · · Score: 2, Informative

    It's called NPSS and it stands for Numerical Propulsion System Simulation. The basic idea behind it is to be able to build a simulation of a jet engine by linking together different objects (fan, compressor, burner, turbine, nozzle, etc) whose properties you can change (fan area, burner temp, fuel flow), in order to theoretically model any engine you want.

    I played with it some, and it's very cool. My BS is in Mechanical Engineering, and they didn't start letting engineering students take C/C++ until the year after I started, so I know the FORTRAN woes you suffer.

    The thing is that for years engineers have had to use FORTRAN to do stuff it shouldn't really be doing, so they've gotten into habits of trying to think of problems as more complex than they really are, just because the programming language they have to use is unsuited to the problems.

    Anyway, NASA has been at it for a few years, and they've done a great job (IMHO) at implementing OO for what they're doing. Using the software to build and simulate an engine is incredibly easy, and you can simulate all kinds of manuevers and engine configurations really fast.

    -ristoril

  182. The Answer Is YES, OOP is Appropriate by waltal · · Score: 2, Insightful

    OK folks, how about object-oriented NASTRAN? Anybody out there agreeing yet? This is hardcore structural analysis, and a major pain for years because of its initial programming architecture.

    Lockheed-Martin is using a generalized data handling/simulation library called GEMD. It's object-oriented data complemented by an object-oriented, high performance C library. It's powerful enough for F-16 or F-22 simulation, and conveniant for simple one-hour problems. It is a standard for much of the engineering staff.

    Are spreadsheets great engineering tools or what? I've done propeller design with a spreadsheet. At the interface, there are lots of objects. I'm sure spreadsheets are best programmed with object principles in mind.

    Engineering is a very real-world endeveor. You can argue that engineers use mathematical abstractions in their work, and I would argue that even mathematical abstractions can be regarded as objects in a programming implementation. And I would also argue that most engineers are held to much higher standards of accountability if their software fails. And that goes for accident and incident analysis, too.

    Anything that improves production, use, testability, maintenance of software in engineering is well worth learning and using well.

  183. How OO might help by slide-rule · · Score: 1


    I was taking a few numerical methods classes in my engineering classwork not *too* long ago. At the same time, I was trying to learn how to apply OO concepts to new problems as well as learn the finer points of Java. So I started doing my various homework assignments and projects in an OO fashion with Java. Maybe a few ideas can be a starting point. (Bear in mind what I did was somewhat crude, but it was personal homework assignments, not full-on production code releases. I'm also not advocating use Java for high-performance-demanding code per se; I was only killing several birds with a single stone ;)


    For a finite element methods class, I created classes to represent various element types. (Bars, thin triangles, thin quads, etc.) There was also a "matrix" object. Now, each element type object would have a method to populate its coefficients into the matrix, and the matrix would have a method with which to solve itself. Now, the implementation of this particular method is quite procedural if you only look at that part; the OO comes about providing a more abstracted method of assembling the matrix, dealing with neighbor-to-neighbor effects, and the like. Ultimately, I had different classes to solve matrix objects by different techniques, so I could easily change how the problem was being solved by just tossing the matrix object to a different object/method (which was already fairly polished in the more general numerical methods class).


    For things similar to CFD solutions (a la your finite volume question), you can likely use OO to organize your flow domain into different region objects, each of which has some notional grid object (or perhaps collection of volume objects). The methods in these classes can give you the ability, again, to assemble matrix objects which can be passed off to a particular solver. (Again, this implementation of the solver will likely appear quite procedural; I didn't carry the idea too much farther before gradution to know if the various matrix inversion techniques could be cleverly OO-ized.)


    So in other words, use OO where the principles can help you. It does take some amount of thought to redesign your approach to the problem. Hope this gives a few things to think about.

  184. What OO is for... by bokmann · · Score: 1

    I'm late joining this thread, so my comment will probably be lost in the noise... I hope that someone who cares sees this and mods it up.

    A better question would be 'what is Object-Oriented Programming for". It is *not* for the computer... a computer will happily execute any machine code, no matter what its source.

    Object oriented programming techniques, and in fact ALL PROGRAMMING LANGUAGES are abstractions that help HUMANS.

    The human mind can only keep track of 'so much' at any one time. That is why we tend to 'package' information up into simpler representations, like analogies and stereotypes. These 'wrappers' around the complexity allow us to manage more at a time.

    This is what OOP is for... helping the developer manage the details of the implementation.

    Now, we as humans are better at representing some problems and 'procedural' and others as 'objects'. The writers question 'Can OO Solve Engineering Problems?' is bizarre in this context... of COURSE it can... it is just a matter of the human thinking of it that way... the question might better be put 'is there a good way for us to think of these as OO problems?" That is a defferent question... Some problems will be better handled procedurally, some will be better handled as OO. And it has as much to do with the person decomosing the problem and their skill set as it does with the problem domain.

  185. too narrow a view of "engineering problems" by Anonymous Coward · · Score: 0

    I find your view of what comprises an "engineering problem" too limited. In this limitation lies the reason why you never found OOP tools useful yet --- for those particular problems you consider, you really don't need them. For problems dealing with number-crunching based on matrices and vectors, FORTRAN is still a good choice of tools, even these days. But by far not all engineering problems worthy of using a computer program for are of this type. These days, finding the optimal layout of base stations for a cellphone network based on lots of geographical and electromagnetical facts is a hugely important engineering problem. No matrices involved at all.

    In other words, you're facing the inverse of the old saying: "Once you've bought a new hammer, all kinds of things start looking like nails". You have had nothing but that hammer for so long you got used to thinking only driving in nails is important work. ;-)

    Now, seriously: OOP is not for (your selection of ) "engineering software", but rather for "software engineering". Its gains are in projects where the difference between craft and engineering becomes truly important.

    Let me try illustrating this by a reference to the history of technology. There's a reason one of those OOP languages is named after Mr. Eiffel, the engineer who built that famous iron tower in Paris. Mr. Eiffel's real revolutionary achievement at the time was that he constructed his tower by combining relatively few types of well-designed and tested elements. In a similar way OOP techniques help you to create well-designed and testable building blocks out of which you can then construct your software system. The key is that these building blocks are *isolated* from each other as completely as possible, and that using them is considerably easier, and less error-prone, than a classical Fortran function library can ever be. In this way, OO techniques help you to manage problems whose sheer size would normally make them impossible to tackle.

  186. Are you down with OOP? by Anonymous Coward · · Score: 0

    Well in the above case OOP does not seem to offer much benefit. However after programming for several years in Java I just naturally deal with problems in an OOP way (not a purist, use right tool for the right job is my motto). The biggest help is that instead of thinking of the code problem in the code space I am thinking of the code problem in the real world sense. Currently I am working on an online classroom and grouping all the code into its real world counter parts is very helpful (There is a student object that handles all the student code, a teacher object that handles all the teacher code, a reports object etc). OOP also helps with readability and code isolation, in having only the code for specific problem in the algorithm at hand. So in dealing with each specific instance of engineering problems it is probably not helpfully, but if you were to make a program that was more a library of solutions then it might come into play.

  187. paradigm shift is hard by jilles · · Score: 3, Informative

    It seems you have convinced yourself that the world should be modeled in terms of procedures. This is typical for people who have programmed using procedural languages. The same happens to people who program OO: they see classes everywhere. Then you have people who like functional languages: suddenly everything seems a function.

    The sad part is that all these paradigms have problems where they can be applied very well and none of them can be applied to all problems well.

    Now back to OO. What is it good for: it's a good way to structure complex systems. If you have a complex system, you can probably make its structure more explicit by using objects, design patterns and so on.

    Mind you, it is no silver bullet and you wouldn't be the first one to build a super complex, flexible OO everything system that doesn't perform well and is impossible to maintain.

    Symptoms that indicate you might benefit from OO:
    - There's a lot of commonalities between the programs you write: this indicates that you can generalize functionality.
    - There's a lot of dependencies between your modules: you need to encapsulate and hide stuff
    - You have a lot of complex data structures and lots of functionality around those data structures: hmm objects???

    If you are serious about adopting OO you should spent some time with books about OO design such as for example Gammma's excellent book about design patterns.

    As for your question regarding engineering problems. I have worked with companies involved in building embedded stuff like fire alarms, haemo dialysis machines (medical machines), mobile phones, digital radio systems and embedded server products. All of them use OO based designs to their advantage so it can be done. And in case you are wondering: all of these systems were very large systems (500 KLOC - 5 MLOC). Using OO is a necessity for these companies since it is the only tool they have to keep complexity under control.

    --

    Jilles
  188. OOP in structural engineering by jamisons · · Score: 3, Interesting

    I haven't worked _on_ this project but I did work with it a little bit, and tried to write a small analysis routine for a class I took. Check out the OpenSEES Project at Berkeley for a good example of a OOP solution to an engineering problem. Every portion of the analysis, from equation solvers and matrix routines to structural elements and material models are broken into objects. It's an ambitious project but it's moving quickly. And it's even open source!

  189. There is something wrong with OOP by Anonymous Coward · · Score: 1, Insightful

    I've been OOPing for several years in various languages and I've found that while OOP helps in writing larger programs, it is not the panacea that many think it is. Many of the ideas are very compelling, like inheritance, but hard to take advantage of in practice.

    I think OOP has some good ideas, but will turn out to be an evolutionary step on the way to a much better way of programming that has not been conceived yet.

    An interesting interview with a thoughtful anti-oop perspective:
    http://www.stlport.org/resources/StepanovUSA.htm l

  190. OOP & complex problem solving by thejuliano · · Score: 1

    Being a former embedded systems software engineer who did a fair amount of work in the modeling & simulation environment, I've seen a lot of engineering problems "solved" through code. And let me tell you that you're right, few if any are done in an OOP language. Why?

    Perforance, plain & simple. OOP languages (I'm simply going to use C++ in place of OOP as it's easier for me to type :) I'm not trying to imply that C++ should stand as a definition for all OOP languages) are not deterministic, and don't typically run too efficently.

    There are several reasons for this, but two stand out in my mind. Memory Management, and what I'll call Bloat.

    First off, C++ code tends to make use of a LOT of dynamically allocated memory. Lots of structures passed back and forth between procedures (methods), things on the heap, and so on. All of this adds overhead to the code. It takes time to do all of that. Just puttng a structure on the stack can result in thousnads of ops (read mem, write mem...). THen there's garbage collection (GC), this runs async to everything else and can eat up more CPU cycles you process needs to run. it may also make some sections of code run longer than others because the code has to wait for the GC to finish. Enough of that.

    Bloat. In order to meet one goal (quicker code development, and lots of reuse of code) C++ has added many layers on top of C. function tables, polymorphism, abstraction, overloading... these things all add more execution time to the code, and make it less deterministic. When I add 2 variables in C or FORTRAN, I know about how long that takes. if I do it in C++ with abstract datatypes, who knows? The complier has to generate logic that can to figure out what function to use, call it (copy the data onto the stack) perform the operation, and return the result. That logic all takes time to run.

    For solving a complicated problem in a timely manner, like say modeling the amount of radar energy reflected off the complex surface of an aircraft, and returning that result to a flight sim C++ might take too long. By the time the code figures out if you can see the other guy, he's already sent a missile your way!

    More complicated problems, like modeling a weather pattern, FEA, or hydrodynamics caan take very long times to run without all of the overhead of C++. The also tend to be fairly straight forward problems to solve, just very compute intensive. Many business apps on the other hand (which is what C++ is good at) have a myriad of nuances and abstractions that aren't comput intensive, but require lots of logic and code to figure out which path to take. Like generating the financial statements for a company. it may only be a list of numbers to add up, but where to find the numbers? what do they mean? What about depreciation, partially owned assets, and one time charges. Lots to figure out what to do with, but little calculation to be done.

    ENOUGH! that's just my $0.02

  191. Article is a Troll by Frums · · Score: 1

    Personally I would consider this article to be a troll.

    Befor eyou mod me down as a troll, think for a moment. The software engineering world is completely dominated by OOP concepts, and the foundations of OOP (encapsulation, inheritance, polymorphism) save thousands of man hours / year / developer when people understand how they actually work.

    The reason I call the article a troll is the highly C based leanings of the /. crowd. The most vocal people here still wish they were allowed to hate KDE, and love only gnome (C based Gnome, C++ based KDE) and the language of implementation carries over to general principles for most people

    And before someone says it, yes you can do OOP in ANSI C, but it is ugly as sin (basically function points on structs for methods, etc).

    -Frums

  192. Math using objects by Falrick · · Score: 1

    Example 1:Vector Math

    Ok, here is probably the simplest example of where object oriented programming can come in handy. Say that you are working with vectors. Now, vector math isn't all that complicated. You can do it rather easily through function calls, such as (in C)

    vec3 = addVectors(vec1, vec2);

    But, it can be a little nicer to have your code reflect a formula that you've developed or are utilizing. Programming the same problem in C++ (you can probably do this in other languages too, I'm just familliar with C++) allows you to change your problem to

    vec3 = vec1 + vec2;

    The way you do this is you overload the + operator (the function named operator+()) in your vector class. Your vector class holds all of the information about the vector and has operations that know how to work on that data. You could further extend your class so that you could do subtraction (vec2 - vec1), division (vec2 / 5), multiplication (vec2 * 5), translation (vec2.translate(5,5,1) ), intersection detection (vec1.intersects(vec2)) and so on.

    Example 2:Matrix Math

    The same sorts of things can be done with matrix classes. Create a matrix class that you populate with data and has operations for performing mathematical operations on that data.

    matrix3 = matrix1 + matrix2

    matrix3 = matrix1 * matrix2

    matrix1.rref();

    etc.

    Could you do the same operations using structures and functions? Sure, but it wouldn't look nearly as clean. The added benefit here is that the interface for performing these operations on your new data types (matrix and vector) are consistent. You didn't have to learn that matrix operations are carried out by matrix_add style functions where vector operations are carried out by vector_add style functions.

    --
    something clever
  193. OOP Myths by DVega · · Score: 1, Troll

    There is an interesting (and rather negative) review about OOP here (OOP Criticism).

    OOP is by no means a magic solution to programming problems.

    --
    MOD THE CHILD UP!
    1. Re:OOP Myths by the+eric+conspiracy · · Score: 4, Interesting

      There is an interesting (and rather negative) review about OOP here (OOP Criticism [geocities.com]).

      OOP is by no means a magic solution to programming problems.


      The criticism page brought up some areas that OOP has alledged weaknesses. Many of these are highly contrived. One of these examples is the issue of mapping OOP to databases, and in particular the widely used relational database model. The problem with this particular analysis is that the mismatch occurs not due to problems in OOP, but rather with the limitations associated with mapping many types of data structures to the RDBMS model. One can hardly criticize OOP becasue it maps poorly with a technology that is far more limited than OOP is. The problem is with the RDBMS model, not OOP.

      Other objections, such as data mapping from one OOP language to another are equally contrived. Already we have methodologies gaining widespread acceptance that actually do this.

      The idea that OOP will fall out of favor in 15 years or so seems rather outlandish. OOP has been around for a LONG time already (LISP dates back to the mid '50s.). OOP's record of utility is well established. It's very hard to claim with a straight face that something is a fad when it in fact has been gaining acceptance and wider use over a 50 year period, spanning essentially the total time period of the development of the practice of programming.

      It is true that OOP is not a magic solution to ALL programming problems. I would not use OOP in coding an FFT algorithm. However not having OOP in your toolbox markedly reduces the number of programming problems that you can map to working code in a clean, logical manner.

    2. Re:OOP Myths by Anonymous+Brave+Guy · · Score: 3, Insightful
      There is an interesting (and rather negative) review about OOP here (OOP Criticism).

      This is an oft-cited anti-OO article. However, it's clearly written by a very biased author, is hardly objective (no pun intended) and is littered with obvious misunderstandings about OO.

      Rather than spend hours dismantling his major arguments and point out all the flaws, I'll just post his "challenge" to the OO community to prove the superiority of OO:

      I have been asking for 3 examples of typical "small or medium custom business applications" or portions that demonstrate OO's superiority for this niche.

      I will even supply the procedural/relational version which to compare it to if you do not wish to.

      It can either be real code or pseudo-code. The example provider is responsible to answer any questions about the example. The example should be well-documented, and any oddities of the particular language used should be clarified.

      Now tell me, how many people are going to expend the dozens of hours probably required to fulfil this challenge, and then field an arbitrary number of arbitrary questions from the author as a result? Is this a reasonable challenge? Does he seriously expect anyone to take it up in earnest?

      Note also the rather gratuitous disclaimer, waaaay down (probably off most people's screens) on the front page of a whole anti-OO site:

      I have been programming small and medium custom business applications for most of my career. Most of my complaints against OO are related to this rather large niche. Perhaps OO is good for other niches; however, I cannot really answer for other niches.

      'Nuff said, I think.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    3. Re:OOP Myths by witwerg · · Score: 1

      lisp is NOT oop. Maybe you mean stimul(spelling)?

    4. Re:OOP Myths by Tablizer · · Score: 1

      (* The problem is with the RDBMS model, not OOP. *)

      And what exactly are these unrepairable Grand Flaws?

      (* Other objections, such as data mapping from one OOP language to another are equally contrived. Already we have methodologies gaining widespread acceptance that actually do this. *)

      And they are a pain in the butt--a "necessary evil" that OO zealots force themselves to live with.

      (* The idea that OOP will fall out of favor in 15 years or so seems rather outlandish. OOP has been around for a LONG time already *)

      True, but it has only been "in style" (mainstream) for about 13 years. Live by the sword of hype, die by the sword of hype.

      (* LISP dates back to the mid '50s. *)

      Whether LISP was OOP or not is highly contentious. OO fans have a habit of taking credit for anything that works.

      (* OOP's record of utility is well established *)

      Only in Zealot's annecdotes. Annecdotes prove everything.

      OO is like Chiropractory: Chiro's do the exact same thing no better than a regular doc, yet charge 3-times as much because of the cloak of BS they have conjured up.

    5. Re:OOP Myths by Tablizer · · Score: 0, Troll


      (* and is littered with obvious misunderstandings about OO *)

      Name one.

      (* Is this a reasonable challenge? Does he seriously expect anyone to take it up in earnest? *)

      You are welcome to suggest "fairer" rules.

      Ragarding other niches, at least I am not so centerUniversed that I extrapolate my nature-imposed limited lifetime experience into *every* domain.

      I agree that my criticisms may NOT apply to physical engineering.

    6. Re:OOP Myths by Anonymous+Brave+Guy · · Score: 2
      (* Is this a reasonable challenge? Does he seriously expect anyone to take it up in earnest? *)

      You are welcome to suggest "fairer" rules.

      I don't have to. I'm not setting out to prove anything here. I use OO, procedural, functional and other programming paradigms all the time, and don't find any single one to be universally superior to all others. I'm simply demonstrating that your rules -- the basis for your claim that OO is unproven -- are not fair.

      (* and is littered with obvious misunderstandings about OO *)

      Name one.

      I'll do better than that. I'll pick a few comments you make from your page, and obliterate their arguments completely. I'll try to keep any relevant context; I'm sure you'll reply if you think I've failed to do so.

      "Object Oriented Technology is a subjective philosophical paradigm only. As we shall see, it is an organizational religion that has not (so far) graduated into a proven general-purpose benefit."

      I posted a counterexample to this from my own work, just the other day. We are currently writing a large (MLOC) instrument-control application, also featuring lots of mathematical analysis of the data collected by the instruments and a pretty powerful GUI/macro language front-end. We are using C++ to do this, and our model is heavily OO based. (Actually, we've pretty much implemented a whole component architecture -- a second, run-time level of OO -- on top of C++.)

      The previous effort was written in C, by a team of experts, and took several hundred man-years to write. Our version is around 30 man years so far, and we're close to matching them feature-for-feature, with a much more powerful UI. And so far, we're still happily extending our system (mostly within the frameworks that we designed early on for the IC, analysis and GUI work). The old C-based system fell apart as far as maintainability went, and was still riddled with dozens of serious bugs to the end (which no-one knew how to fix, hence part of the reason for the new version). Their code is the type of spaghetti that is sadly common in real world procedural work, and finding your way around it is very difficult. Ours is systematic and so easier to navigate, as is typical of a decent OO framework in a large-scale app.

      Now, this is not looking at what is possible (when coded by the 2% of elite programmers in their field), it is looking at what actually happens (when you have a team of mixed ability). And it's a pretty damn compelling example of OO totally outshining procedural on a large-scale application.

      "Land of Confusion", and all that follows

      Here you make numerous clear statements about what OOP experts say, and what people think about OOP. And yet, you provide no evidence to support any of it; not a single citation is present in that section. I have never heard anyone I would regard as either an OOP expert or a developer who regularly uses OOP make most of the claims you state.

      This is typical of the style of your whole site. You frequently express your personal opinions of OOP, or what you perceive expert opinion to be, as fact, but without citing any references. You drum up some old arguments long since given up as if everyone today still believed them, and then point out where they are flawed as if years of experience with OOP hasn't already demonstrated that. At the same time, you gloss over examples, such as mine above, of projects where OOP and procedural approaches can be directly compared, and the OOP approach has worked much better. (I do not claim by any means that all projects fall into this category; they don't. I merely claim that many examples exist and you have totally failed to mentioned them.)

      "OOP often does not map well to relational databases."

      I find that ironic, given that in the above-mentioned project, we implemented a major part of the system based on a common relational database technology. The database is at the core of our whole application, and the APIs we designed to access it are still standing, with little need for change, even after nearly seven years. I would call that a remarkable success, personally.

      "If you mix the data in with methods, then you are STUCK with the current OO programming language to interpret your data. You cannot easily read the data except with the OOP language and/or program that generated it."

      WTF? How on earth did you get to that conclusion? You can write data from an OO program out to any format file you like, just as you can with procedural languages, and you can read it back in with any language using any paradigm that provides the necessary facilities. Your statement above seems entirely bogus.

      "Even if you stay with one OOP language or protocol, one has to spend a fair amount of time building OO wrappers and mappers for incoming and outgoing data that does not use the same (or no) objects as the internal system."

      Um... No. Writing a plain OO wrapper for a procedural style API typically takes a few minutes, as anyone who's used C libraries from C++ will be able to testify. Writing a good wrapper, which provides a mapping from your OO system's concepts onto the procedural API, can take much longer, of course, but adds value in the process. It's no different from a smart procedural programmer not calling, say, OS-specific APIs directly from high-level code, but providing an isolation layer to minimise problems with porting to other OSes or libraries at a later date.

      "The inheritance model of OOP tends to assume the world can be forced into a hierarchical classification structure, or at least into mutually-exclusive divisions (a flat tree), when in fact this is often not the case."

      Do you know what multiple inheritance is? I used counterexamples to your above claim pretty much every single day I'm at work. Do you know what refactoring is? You can, and should, do it with OOP code as your application develops, just as with procedural, or any other paradigm. Your argument is ill-founded.

      "Related to inheritance (above), IS-A-Mania is the excessive promotion of one aspect/criteria above other candidates."

      And yet, every serious OOP instruction I have ever experienced, in print, at a training course or from senior staff at work, has been quick to stress that inheritance should not be overused. It is a valuable tool where it is appropriate, but that does not mean that it is appropriate everywhere. Your presumption of the important of inheritance in OO designs -- the foundation of your whole argument here -- is totally unrealistic.

      "Many OO books and even some OO fans suggest that OO only shines under fairly ideal conditions. These conditions may include:
      • Sufficient training and mentoring
      • Sufficient incentives for long-term planning and/or good OO (see Planning article)
      • Sufficient understanding of the domain/task OO-friendly database system
      • Low employee turnover
      • Good code viewer/editor tools
      • Sufficient budget for good planning
      • Good project management"

      Those would be pretty similar to the "ideal" conditions for any programming paradigm. By definition, to use any tool well, you need sufficient training, understanding of your problem, etc. Otherwise, less is sufficient. Any project is better developed with by low turnover team, and with good management. Your points are not related to OOP specifically in any way.

      Oh, and I love the graph of productivity vs. a scale of chaos->typical->ideal. Did you actually have any of the metrics you so long for to support it, or was it just more gratuitous and unfounded OOP bashing?

      I've got to about halfway down the page now. I could go on, and I'm half tempted to have a go at your final conclusions, but I don't see much point. If my comments above haven't convinced people of your article's misleading and biased nature, I don't think any further discussion will. Your own opinions are obviously quite different to mine, and I accept that you're entitled to them, but I won't accept them marketed as fact without challenging them.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  194. OOP and engineering by Anonymous Coward · · Score: 0

    OOP can work very well with engineering problems in principle. The difficulty has been that most OOP languages have either been too slow (e.g. Smalltalk) or aren't that easy to use for engineers (C++ is pretty messy in terms of OOP and memory management and what you have to do to build good OOP models, in my view).

    Where OOP could help is in the extensibility of code. An example would be in molecular modelling where particles and the interactions between them fit very nicely into the OOP paradigm. The great thing about using objects is that if you want to add new particles or new interactions, you just extend existing classes. OOP tends to make finding and applying changes to a system very much easier and less error prone.

    Even with systems that are less based on 'things' such as particles, and more based on 'processes', such as calculations, OOP allows such systems to be broken down into distinct modules with clearly specified 'interfaces' between the modules, so it becomes very easy to update and extend the system.

    Java could have a lot of potential for OOP in engineering, as its a simple enough language so that the developer doesn't get distracted with memory allocation, and with the huge amount of work being put into optimization of VMs, Java is likely to match the speed of Fortran in many cases

  195. OOPs by Anonymous Coward · · Score: 0
    Managing contact lists, accounting, any business problems, no job is too small to be horked up by OOP.


    It's job security for people who don't understand business rules, e.g. programming majors.

  196. A real-world example by plsuh · · Score: 1

    Most people seem to be talking about OO and engineering in the abstract, so I thought I'd add some facts from a real-world case study. (* ducks out of the way as screaming ./'ers flee for the exits ;-) *)

    When I was a Senior Economist with the Law and Economics Consulting Group, I worked on an electricity deregulation project. We had to model the electricity market, including the flows from sellers to buyers and constraints on the flows. Individual generating plants had run rate upper and lower bounds, and there were varying loads depending on time of day and time of year.

    This was modelled by using the following main classes: electricity generating plants, utility companies, and transmission lines, plus some minor helpers. Each electricity generating plant had its own capacity and marginal cost of operation, and there were various sub-classes of generating plant for the different types: coal-fired, gas-fired, gas turbine, hydro, each of which had different characteristics; e.g. hydro plants had lower capacities in autumn than in the spring. Transactions between utilities were modelled as another sub-class of generating plant, whose capacity was the amount of the transaction and whose cost to run was the price of the electricity sale. All of this was subject to the transmission constraints between nodes.

    Utility companies had loads that they needed to supply, either using their own generation capacity or by purchased power. They would attempt to reduce the cost of supplying their loads by purchasing electricity on the open market instead of running their own plants. They would also attempt to generate additional profits by selling electricity to other utilities whose costs were higher. The market was run via multiple rounds of bidding, until the cost of electricity in all of the different areas had stabilized. There was a special case (although in the programming world no sub-class was needed) of energy marketing companies, e.g. Enron, which had no native loads that must be supplied but which did own generating plants.

    So you say, OK, why is this an engineering problem? Isn't it an economics problem? Well, it is in fact a superset of the engineering problem. In fact, there were several software packages that we investigated that -- given the operating characteristics of the plants, the transmission constraints, and the loads to be supplied -- would calculate the most cost-efficient combination of generators that could supply that load. However, none of these would have given us any insight into the necessary market interactions that would happen under deregulation. Writing our own model in C++ using OO methods enabled us not only to solve the engineering problem of supplying electricity to the region, but also to study the way that the companies would behave in a deregulated environment.

    --Paul

    1. Re:A real-world example by Anonymous Coward · · Score: 0

      and then ENRON floundered !

      No matter, like in the FAA case, in the nuclear industry for instance, if you don't rely on old fortran code for safety analyses, you don't get clearance to start your reactor.

  197. Beware Voodoo OO by dubl-u · · Score: 2

    As many other people have pointed out, it's not so much the type of problem that matters for whether or not you choose OO technologies.

    If you are by yourself, writing a small single-purpose, one-shot, low-state program that requires maximum performance, then by all means write in some procedural language.

    If you are working with a large, distributed team, writing a large, complex, high-state program where performance takes a back seat to flexibility, evolvability, and maintainability, then choosing the right OO language can help a lot.

    And if you're somewhere in between, the choice depends a lot on your circumstances.

    But if you do pick an OO language, please take it seriously and really learn how to do OO design well. I saw a team write a million-line procedural program in Java, entirely missing the point of using Java in the first place. They would have been better off using the Visual Basic they knew and loved. Or they would have been better off going whole hog and actually writing OO code in Java. But their Procedurized OOP killed them.

    Switching from a procedural style of design to an OO style of design will take you a couple of years before you're as good in OO as you were in your favorite procedural language. To get a good start, rummage around in Ward Cunningham's Wiki. And check out books like Martin Fowler's "Refactoring". Also consider using something like JUnit or CppUnit and the XP-style test-first programming, which will speed your learning considerably.

    And regardless of what you pick, good luck!

  198. Deisn patterns by StrawberryFrog · · Score: 2
    have a look at some literature on Design patterns.

    Some of these will be applicable to managing your algorithyms or making your software more flexible.

    Am I just being close minded to the ideas of OOP or do my problems just require 'procedural' solutions, which are better solved using procedural techniques?

    It is possible that your key algorythyms will remain lumps of procedural code, OO languages allow this. There is advantage in an application of any size in the judicious use of OO techniques.

    --

    My Karma: ran over your Dogma
    StrawberryFrog

  199. Modelling Data vs. Decomposing Processes by carstenkuckuk · · Score: 1

    It boils down to where the complexity in your problem is:

    - If the data structures are rich and manyfold, you model the data types first (Has-a and Is-a relationships). Then you spread your algorithms around it. That's what OOP is about in really big systems.

    - If the data structures are trivial, but the algorithms working on it are complex, you put all your energy into the algorithms, decompose them, look for coupling and reuse and end up with structured programming. Then you spread the few data structures in that you have and move them around as parameters. That's what procedural programming is all about.

    In my experience, commercial applications are rich in data structures but trivial in algorithms (only add and subtract) whereas engineering applications only have matrices as their data structures, and calculation and visualisation is complex.

  200. OOP is for D&A, not algorithms. by Anonymous Coward · · Score: 0
    Asking what good OOP is for these purposes is like asking why you should use a bulldozer to build your house, since a hammer and nail is fine for the door. Or asking how to translate this into OOP:


    for (int i = 0; i

    You use OOP techniques and patterns to model the problem domain itself, not perform simple (or even complex :) mathematical calculations. For example, if you want to turn it into a distributed application then OOP might have relevence for the management and interaction of components.

  201. Lots of excellent work... by HisMother · · Score: 1

    Look at, for example, MPQC, a parallel quantum chemistry code that several times in recent years has held the record for largest QC computation ever performed (QC is one of the most computationally demanding branches of scientific research.) MPQC is built on a modular library called SC, for "Scientific Computing," which includes all sorts of tools for parallel communications, parallel file I/O, vector and matrix math, etc. SC and MPQC are written in a very O-O style in 99% C++ (a bit of legacy FORTRAN still in there.)

    --
    Cantankerous old coot since 1957.
  202. OOP may confuse issues by leandrod · · Score: 2

    > I appreciate the concepts of OOP and see its applicability in managing records

    Then unfortunately you haven't quite understood neither OOP, nor databases -- and databases are essential to many kinds of programming, including engineering.

    Please read http://www.firstsql.com/dbdebunk/, as well as Fabian Pascal's articles at http://searchdatabase.techtarget.com/tipsIndex/0,2 89482,sid13_tax284872,00.html -- there are also some interesting articles at http://dmoz.org/Computers/Software/Databases/Relat ional/ and subdirectories, including an early version of the Third Manifesto.

    --
    Leandro Guimarães Faria Corcete DUTRA
    DA, DBA, SysAdmin, Data Modeller
    GNU Project, Debian GNU/Lin
  203. example of OO in engineering by parker9 · · Score: 1

    http://ptsg.eecs.berkeley.edu/ has a plasma PIC code based on OO principles.

    i agree w/ others- you seem confused about what OO actually means, though i won't beat that dead horse.

    as a physicist, i'm using f90/95 so that i can keep the fast fortran compilers (and yes, fortran is still faster than c/c++ in heavy floating point calculations w/ functional calls- sin, exp, etc.) and yet still use OO methods to keep things contained and portable.

    to take your heat transfer. that's a simple elliptical equation. so is Poisson, Laplace, diffusion, etc equations. so i have an object that does just that, given a list of 'structures', the object constructs a mesh, constructs the finite difference (or element) coefficients and then solves the bloody mess. so from the rest of the code, all i have to do it get.field(structures) or get.temp(structures) and either Poisson or the heat equation is solved. the calling routine doesn't know how this is done and it doesn't matter. the object itself decides what type of mesh (structured/unstructured) depending on the equation and shapes of structures. there are sub-objects for individual numerical precedures (e.g. cg for symmetric matrics, ADI for structured mesh, etc.).

    it's elegant in the sense that you can seperate the nuts and bolts of numerics from the physics. the main code is usually very readable (who reads comments anyways?). once you have the objects and sub-object debugged- they are portable and don't have to be touch.

    OO is a wonderful way to go for physics problems when you're faced w/ writing a large code which will have to evolve in time in ways you can't possibly predict. which is what i seem to do...

  204. Haskell by Mandrias · · Score: 2, Informative

    Haskell is an often overlooked yet interesting and powerful procedural language. I've used it for some engineering math and also implemented an ARM processor VM with it for a class. Just thought I'd mention it :)

    --
    Use the Z-modem protocol between Information Superhighway routers to compress the plaintext. ~LordOfYourPants
    1. Re:Haskell by Anonymous Coward · · Score: 0

      > Haskell is an often overlooked yet interesting and powerful procedural language.

      I believe you meant Funcional, not Procedural.

    2. Re:Haskell by Mandrias · · Score: 1

      Yes I meant functional.. Silly me. I tried too hard to say the right thing that I said the wrong thing.

      --
      Use the Z-modem protocol between Information Superhighway routers to compress the plaintext. ~LordOfYourPants
  205. My $0.02 by Amazing+Quantum+Man · · Score: 2

    While OOP has some advantages in a traditional setting, where it really shines is when you use OOA/D (OO Analysis and Design) as well. If you do a traditional functional analysis and design, then you get a procedurally oriented design. Any OOP benefits you get out of that will be minimal.

    However, if you do OOA/D, then you come up with an object-based design, and at that point using OOP really helps a lot.

    The question then becomes one of how do you want to perform your requirements analysis. If your requirements are strictly functional, then you don't get much benefit.

    On the other hand, even with a functional design, you can still benefit from some features of OOP (the Pipe/SquarePipe/RoundPipe examples above come to mind).

    As several people have mentioned, if you can factor your problem and find the commonalities (remembering to distinguish IS-A relationships from HAS-A relationships), you may be able to take some advantage.

    Many of the problems you mention (Monte Carlo simulation of XXX, finite difference solutions to DiffEqs, etc...) are at too low a level to use OOP. If you look at them, they're really more a means than an end in and of themselves. The question you need to look at is, "What am I using these low-level 'primitives' to do? What is the big picture?"

    For example, you mention radiative heat transfer. Maybe you're designing an engine. You could put the (procedurally oriented) radiative heat transfer routines inside the Radiator object (note, I have no background in engineering -- I'm guessing...), and use it that way in an OO manner.

    However, in the end, it all comes down to your analysis and design.

    Incidentally, there's one more thing to consider: IF IT AIN'T BROKE, DON'T FIX IT! I know that engineers have tons and tons of debugged, working FORTRAN code. If you use that, you don't have to worry about the typo you made in re-implementing the FFT.... Always a consideration.

    --
    Fascism starts when the efficiency of the government becomes more important than the rights of the people.
  206. OOP Fortran 90 Standard exists !!! by Anonymous Coward · · Score: 0
    WHY hasn't anyone here mentioned that OOP Fortran is standardized, and available in all comercial compilers!!!


    OOP was introduced with the Fortran 90/F95 standards. This is included in EVERY commercial compiler. Unfortunately it is not in the GNU F77 compiler which no-one seriously uses. Even "Numerical Recipies" has been updated to the new standards.


    I have programmed in most modern languages starting with C++. Transition to F90 is very easy. The key features are Data/Function objects and Operator overloading. While the true OOP purist may not find "Garbage Collection" or advanced inheritance, OOP Fortran is plenty "Good Enough" for real world problems. The old F77 standard is used only by people who "don't know any better". The advantage of Fortran is its powerful out-of-the-box matrix handling. Since matricies and vectors are native concepts to fortran, it can run far more efficiently on super computers. No other language expept perhaps IDL have these features.


    I would NEVER program any substantial scientific analysis program in C++ or JAVA. Fortran has 30 YEARS of math/science library routines built up. Nothing like this exists in the C++/Java worlds. Most C++ advanced math libraries (there aren't many) are just ports from fortran.


    Sadly, I see a real push away from Fortran promoted mainly by CS departments. Through 4 years of engineering school at a major university, I never heard even one thing about Fortran 90. It is sad since Fortran really has kept up with the times. The problem is that Fortran 90 is backward compatible with F77 so there is usually more than one way to do things. (Like C++ is backward compatible with C) Another problem is that the F90 language arrived somewhat late, which gave C++ a foothold. Still, without question OOP based F90 is THE PREMIER language of scientific computation.

  207. Engineering Programming Language by clary · · Score: 2

    Question: What programming language will engineers be using in 20 years?

    Answer: I don't know, but they will call it Fortran.

    (That joke is funnier if you were around when Fortran 8X, er 90, came into being.)

    --

    "Rub her feet." -- L.L.

  208. Two big benefits of OO by adamy · · Score: 1

    Design Patterns and Refactoring.

    Design patterns help you to orgabnize your code. Refactoring allows you to postpone doing so until it is required.

    You write code to solve a problem. As an engineer, you write it procedurally, focusing more on the process than on the objects. That is OK. You are not really happy with it, but it does the job.

    Now you come across another problem. Really similar, but slightly different. You have two choices. (Well more, but I'll focus on two)

    Copy the old code, change the few places that are different. Solve the new problem.

    Or, you apply a refactoring. Perhaps the difference is just a process that needs to be run . Extract it into it's own method, extract the moethod into an object, swap it out, and you have a strategy pattern. Or perhaps it is more complext than that, there are 4 or five steps to be completed, but details are different in each place. Refactor to a template method.

    Or where input before came from a file, it now needs to come from the network. Abstract your input, and extend using inheritance. Now you can have file input, network input, and others as they come up.

    Or your buddy next lab over has a really cool process he cobbled up that you can use but your code initializes a complex object one way, his another. Adapter, Builder ,Abstract Factory...all these are tools to help you use and ruse code that get's the job done. Refactoring allows you to get there from what you have.

    It breaks my heart to hear that they are no longer requiring ADA. Although I only learned the pre 95 version, it was my intro to OO, and I find it shares many of the things I really like about Java. And, without the Sun issues that bother so many. It really is a nice language

    --
    Open Source Identity Management: FreeIPA.org
    1. Re:Two big benefits of OO by Anonymous Coward · · Score: 0

      Design patterns help you to orgabnize your code.

      Is this an Apple thing?

  209. nearly useless by cerberusti · · Score: 1

    The point of OOP is to protect you from yourself. There is nothing you can do with OOP that cannot be accomplised in structural or procedural languages. For instance a class in C++ really gives you nothing more than a structure and functions designed to operate on that structure in C. The difference being that the programmer must use the member functions to manipulate the data (unless they are public of course). This is more of a hinderence than a help on complex problems, as there are times that you will need to make many small manipulations to the data but, they do not need to be reused (making them worthless as a function, unless you think it makes the code clearer in some way.) Stick with C for complex problems. Use C++ when the staff is inexperienced (or not very good), or when your problem will fit very nicely into an OO framework (which does not happen often with complex problems.)

    --
    I'm a signature virus. Please copy me to your signature so I can replicate.
  210. Its great for global variables- "wink" by LM741N · · Score: 1

    When I port a C program into Python, I take the 100 global variables and make them members of a dummy class, so I only have to feed 1 variable into each function. Oh the wonders of OO :) :)

  211. Operator overloading != OOD by Invisible+Agent · · Score: 2

    Operator overloading is just syntactic sugar, it has nothing to do with object-oriented development. There are a number of non-OO languages that implement this feature. I dislike most uses of operator overloading anyways. Sure, it may "look cleaner" for the above trivial examples, but with multiple overloads and implicit casts, it can be difficult to figure out which function ends up being called. Better to keep things as explicit as you can.

    The definitive benefit of object oriented languages is caller-reuse as implemented through polymorphism. In procedural programming, I can reuse called code (a.k.a. functions), but in OO programing I can reuse *caller* code. The shapes example is great to illustrate this: if squares and circles both inheret from a base shape, who implements a "draw" function, I can easily add triangles later, pass them around as references to the base class "shape", and any code that asks a shape to draw it self remains untouched, whereas in procedural programming I have to touch each instance of code that has to do with drawing, and account for the newly added triangle case.

    --

    Invisible Agent
    This post is a mirror; when a monkey stares in, no hacker gazes out.
  212. financial software by soldack · · Score: 2

    I used to write financial software in C++. We has objects for Interest Rates that handled conversions to and from various types (Annualized, Continuous, Bond Equivalent Yield, etc) and could work as normal double floating point values. We had a class hierarchy for option evaluation functions. At the base a parent class had the features common to all options and their evaluation formulas. Children classes then implmented specific evaluation formulas. Sometimes tweaks were needed to those formulas for specific situations and another level of inheritance was used. We found that the OO C++ code was much easier to maintain and add on to then the previous functional C version.
    As other posters have said, to really use OO you have to break the problem down into objects. What are the features of these objects? What do they do? How do they interact? Another good idea is to see what certain objects have in common. This allows you push these common features and functions into a parent class that both objects inherit from.

    --
    -- soldack
    1. Re:financial software by Tablizer · · Score: 1

      (* I used to write financial software in C++. We has objects for Interest Rates that handled conversions to and from various types (Annualized, Continuous, Bond Equivalent Yield, etc) and could work as normal double floating point values. We had a class hierarchy for option evaluation functions. *)

      I find that it is best to make the various sub-features *indepedent* rather than force them into a tree-structure. (Disclaimer: I am *not* a financial expert.)

      Yes, almost anything *can* be forced into a tree structure, but trees are often not the most appropriate way to manage incrimental variations of things in the long run. Unless there is some natural force that herds changes into a tree pattern, real-world changes/differences are best represented as graphs or sets.

      Otherwise, you get creeping vines with duplicate nodes or major refactoring.

  213. Pardon my ignorance but... by Codifex+Maximus · · Score: 1

    What is the difference between C as a procedural language and C as a functional language.

    As far as *I* know, C is functional language being that every part of it is a function. What makes a language procedural anyway? When you really get down to where the rubber meets the road, all code is procedural is it not?

    --
    Codifex Maximus ~ In search of... a shorter sig.
    1. Re:Pardon my ignorance but... by FigBugDeux · · Score: 2, Informative
      here is the comp.lang.functional faq entry to answer your question:

      http://www.cs.nott.ac.uk/~gmh//faq.html#functional -languages

    2. Re:Pardon my ignorance but... by Codifex+Maximus · · Score: 2

      From the web page you referred to:
      Functional programming is a style of programming that emphasizes the evaluation of expressions, rather than execution of commands. The expressions in these language are formed by using functions to combine basic values. A functional language is a language that supports and encourages programming in a functional style.

      Hmm...

      So, given this definition, a functional programming language is one that uses canned or prewritten functions to evaluate expressions on a higher abstraction level than "procedural" languages such as C.
      These "functional languages", you mention, appear to have alot in common with spreadsheet style functional representations... I might have to take a closer look at them... Thank You.

      --
      Codifex Maximus ~ In search of... a shorter sig.
    3. Re:Pardon my ignorance but... by Anonymous Coward · · Score: 0

      Canned or prewritten functions are not what make a language functional. A procedural language is one that describes a series of procedural steps that alter some sort of state. A functional language is one that composes a set of expressions that return values.

      Either kind of language can more or less emulate the kinds of things the other can do, so the easiest way to tell them apart is to imagine a procedural language that is not at all functional and a functional language that is not at all procedural. A 'pure procedural' language would be one that has no concept of function calls and return values, just a program counter and a store that program instructions can change.

      A 'pure functional' language would be one that has no store to change, only functions, parameters, and return values.

      Either one is turing complete, so picking functional or procedural just depends on how well one or the other works for your purposes.

    4. Re:Pardon my ignorance but... by Anonymous Coward · · Score: 0

      You're missing something.

      Procedural languages, or more properly, imperitive languages like c, focus entirely on the "how".

      Functional languages *describe* the "what". Much of the "how" is often left to the compiler.

      More specificly, imperitive languages have assignment statements, and represent computation by commands which change the state of the system.

      Functional languages on the other hand, have no assingments. Any constant variable keeps it's same value. Any variable who's value could concievibly be different things is described by the functions that determine that value.

      No where do canned or prewritten functions enter as a distinction between the two.

      Another distinction is that in functional languages, you often can return a function just as you'd return a value. This is something that clearly isn't possible in c.

      In the real world, there are languages that blend the two, like OCaml. However, to people aware of the terminology, calling c a functional language would be incorrect. It's functional in the sense that it has these things called functions, but nearly in the same sense as scheme, SML, Haskell or the like.

  214. Some OO scientific programming examples by fxj · · Score: 1

    OO and functional programming is not so new in the scientific (numerical) community. Take for example IDL (from Reseach Systems), a scripting language very commonplace in astrophysical data analysis: Data arrays behave like objects with their own methods.
    Another example is vtk (visualisation toolkit) from www.kitware.com: a numerical visualisation library that can be used from c++, tcl, java and python.
    And speaking about python: the numerical extension NumPy is very OO, too. (or check out scipy.org)
    I also know about some large plasma simulations that are written in c++ using oo-techniques.
    The problem is that many scientists are still using code from the 80's written in FORTRAN 77.

  215. Fortran vs OOP and numerical computing by TopherC · · Score: 1
    As a physicist, I use Fortran a lot. I don't enjoy programming in it, but I do a lot of it because I'm working on a large experiment with tons of legacy code going back 20 years or more. The way I get my kicks, so to speak, is by doing as much as I can with Perl. I probably spend half my time programming in Perl, and the other half in Fortran. These are a great combo, since Fortran is great at the heavy-lifting (numerical stuff), and Perl is great with everything else. But I digress.

    OOP techniques can provide amazing advantages for numerical computing, and I'm surprised that there isn't more written about it. When you deal with scientific computing, it's a combination of numerical computation and the usual comp-sci stuff figuring out how to implement simulations and the like. For "the usual stuff", we know very well how OOP can help. But for numerical programming, the benefits are still there.

    In numerical work, you deal with a variety of mathematical objects such as complex numbers, vectors, matrices, tensors, algebras, and so on. In working with the math, we tend to use the more sophisticated objects because they are easier to deal with (laziness) and more meaningful. But when you go to code it up in, say, Fortran, all the beauty vanishes and the nitty-gritty details become a menace. Or, you could use OOP and make up things like vector classes, matrix classes, and so on. Then the code suddenly becomes simpler, you save a little time writing the code, and make many fewer mistakes. The code looks more like the math.

    I hear that rogue wave makes some very fast C++ libraries for numerical work, though I haven't used them personally. There are other collections out there as well, I'm sure. My main beef about other languages such as C++ and Java is that there is a blatant lack of concern for numerical programming. Here are some rants:

    • Complex numbers: In C++, there are a variety of ways of handling complex numbers, but there is no standard as far as I can tell. So by using complex numbers in C, you aren't writing portable code.
    • Powers: This is an old issue. Why on Earth can't modern compilers handle integer powers efficiently (Fortran's ** operator)?? You must realize that in numerical work, you use **n operations about half as often as addition and multiplication!!!
    • down-casting: 1.8 / 2 = 0? In Fortran, binary operators taking different types of operands generally do the "right thing" which is to promote integers to floats, floats to complex, single precision to double, etc. C and other languages do the opposite, which is almost always NOT what you want! This must be the #1 source of bugs in C numerical code.

    I hate Fortran, I really do. But when doing pure numerical work Fortran's actually a lot better than most other languages I've seen. There's no good reason why other languages couldn't be reasonable in this regard.

    Okay, I'll admit that the only two genuinely OO languages I know are Java and C++. And these both derive much of their behavior from C, which is not a very "modern" language any more. But it is still a lot younger than Fortran. (Yeah, Kernigan and Ritchie were going for speed and simplicity in the mid-70s, I understand.) Anyway, in spite of wanting to borrow syntax from C, why can't anyone simply decide to improve on the bad old features of C like those mentioned above?

    Whew, okay. I'm done ranting now. I feel much better.

  216. OOP and Quantum Mechanics by Alien54 · · Score: 2
    IBM had at least one paper looking into OOP and it's relationship to Quantum Mechanics. The best paper is entitled "Is Schrager's Cat Object-Oriented?", which you can download as a pdf, etc. (yes, that is the name of the paper on the site)

    This may be useful in the broader perspective of applying OOP to real life. Their are plenty of papers up on the IBM site that are worthwhile, even if searching for them could be inconvenient.

    --
    "It is a greater offense to steal men's labor, than their clothes"
    1. Re:OOP and Quantum Mechanics by bsd-mon · · Score: 1

      Also, the GEANT 4 toolkit from CERN is used for high-energy physics simulations and is OO-C++
      Geant 4

      --
      To read makes our speaking English good. - X. Harris
  217. OO is happening in engineering by Billy+the+Mountain · · Score: 1
    Look at:
    MOUSE (GPL) -- an OO framework for finite volume computations on unstructured grids.

    Also, finite element analysis comes to mind as a fertile realm for OO. In fact there's a book on it:
    Object Oriented Methods and Finite Element Analysis

    --
    That was the turning point of my life--I went from negative zero to positive zero.
  218. Re:I think it's a problem of scale and understandi by 7dragon · · Score: 1

    Great explanation. Succinct and informative.

  219. Many algoithms are easier to code in OO. by Naked+Singularity · · Score: 1

    I'm an engineer who programmed for many years in Fortran, was interested in OO languages, but always reverted to Fortran for real work. My first real OO code was a library to do Automatic Differentiation for uncertainty analysis. This has been done very successfully in Fortran 77 (ADIFOR for example), but the result is essential a preprocessor that reads a Fortran code and outputs new code Fortran code with extra statements for calculating derivatives. In an OO language that supports operator overloading, such as C++ or Python (not Java), no preprocessing step is needed, you just redefine math operations and functions to include the calculation of derivatives. In all, a much cleaner, easier and more elegant solution. Functions and operators for matrices and even more complicated data structures are relatively easy to develop and can really simplify programs that are written to solve engineering problems.

    Since this first effort at using an OO language I have since given up on Fortran to write engineering code. I mostly use Python (which has a very good numerics library) and occasionally use C or C++ when extra speed is needed. I really hate going back to Fortran because it now seems so restricting. I personally would recommend looking at Python as very nice OO language for engineering calculations.

  220. Bad example? by Anonymous+Brave+Guy · · Score: 4, Interesting

    Sorry, but I think that's a bad example. Using an OO design has gained nothing over a simple function or two here, but has probably generated much more clutter as a result.

    If I dared propose a more appropriate example in a similar vein, one thing OO is quite good at is providing and working with a representation for complicated and interrelated data items, such as a mathematical expression. Suppose I'm writing a mathematical tool to process these. I will represent an expression as an object of type Expression. Subtypes of that might be ConstantExpression (representing a numeric constant, say 2 or e), AdditionExpression (representing a+b, where a and b are themselves Expressions), etc.

    Now I have a clear structure for representing these, I can parse whatever input I have into this format, and work with it. Need to display it using pretty graphics? No problem, add a Display() method to Expression's interface, and provide a suitable implementation for each subtype. Need to evaluate the expression? Eval(), here we come.

    So far, so good. You've used OO to provide a nice representation of a problem, at least as clearly as a procedural solution would have done. It's pretty much a draw so far, and a matter of personal preference which style you prefer.

    However, the OO framework is much more easily extensible than its procedural counterpart. You can add new subtypes of Expression, and have them immediately fit into your existing framework, without changing any of your existing code (or even having access to it, for that matter). To do this procedurally, you often wind up writing some clever switching logic, but OO does it all for you behind the scenes.

    It's also easier for the outside world to work with your code, because you can provide nice, clean interfaces, such that all Expressions look the same to the outside world, however they are composed.

    Finally, this approach helps organise your code. If all your types of Expression provide an Eval() interface, the implementation of that interface is in a known place, and probably quite straightforward for each subtype. This maintains a degree of clarity that is easily lost when you don't have the organisational framework an OO design supports.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  221. Templates and OO by Anonymous+Brave+Guy · · Score: 2

    I agree with most of what you wrote, but I think bundling C++ templates in as "fluff" is grossly unfair. Templates are responsible for a lot of the good things about C++, and many of those aren't necessarily OO at all. The ability to write generic algorithms, but also specialise them for cases where's it's useful, is a godsend to those writing mathematical functions. The use of expression templates to generate highly optimised code with no programmer effort means C++ programs can now equal or beat the sort of code produced by a decent FORTRAN compiler. And, of course, the use of class templates means you can define generic mathematical structures such as matrices over any type you like, which makes such structures far more useful than vanilla OO designs would allow. Finally, there is the use of templates to provide traits classes, policy classes, and other tools of general use. None of these things is "fluff" if you're trying to develop a serious application!

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  222. Some facts by Anonymous Coward · · Score: 0

    First of all, as it's been pointed out a million times: OO doesn't necessarily mean C++!
    I've worked with C++ on a very large 3D application, Maya (3D packages are one of the best candidates for OO design) and I decided that C is a much better solution for this type of an app.
    You can create OO solutions extremely well in C!
    Having 8+ years of experience in the field, I would actually argue that you can do it more efficiently in C than in C++!

    Some facts & numbers:
    A few co-workers of mine are using C++ for a moderate sized (both for functionality and code size) project that's about 30K lines of C++ code.
    Compile time: ~2min 40sec

    I'm working on a quite large 3D application in C that's about 10-15 bigger as far as functionality goes and is composed of about 300K lines of dense C code (tons of objects, template functions, embedded macros etc.).
    Compile time: ~ 2min 30sec on the same system!!!
    I find it a lot easier to keep track of things, to reuse code and to debug the application.
    And the users definitely appreciate the fact that it starts up in 1-2 seconds with about 50 plugins loaded at runtime
    :)

    This 3D app would DEFINITELY NOT have this much functionality and/or would not be as stable as it is, had I developed it in C++. If for nothing else: sheer COMPILE TIME!

    I know that C++ is "fashionable" nowadays, but I think, it is being way over-used.
    Though I'm sure it's a better solution for some projects...

  223. I wish my FORTRAN code was OO by RexRuther · · Score: 1

    I maintain an old mechanical engineering simulation package that was originally written in FORTRAN 66 way back in the 60's. It is a major pain in the a$$.

    It uses "arithmetic if's" and "gotos" which really generate spaghetti. It also uses a huge "common block" for global data (which is basically every variable). Any function or subroutine can change any global variable. Variables have different meaning at different times in the program to save memory. Fixed array sizes. The list goes on and on.

    I wish we had the budget to move this beast to C++ where it would be easier to add features to objects without having to delve into the guts of the program to make changes.

    The program is fast at what it does though ;)

    --
    -"The early bird catches the worm, but the late bird sleeps the most"
  224. huh? by samantha · · Score: 2

    This actually made Ask Slashdot? Why?

  225. Fortran - OO is not a direct path ... by Anonymous Coward · · Score: 0

    Which is why you can't see OO for what it is.

    Now, looking at the disassembly of OO programs makes it clear that the only real functionality difference between C and C++ programs is that a "this" pointer is sometimes passed around. The purpose of "this" is to associate an "instantiation with the currecnt context". Or said in another way, its a conventient way to solve some re-entrancy and multitasking problems.

    Now of course the higher level OO paradigms added, like namespaces, templates, derived classes and so forth are nice. However, they are all just some syntactic sugar that hiding what is essentially just the C language.

  226. Can OO Programming Solve Engineering Problems? by Anonymous Coward · · Score: 0

    As an intermediate solution I would suggest that you take a look at the more modern variants of FORTRAN. In particular, I just recently finished a rather large project which was written in Fortran 90 and found that it has some very nice object-oriented'ish properties that were very handy. It was a good deal less extreme than going to a true OOP language.

    However, I should comment that some of the big accelerator codes (check out the work done at www.lanl.gov - Los alamos accelerator code group) using MASSIVE oop to push billions of particles
    are written (I believe) using OOP languages and
    symplectic maps...It's really quite amazing what they've done.

  227. Practical example by Miau · · Score: 1

    Imagine that you want to simulate the thermal behavior of a solid. You can build an object, a class if you want, called "solid". Then define a method (procedural programation) to simulate radiation exchanges, another for conductive ones and a third method for convectives. The way OOP can help you is that if you want to simulate the thermal behavior and ink per page consumption of a pen, you can create an object called "pen", write down the code for the ink part of the problem, and just instruct that your "pen" object is a "solid" kind of object, making use of the existent methods for such an solid object. Imagine that you want to simulate the thermal behavior of a solid. You can build an object, a class if you want, called "solid". Then define a method (procedural programation) to simulate radiation exchanges, another for conductive ones and a third method for convective. The way OOP can help you is that if you want to simulate the thermal behavior and ink per page consumption of a pen, you can create an object called "pen", write down the code for the ink part of the problem, and just instruct that your "pen" object is a "solid" kind of object, making use of the existent methods for such an solid object.
    Read Marx Mrvelous answer at Jan 03 11:38 AM

  228. Business strength (tighter binding to domain) by ratajik · · Score: 2, Insightful

    One strength I've seen with OO isn't in the pure programming realm, but more in the business realm. You build objects based on the domain you are working in, whether that's banking, accounting, games, whatever. The terms you use, and how the high level objects fit together and interact can be more closely aligned to the domain you are working with, compared to procedural languages. This allows a developer to more easily verify that what they are developing is actually what is needed (easier to check against the domain), and also allows non-techies to look at the object model and be able to understand what's going on (again, because it's modeled directly to the domain, in the terminology of that domain).

    There's lots of other good things about OO (which others have already pointed out), but this one strength is something I've seen work on several projects. Many of these other strengths are in more of the pure technical realm, but the business-oriented strength is one that can be overlooked, but is still important

  229. I worked on one by periclytos · · Score: 2, Informative

    go to www.dromeydesign.com
    our main product "DESS"
    is all Object oriented
    where we model entire power systems in an oo model

  230. Fortran by Anonymous Coward · · Score: 0

    Regarding the SQLPlus code written very Fortran-like, Doesn't the saying go "A FORTRAN programmer can program FORTRAN in any language"

  231. OO Strengths by radtea · · Score: 1

    I've been doing OO programming in physics and engineering (mostly Monte Carlo simulation, but also statistical analyis of data) since the late '80's. The trick is to reconceptualize your problem, which is independent of the language you're writing in. My early OO efforts were in FORTRAN77 and C, now long abandoned in favor of C++.

    I've since seen a lot of what passes for OO programming in the sciences, and most of it isn't--it's thinly disguised procedural programming with clean and well-specfiied interfaces.

    The difference between OO and procedural programming at the design level is the way in which programs are structured. Procedural programs are at their core a collection of algorithms that operate on data. OO programs (should) have at their core representations of real-world objects, with neither data nor algorithms being the primary abstraction. The be an object a thing must have both state (data) and behavior (algorithms).

    We are still in very early days yet in applying OO principles to science and engineering problems. Even "OO" numerical libraries are to my mind a very, very small step: they represent traditional, procedural algorithms in slightly richer and more maintainable ways. Having a matrix "object" for instance, is a definite gain ove having a flat array and bunch of procedures that work on it, but the success of the STL suggests that generic programming is a much better approach to this sort of problem than OO programming.

    The place where OO programming will come to the fore is in allowing rich and intelligent representations of real-world objects in engineering software.

    For example, I once wrote an OO layer overtop of a Levenberg-Marquardt minimizer that allows me to represent the objective function in terms of physically meaningful components that can take constraint objects that prevent the minimizer from entering physically impossible parts of the parameter space. In one sense this is a trivial problem, but in a larger sense it allows me to quickly specify components and constraints without ever having to think about array indices and other error-prone nonsense.

    It is this aspect of OO--its ability to produce rich and natural representations of complex problems--that we have hardly begun to explore, and where the real strength of the approach lies for science and engineering.

    --Tom

    --
    Blasphemy is a human right. Blasphemophobia kills.
  232. Two books on the subject by Anonymous Coward · · Score: 0

    A couple of books on the subject, available from Amazon.com:

    Scientific C++ : Building Numerical Libraries the Object- Oriented Way by Guido Buzzi-Ferraris

    Scientific and Engineering C++ : An Introduction With Advanced Techniques and Examples by John J. Barton, Lee R. Nackman

    I've got Scientific C++. Its not bad. He gives an idea of creating matrix classes and solvers to greatly simplify the writing of even procedural matrix problems.

    Its been so long since I've had creative input to slashdot that I forgot my nick. :)

  233. Look into MVC by Xi · · Score: 1

    Look into the model, view, controller paradigm. It seems this is well suited toward OOP and could apply to a variety of mechanical systems.

  234. OOAD by ScroP · · Score: 1

    The biggest problem people have, in my expirence, is in applying OOAD correctly to the domain they are working in. You can model anything you want to using OOAD but it can often take some time and a good deal of knowledge about whatever field you are working in. It can be hard to find talented people who also have enough knowledge about what specific engineering task you have them writing software for.

    Although that is the biggest problem I have noticed, I don't think its a problem of OOAD at all. You run into this problem using any programming method. Its not a problem of OOAD at all.

    OOAD can be applied to problems in any field. However, OOAD does not solve any problems itself. Its a method modeling and developing a solution. OOAD is not specific to any programing language in particular, think of it more like a methodology. You still need to create an efficetve solution. Its a tool for doing that, not a solution in and of itself.

    If you can map out some goals of what you want, I don't see why you should not be able to produce an effective design to do it. There are many sources of information about this (you can find links to quite a few on http://www.cetus-links.org)

    If your not comfortable with object oriented design, then I would suggest that the problem may be in choosing a problem solving approach you are not comfortable with; and not a problem with OOAD itself. If the people who will be ultimately responible for maintaining this software are not OO people, then it doesn't seem like the right tool for the job. You can't attribute that problem to OOAD, though.

  235. Confucious say . . . by Anonymous Coward · · Score: 0

    Why use sledgehammer to swat fly?

  236. A real OO application to Engineering by Anonymous Coward · · Score: 1, Informative

    C++ contains a special type of construct called a template which can be used in a "who would have thought of that" way to perform math functions like FFT's and sorts EXTREMELY quickly.

    They are called template metaprograms and what they essentially do is completely unroll large mathematical operations at compile time and give you a big blob of machine code that is hardcoded to do your operation. Todd Velhuizen seems to be the patron saint of these constructions, and he claims in the links below that a metaprogrammed FFT runs at 3 times the speed of an optimized regular FFT routine. The caveat seems to be that the larger the operation (like a sort for 100 elements as opposed to 10) the larger the unrolled code generated, and hence the lower the processor cache hit rate and the less that things like function call overhead (which unrolling completely removes) matter. Here are some good links to the subject:

    http://www.ddj.com/documents/s=958/ddj9608d/9608d. htm

    http://osl.iu.edu/~tveldhui/papers/Template-Metapr ograms/meta-art.html

  237. OOP is good for DTS by frank_adrian314159 · · Score: 2
    Discrete Time Simulation systems can make very good use of OOP. Events, event queues, and models are much more extensible and maintainable in this type of system. This is not surprising, given that the first somewhat OOP language, Simula, was designed for just these purposes.

    However, if you're looking for flat out performance, even these kinds of simulation systems are still better done in FORTRAN. It's just that unlike fluid dynamics models, the models in most DTS's change over the lifetime of the program (just as the core algorithms don't), so maintainability is more of an issue.

    --
    That is all.
  238. Don't restrict yourself by mav[LAG] · · Score: 2

    If OOP seems like overkill for small and specific engineering problems but you're facing the problem of maintaining and enhancing a large procedural code base, then there's a nice solution.

    One of the most efficient ways of tackling this kind of problem is to keep your existing investment in procedural code but wrap it using a scripting language - preferably something like Python. Python has enough classical OO built in to keep your front end clean and maintainable but interfaces easily to programs written in C or C++. There are also tools to do this wrapping automatically for you. Your engineering data and equations will just look like normal Python objects but of course run at the same speed - minus a small amount of call overhead.

    Example: after experimenting with Ken Perlin's source code for the 1, 2 and 3d noise which now bears his name, I found that the code was becoming hard to maintain and enhance without changing bits all over the place. Messy. Rewriting it all in Python or C++ would have been a pain because it was optimised C with lots of inline Asm. The solution was to keep the existing code base doing what it did best - calculating perlin noise functions at full speed - and just create a Python wrapper for the interface functions. In the end I got the best of both worlds - Python kept the frontend testbed clean and easy to maintain, the back-end code was unchanged. Time taken to convert the lib - a couple of hours reading the Extending and Embedding part of the Python manual.

    Try it - you might like it. I don't know if Python talks to Fortran though.

    --
    --- Hot Shot City is particularly good.
  239. C++ is not OOP, C is not procedural !!!! by Zero__Kelvin · · Score: 3


    One of the most common misconceptions in the industry is that C++ is 'an OOP language.' For that matter, it is similiarly incorrect to label C a procedural language. Paradigms like Object Oriented or Procedural are exactly that ... paradigms ... ways of thinking about problems.

    The first C++ compilers were merely front ends for C ones, which took C++ constructs and generated C code, which was then compiled and linked into an executable. It is true that C++ was developed to assist in making OOP constructs with clarity and ease (let's not argue the success or lack therof here, please.) Still, nothing stops one from OOP modelling in Assembly Language and procedural was always openly supported by Bjarne Stroustrup when he invented C++.

    You call the problem on the head when you say "I cannot, however, convince myself that there is a clean way to use these concepts to solve the type of procedural problems that I have encountered in the past." When your problems lend themselves to procedural solutions then you want to think about them that way, just as when your problems lend themselves to Object Oriented models, you want to model them that way.

    The right tool for the right job. If you want to implemet a Fast Fourier Transform you want to look at it procedurally. If you want to model a Robot, in which thousands of components performing those FFTs interact, you probably want to take your procedural code, wrap it in some Object Oriented code, and get your model.

    OOP and Procedural are complementary analytical methods, not competitors. It is an abuse on the part of any software engineer to view or discuss them otherwise!

    --
    Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
  240. Re:OOP Fortran 90 Standard exists !!! Mod him up by Lawrence_Bird · · Score: 1

    Amazing it took as long as it did for somebody to state that OOP existis in FORTRAN.

  241. some OOP examples in science/engineering by Anonymous Coward · · Score: 0

    I have actually written a couple of optics/engineering type programs for work using OOP.

    1) A data modelling program. The program reads large data files and creates an object using each one as input. The object type is based on the needed curvefitting/modelling algorithm for the given data set. The advantage of using OOP here is that I am currently developing new curvefit algorithms and data models, and the object based structure of the program allows the main program to remain essentially unchanged no matter how many different models are included in the program. It has allowed me to do some detailed comparisons between the accuracy of the various models. Procedure/Function based programming would do just fine, but OO based allows me a bit more flexibility.

    2) A large scale development project that I hope to spend more time on in the future: A software package allowing one to develop photolithographic masks. In a certain sense it would have some limited CAD capabilities, but would allow one to work with a number of different masks (essentially images to be etched into glass or metal substrates later on) and mask types. An OO model is ideal in this situation since I could set up a "Mask" base type and have derived classes for each of the different lithographic mask representations. Again, this lets the main program work with essentially one type of data, even though it may represent any number of different things. And I can add as many different mask types as I need too.

    Don't know if either of those made much sense, but the point is, OOP can be useful depending on your application. Usually you can make do just fine without it, but it can dramatically simplify certain tasks.

  242. Car design by nettarzan · · Score: 1

    Many OO books contain an example of how to model the car in OO. The "Car" object is a container of Engine, Transmission, etc. The engine can be of different types like V6, V8, Turbo-charged etc..
    How use inheritance to model that. OO is comes in obvious when you have to do lot of simulation work in your engineering field. I find your question ironical because I frequently read the analogy of the software components and engineering components (like IC, nut, bold) and having standard interfaces between the components so the COTS software components can be assembled together just like the hardware components. To model, algorithms use the "Template" pattern from GoF pattern book. In fact OO would be very ideal. Only field where I don't see OO to be very helpful as you mention in your question is in the field of Mathematics. Well, I guess even there is a standard example like Complex numbers and operator overloading. OO is good. I like it. I see no reason why anyone want to program in procedural paradigm.

  243. OOP is the implementation; OOAD is the solution by jmb-d · · Score: 1

    It's not OOP that saves the day, but the OO Analysis and Design. You can't just write code using an OO language and expect every problem to just solve itself unless you have a thorough understanding of the problem (discovered during the Analysis phase) and a sound strategy for solving
    the problem (created during the Design phase).

    --
    In walking, just walk. In sitting, just sit. Above all, don't wobble.
    -- Yun-Men
  244. The winds of change... by Tim · · Score: 2

    "Let's just say you'll have a hard time finding a senior engineer who knows C++, and an equally hard time finding one who doesn't know ForTran. And, often, the senior engineers are among your better resources."

    Well-phrased. Yes, older engineers (and scientists) are better versed in FORTRAN. Of course, by "FORTRAN" we really mean that these folks know FORTRAN 77, and you have to ask yourself--do you really want to begin any new coding project in a language as primitive as F77? It's a bit like saying: "we're going to code in BASIC, because that's what the staff knows." Sure, you gain in developer training, but you lose many times more in code management, reuse and maintenance. And what about newer FORTRANs, like F90? Well, if you're going to retrain on that rats-nest of a language, you might as well just stick with the industry-standard rats-nest, and use C++. For an F77 programmer, the learning curve will be the same.

    Another funny thing is, most truly senior engineers and scientists aren't the ones writing code anymore. So it becomes even more absurd to suggest that new code should be developed in a language they understand. Indeed, develop in a language the new engineers know, because they're the ones who will be maintaining it well after Dr. Cranky is eating tapioca in the nursing home, babbling on about COMMON blocks, hollerith strings, and how "back in the good old days, all we had was GOTO, and dammit, we LIKED it!"

    --
    Let's try not to let fact interfere with our speculation here, OK?
    1. Re:The winds of change... by blakestah · · Score: 2

      Well-phrased. Yes, older engineers (and scientists) are better versed in FORTRAN. Of course, by "FORTRAN" we really mean that these folks know FORTRAN 77, and you have to ask yourself--do you really want to begin any new coding project in a language as primitive as F77? It's a bit like saying: "we're going to code in BASIC, because that's what the staff knows."

      Most engineers keep up reasonably well with the changes in ForTran. It has come a long way since f77, which is often used as an excuse NOT to change to a C based platform, along with lack of adequately optimized compilers.

      Another funny thing is, most truly senior engineers and scientists aren't the ones writing code anymore. So it becomes even more absurd to suggest that new code should be developed in a language they understand.

      I am guessing right now - no - scratch that. I am almost positive right now you've never worked for a senior engineer. They are tweakers, coders, hackers, etc. My boss once disappeared for days into his office, and we thought he was working on something important for the team. He came out happy as a clam that he had rewritten an enormous chunk of ForTran code, and he was sure it was now free of bugs (it was free of bugs before, too - he just rewrote it so he could read it more easily later). Engineering teams are different in that way from coding groups - the senior engineers LOVE nothing better than digging into code and looking for another optimization. It drives you nuts if it is your code.

    2. Re:The winds of change... by Pig+Bodine · · Score: 1
      And what about newer FORTRANs, like F90? Well, if you're going to retrain on that rats-nest of a language, you might as well just stick with the industry-standard rats-nest, and use C++. For an F77 programmer, the learning curve will be the same.

      Except that the industry standard rats nest in engineering and science is Fortran. Compatability with people writing GUI programs is less important than the fact that F90 compiles the enormous base of F77 numerical code. Also F90 has features of special interest to those writing numerical code. With the features for handling arrays, F90 matrix code is very easy to write.

    3. Re:The winds of change... by Tim · · Score: 2

      "Most engineers keep up reasonably well with the changes in ForTran. It has come a long way since f77, which is often used as an excuse NOT to change to a C based platform, along with lack of adequately optimized compilers."

      Horse-hoohah. Maybe, by "adequately optimized compilers" you're referring to C++ platforms, but even that's not true anymore, unless you're discussing older implementations. Fact is, the current generation of C (and yes, even C++) compilers are as well optimized as any Fortran compiler for the common cases, and very few people make use of the esoteric, vector/matrix parallelization enhancements that most Fortran programmers love to brag about (many of which have been implemented in C++ libraries, btw). Frankly, the "optimizations" that keep people tied to Fortran are pretty much irrelevant today anyway--computers are getting faster and cheaper, but programmer time is becoming more expensive. It makes no sense to stick with a programmer-intensive language like Fortran in this world.

      "I am guessing right now - no - scratch that. I am almost positive right now you've never worked for a senior engineer. They are tweakers, coders, hackers, etc.

      A "my experience is more valid than your experience" argument. Oh goody. For your information, I've worked for a wide variety of "senior engineer" types, and, yeah, your experience is typical for the breed. The "senior engineers" duck into their office and do something irrelevant for a week once or twice a year, while the rest of the team produces new, useful code over the course of the entire year. And that pile of "optimized" code the senior guy produced? Well, at least he can read it, I guess...usually no one else can.

      My point remains: even if the "senior engineers" get in a coding snit every now and again, their output typically barely matches that of the younger members of the team. And that's the way it should be--you want to see your senior engineers/coders/scientists acting as mentors and supervisors, not grunt coders. And, given that the Fortran langage does not lend itself to software maintenance and readability, it makes no sense to force new members of the team to learn it when they probably already know C/C++ anyway (esp. if they're out of school in the last 10 years).

      Now, before you flame, keep in mind that I'm refferring to new projects. I'm not an advocate of rewriting old code for the sake of rewriting old code. I just think it's technically foolhardy to use an archaic language like F77 for a new project. Maybe you would want to use F90, but even then, you have to ask yourself why you're choosing that language over something that new graduates are going to know right out of school...

      --
      Let's try not to let fact interfere with our speculation here, OK?
  245. Re:Object-oriented programming was invented for th by markmoss · · Score: 2

    To carry on your car analogy -- yes, OOP is good for modeling the interactions between cars, but first you have to model _one_ car. And this, depending on the level of detail you are looking for, may be simultaneously too simple and too calculation-intensive to fit well into a general purpose OO language. (Simula is a special case -- since it has the required math built-in, it might be competitive.)

    To get to something like the problems he was concerned with, let's say you drill down until you need a complete simulation of the air/fuel mixture flow through the intake manifold. "Objects" are irrelevant at this point, all you are concerned with now are many little chunks of gas ("cells"), represented by numbers in a big multi-dimensional array, and related by a massive set of partial differential equations. There are going to be billions or even trillions of floating point operations, taking minutes to hours to complete no matter how efficiently programmed.

    You need a language in which you can easily input those equations, and which will very, very quickly go through all the calculations on each cell in that array. FORTRAN excels at this sort of calculation, basically because the language is so unsophisticated that the compiler can do great optimizations. The one issue is that FORTRAN natively understands only basic algebra. The calculus and the process of turning a continuous set of equations into discrete cells of air and steps in time has to be programmed in; there are libraries you can call, but you've got to understand how to pick the right library function and to translate the problem for it.

    The second choice is to go to a specialized simulation language like Simula, where the compiler understands discrete integration operations, so you feed in the equations and the geometry and it picks a method of solving it. It might not be the best method, but there's a pretty good chance you'll get usable results without doing a whole lot of work yourself. It's unlikely to run anywhere near as fast as a properly tuned FORTRAN program, but you'll usually get the first-run results much quicker than the FORTRAN could be written. But if you need to try 10,00 different configurations, and FORTRAN runs each one in 2 minutes while other languages take 3 or 4 minutes each...

  246. OOP in molecular simulation by tarvosz · · Score: 1
    During my final year at uni I did an implementation of a molecular interaction simulation written in C++ in strict OO style.

    Though this was very cool, and actually worked, the conclusion at the end of the project was that a strict OO implementation was much less efficient than a traditional, procedural approach. I assume that this finding has probably been repeated across other areas of engineering and modelling as well.

  247. You're both right by SimonK · · Score: 3

    One way of looking at software engineering divides it into levels of abstraction at which people work. In the traditional view, engineering proceeded by starting at the highest level and proceeding in a orderly manner towards code. We're coming to realise that approach is wrong, but the levels of abstraction still exist. You can use OO at all these levels, by modelling things in terms of classes.

    At the highest level, often called analysis, classes, objects and the relationships between them should correspond to concepts in the problem domain. Implementation issues should not come into it. An analysis model should end up representing the system as the user thinks about it.

    At the code level, objects are indeed methods combined with data, but while the analysis model won't have captured all, or even most, of the code you end up writing, the concepts in it should still be present in the code.

  248. Gagh ! by SimonK · · Score: 2

    People still teach that ? I give OO training courses, and we mock that stuff mercilessly. Thats just a (bad) way of doing analysis. If you try to go straight from that to code, you'll end up with a poor, naive implementation, probably with all the "real work" done by one method and all the OO superstructure looking like useless fussiness. Its that kind of thing puts people off OO.

    1. Re:Gagh ! by smittyoneeach · · Score: 1

      Might the noun/verb approach represent a starting point in a heuristic analysis that gets you someplace useful?
      My admittedly brief experience has been that getting people (users/managers) to overcome the static friction within their minds is the supreme challenge; these implementation details are relatively benign.

      --
      Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
  249. Think of OOP this way . . . by Anonymous Coward · · Score: 0

    It's not so much about managing engineering problems as it is about managing engineers. Imagine you have two engineers with big egos. If you were to try to get them to work together on the same piece of code, they would probably spend all their time fighting. OOP lets you separate the problem into smaller 'objects' that each can work on. You could do the same thing with function and procedure definitions, OOP just provides a more formalized way to accomplish the separation. This would not totally solve your problem, but it would help.

  250. Re: angle brackets by Da+Schmiz · · Score: 1
    ( angle brackets got stripped by the formatter :-( )of course ...
    Try using "&lt;" ( < ) and "&gt;" ( > )

    I know, I know, it's slightly offtopic... sorry 'bout that.

    --

    "Anything is better than IE, and you can quote me on that." -- Wil Wheaton.

  251. Nuts to OOP, OOPS! I spilled my Java! by Anonymous Coward · · Score: 0

    For those too busy fawning over OOP here is some help:

    http://www.embedded.com/1999/9908/9908feat1.htm

    And if you're a bit too enamored with the C++ new operator try this:

    http://www.scs.cs.nyu.edu/~dm/c++-new.html

    And to see how STL guy A. Stepanov feels about OOP proponents see this:

    http://www.stlport.org/resources/StepanovUSA.html

    Although I have met quite a few talented (and effective) practicioners of OOP, much more often I run into hyper-political, resume-stacking, rabid and incompetent advocates of OOP. Mostly, they never finish what they start.

    Who cares what Grady Booch and his two quack partners say anyway? I mean besides the rabid advocates...

  252. Dead on by SimonK · · Score: 2

    But there's a bit more to it than that. OO is just a way of acheiving well designed software. It has its failings, but its the best I know of. So what does it mean for software to be well designed ? Well (and this goes back much further than OO), it should consist of loosely coupled components, each of which is highly cohesive internally. Each component should hide a small group of closely related design decisions (ideally one) so that the rest of the system can be built independent of its details.

    In the end, OO is not about being able to write better algorithms, but about how long your software will last, of how much value it will be to its users, and how much grief it will cause its maintainers. These are principally concerns in commercial environments (where value==price and hassle==cost), but they're relevant everywhere software is written and used more than once.

    Now, looking at your problems and your question, here are some random thoughts. I'll be the first to admit to not having the faintest idea what most of those problems are, so some of this is about the peripheral aspects.

    Firstly, all OO language in common use are procedural. The opposite of procedural is declarative, but there are very few declarative languages and they are principally of academic interest. In the end, code in OO languages is just like code in C, Pascal or Fortran.

    So, thinking about your algorithms: does the algorithm always operate on the same domain ? For instance, do your fluid dynamics always model fluids ? or might it be modelling some complex economic system ? If so, you can split the domain off from the algorithm uding the techniques off OO, by representing it as a set of abstract classes or interfaces. Of course, this is only of interest if the algorithm is part of a larger system with some purpose, and not just an academic toy.

    Similarly, are there several algorithms for solving a problem ? or can the algorithm be tuned differently. I know this is the case with some stochastic methods (I used to work on a system that used simulated annealing for place and route - in Smalltalk). In these cases the abstract properties of the algorithm can be encapsulated in an abstract base class, and concrete specialisations used to offer a choise of implementations.

    I hope that helps somewhat. Just one thing to bare in mind: beware of C++. Java is unnfortunately inappropriate for heavy numerical lifting, but C++ contains many pitfalls for the unwary. Its worth learning a more rigorously OO language - like Java - and then going back to C++.

    1. Re:Dead on by cheezit · · Score: 1

      Absolutely correct on learning Java before C++. I did that (by accident, really) and it seems to have given me a different perspective on the languages than I would otherwise have.

      I appreciated templates and the STL much more after having worked with Java's container classes; I appreciate the simplicity of Java's handling of class constants after dealing with the many ways to initialize class constants in C++.

      Java is sometimes derided as a toy, but people should remember that warty languages get that way with age. So far Java has done OK but I suspect in 5 years it will look different after some goofy attempts to add things like generic types.

      --
      Premature optimization is the root of all evil
  253. Try Scientific & Engineering C++ by mmacrobert · · Score: 1

    Excellent book on OO principles as well as applying them to diverse engineering problems. Includes special emphasis for FORTRAN programmers, as well as how to interface C++ with FORTRAN libs.
    "Scientific & Engineering C++", Barton & Nackman, ISBN 0201533936
    Enjoy.

  254. Definitive answer on C++/OO by Anonymous Coward · · Score: 0
    I couldn't put it any better than this.

    Too funny!

  255. Polymorphism matters by SimonK · · Score: 3, Insightful

    Encapsulation is only half the story. To get any benefit from OO, polymorphism is essential. Encapsulation does indeed get you nice organisation by itself, but you don't get any improvement of flexibility. With polymorphism added, you gain the vital ability to operate on objects without having to discover their runtime type. This lets you write, for instance, a catalogue system that can operate on video tapes or books, without having to have any knowledge of what exactly its working on.

  256. I used to do this by epepke · · Score: 2

    Perhaps I can help. A few years ago, I ran a team to write a large scientific visualization program called SciAn, which was all object-oriented. We did stuff like this. Although most of the time the calculation was saved in a file that we read, we also did calculations within it, sometimes using distributed objects.

    One problem you may have been having is that nearly all O-O books are crappy and ignore the real power of objects. Here's a heuristic: when a book talks more about "classes" than it does about "objects," throw it away. Vigorously. Anyway, here's how we did it, and you can maybe decide how you could do it.

    Take the case of a grid. (Please!) Just to be simple, first let's take 2-D. The points may be connected with edges to form either a non-structured grid or a structured grid. A non-structured grid may be triangular, such a grid may also be a Delauney triangulation. Or it may be a structured grid, in which case it might be a rectilinear grid. You might want to have the grid denser near the boundaries, I called these "separable" grids because I couldn't think of a better word. Or the grid might be curvilinear, wrapped around, say, an airfoil.

    Immediately, an object structure emerges, fairly cleanly, like this:

    Grid
    Structured Grid
    Curvilinear Grid
    Rectilinear Grid
    Separable Grid
    Regular Grid
    Non-Structured Grid
    Triangular Grid
    Delauney Triangulation

    This probably isn't the hierarchy that I used, exactly, because we had a lot more different kinds. We had multiple grids linked together, data in separate objects linked to the grids, N-dimensional grids with M-dimensional data, time-dependence, etc. But you get the idea.

    Would you want to use a bunch of little objects to implement your Navier-Stokes calculations or whatever? No, of course not. Put them as methods within the object.

    Once you do this, the objects make sense. You might have a method to initialize the data and a method to calculate one step in the calculation. Another method might be used to switch between, say, a simple projection integration and second-order Runge-Kutta. Call setReynoldsNumber(double x) and see what happens. You might have a method to construct another grid that contains the gradients. You might have a method that resamples any grid as a regular grid. You might have a method that constructs a Delauney triangulation of a point cloud. You might construct an M-1-dimensional slice from an M-dimensional grid, or return a snapshot of a time-dependent data set. Different implementations of these methods may live at different points in the hierarchy.

    At our height, we supported about 20 different file formats for the most diverse kinds of data you can imagine: HDF files, protein structure files, EEG recordings, particle traces, for meteorology, chemistry, quantum chemistry, economics, high-energy physics, QCD, you name it, and internally, all the datasets were in the same kind of object and behaved largely the same. As a joke, I deformed an EEG brain by a mountain terrain field. It took about five minutes.

    Alas, the research institute went defunct, and now I have to spend my time writing financial and HR reports. On the other hand, I make a lot more money.

    Beyond this, you can think in terms of having multiple objects interact. Nearly all of the big stuff that we did involved interactions between grid, dataset, and visualization objects, but there were many others. Want to run your simulation with an isothermal top instead of an adiabatic one? Don't rewrite the equation solver. Slap an isothermal cap on one face of your grid; it knows to clamp the temperatures at each time step. Or whatever: invent your own. Once you start thinking of these things in terms of objects, there's a lot that can be done.

    The guy who said that your problems are too small and specialized to benefit from O-O actually had a point. I'm not saying that they are, of course. But if your mindset is that once you have an array of values then you're totally done and eveything's known and you just throw it at a postprocessing package called Graduate Student 3.0, collect your Nobel prize and retire, then there won't be much use for O-O programming. Alas, I've worked with a lot of scientists who thought this way. However, if you work on several problems that are both similar and different, a carefully designed (and redesigned when it doesn't work--don't laugh; it happens) object framework can help you put together something synchronistic that builds up over time and really does save work.

  257. Maybe so by SimonK · · Score: 2

    Certainly if you don't try to write a system like that, but just use it to get the idea, then its harmless. I was particularly worried that the original poster mentioned it in the context of being taught Java, though. Unless it was a "your first language" course, in which case he probably should not have attended.

    One course I teach is basically "OO for beginners", which is intended for new graduate recruits (not CS grads), and for non-engineerings managers. In that, we get over the brain friction with a role playing exercise that involves people first simulating a business sytem by passing bits of paper around, and then simulating the same system as an OO system, with each person playing an object, by passing messages around. After that, they seem to get the idea of objects, messages and most importantly, classes and polymorphism, quite well.

  258. Engineering solution that used OOD by shortstop · · Score: 1

    I have had the pleasure of working on and using an OO software package at an engineering consulting firm for a number of years. We do a lot of system analysis, namely power cycles, so the software is used for modeling a network of engineering processes. We were able to make use of an OOD that brought several advantages:
    - Generic procedures define I/O, curve implementation, etc at a high level and are inherited to the process specific objects.

    - Easy extensibility. It has been very easy to add new processes to the model's library by focusing the attention on writing code for a particular object procedure. You don't need to be an expert on OO and all of the other object functionality is already taken care of. Makes us engineers think we are real hackers. :)

    I wish I could share it with you but this is an internal tool and a closed shop. I just wanted to share a success story for using OOP on an engineering problem.

  259. Its all about design by Anonymous Coward · · Score: 0

    When it comes down to coding or problem solving, who really cares. But when you need to design a maintainable software product and hope for some code reuse, OO is the best. Functional has worked and will continue to work but OO is better. The benefits of OO are not obvious when coding but are emerge in design. That is a down side to some who would prefer to just start hacking and forget design.

  260. Object Orientation by Tim12s · · Score: 1

    Civil Engineer
    Mechanical Engineer
    Software Engineer

    What do the above have in common?

    They are all the application of proven scientific methods to produce a result that achieves some objective and works safely within specified limits&criteria with repeatable reproducable results.

    Civil Engineers build bridges & buildings

    Mechanical Engineers build turbines & engines

    Software Engineers build software for nuclear reactors and apollo moon missions.

    Software Programmers build software for space probes that crash into mars because of no formal validation.

    Engineers dont/cannot afford to make mistakes.

    Lives are at stake.

    ---

    Now, what does all this have to do with OO:

    ----

    The difference between a software developer and a software engineer is that an engineer will have some formal process and paradigms to ensure that the process of development is safe and that the result has no alternative side effects.

    Object Orientation makes LARGE systems so much more architecturally flexible entirely due to formal reusability and potential reflection/descovery.

    Once objects have been engineered to some formal generalized state, they should be reusable across a business and the customized subclasses should be the implementation of all custom business logic.

    In addition, an object is not like a 'library' in that while two of the same libraries may not be linked to a program, a program may have references to the two live instances of an object which are the same, except in version and revision (theoretically it should work this way, but i think only the latest J2EE stuff is capable of this).

    In addition, OO legacy goal is to invisibly extend the system, while not breaking the contract on which binds process, and provide support for current methodologies on legacy systems... this is not successfull.

    -=-

    OO does not calculate information quicker.

    In fact, it will definately be slower if you make everything, and every process an object.

    The only possibly good effect that OO will have in a procedural calculation is version control and the magnification and seperation of abstract mechanics.

    Think raycasting, think process transformation, think mechanical dials, think resources in a 'machine', think realtime execution, think of more than one analysis that one wants to work with within the same machine framework.

    Importantly, Objects are expected to have a contract which they enforce. Breach of this contract should be impossible.

    When it comes to raw processing such as:

    for each step
    for particle 1 to google do
    interact field
    push particle
    end
    calculate field
    end

    There are no major architectural components.

    Sure, you could use OO for datatype abstraction, but a library is just as sufficient.

    One important thing to rememeber is that a scientific tool does not need to be robust. It's designed for a specific purpose, calculate an answer. One does not care about the instance of implementation, or the process of implementation, but only, that the answer is correct.

    You throw the program away after you have the answer.

    Something like mathematica or IDL, which are both meta-scientific tools that aid in the calculation of calculations will use objects extensively. They have procedural/functional syntax to solve problems. Using the tools are functional.

    You throw the program away after you have the answer; so WHY use OO ? There is no real reason. You can use OO libraries in your procedural process. You can use OO in designing an application that executes your procedural process, but unless you're process is massive, I wouldnt use OO for the implementation of the procedural process.

    Infact, i'd put the entire procedural process within one object.

    class myanalysis {
    Graph calculate(int x, int y);
    }

    Calculate is clearly procedural.

    The output, eg: Graph, and the means for viewing the result may be in the application domain, in which case OO is used extensively.

    EG: windowing components and visual graphing components.

    But you're analysis is very much procedural.

    Dont foolyourself, use the best tool/paradigm for the job. If its perl, php, parot, prolog, lisp, visual basic or Java then use it.

    === sidenote ===
    A Software Engineer is not currently a formalized profession, but I do believe that there is some work going on to make this so. Those that have the understanding on what it takes for a process to be formally proved to work, and have the means to implement the process, are Software Engineers.

    For those wondering: Most programmers are just software developers, the [software] engineer is just a tag aquired to sound good. This (formal definition of a software engineer and the means to aquire said title) may have changed at the time of me writing this.

    Yes, electronics engineers write software in electronics components, no, they arnt software engineers, but they are (commonly) programmers.

    with formal acreditation... unless i'm mistaken.

    === sidenote 2 ====

    Formal Object Reuse on a massive scale has not lived up to the hype'ed expectations.

    Components dont just 'fit' together as easily as one would like. This makes the formal process very difficult. Java makes this easier in terms of a formal, well guided implementation, but there are better formal languages out there, unfortunately some are only research projects or have lacked the mainstream support.

    Taking two components: one from vendor A, one from vendor B, do not currently 'just work' without some intermediate interface marshalling... a goal of current thinkers is to solve this problem. Hence reflection, beans, visual components. Important component/process such as the various banking processes and company ledgers always need to be customized and information is not usually consistent between different implementations of ledgers and supporting APIs, thus one cannot just swap ledger components from two accounting packages as they're too different, on an implementation level.

    Lots of problems.

    -Tim

  261. FORTRAN vs. [insert language here] by Anonymous Coward · · Score: 0
    Having read much of the debate, which has branched into various different arenas, about how good C++ is for this, or C is for that, or OOP is the best thing, I will pull back for a minute and quote something posted to comp.lang.fortran.

    Cheers,

    A FORTRAN advocate

  262. what i'm developing by zebadyah · · Score: 1

    Currently I'm finalizing an Excel version of what will be a program that my co. will be producing later this year. Began in excel as simple method of rapidly producing reports with inputs, and over the last year has turned into a 15 MB ssheet with a 4 MB report generated. Main reason we've kept it in excel all this time is that everyone in our office can work with excel and can easily comment and change formulas (except where I've had to use VBA functions to simplify or do multiple iterations w/o using the Solver func). What this does is take a 12 month history of data and run nine different simulations based on input data and produces an overall project cost, operating cost, and financial outlook for 15 years. About 6 man-years of work in the making and still more to go to make the final standalone program. This year we'll port it to VC/VB. Would have started sooner but last year accounting wouldn't pay for the compiler. Main thing I've wanted to be able to do is the database functions of VC++/VB as every time we've come up with a new feature I've had to redesign our layout and output.

  263. Certainly true for fluid dynamics by wjbaird · · Score: 1

    I saw a talk presented by the scientific computation group at the University of Waterloo about 5 years ago on the advantages of implementing a fluid flow solver in C++ vs. FORTRAN.

    The conclusion was that you lost a tiny bit of performance (about 3%) but your code maintainability went *way* up. The example presented was a simple 2D navier-stokes solver, and adding a new element type to the C++ version took a few hours of effort, but adding a new element type to the FORTRAN version took a couple of days.

    on their webpage they say that they are now doing all of their scientific computation work in C++

  264. OOP and Engineering problems by Anonymous Coward · · Score: 0

    It is very easy to write poorly performing code in an OO language. Everything from complex copy constructors to unexpected copies on function calls can both exact a large amount of cycles to perform and destroy your cache working sets. I have seen very fast, very efficient turbomachinery simulation code writen in C++, but it was written with *great* care and knowledge. Unfortunately, programmers who are not aware of many of the pitfalls of C++ (usually those who migrate from one of the various FORTRAN flavors or who simply learn C++ from one of the books on their own) can easily write a program that is a complete failure performance wise.

  265. Resue and extend... by Razzy · · Score: 2, Insightful

    I doubt OO will help with computational efficiency in the problems you mentioned. Where it could help is in the man-hours department. Creating reusable and extensible OO objects can reduce your coding time on any particular problem a great deal.

    For example, I am a contributor to the Scythe Statistical Library which is essentially a big matrix object which supports many common operations. Scythe was initially designed by two professors who do a lot of monte carlo simulation. They still write programs that are essentially procedural to do each simulation, but the library greatly reduces the overall coding effort on each project. Other portions of the library (random number generators, numerical optimizers, etc) are as procedural and stand-alone as a standard c library. But matrices are so important that it makes sense to create an object for them. If needed we could create extending objects like triangular matrices, etc with little effort.

    In essence, if you can think of some portion of your coding effort that is object-like (a matrix, a polygon, an engine part) and important enough to many different projects, creating an object for it makes sense. This is especially true if you can think of sub-objects which you might use in the future.

  266. Re:Object-oriented programming was invented for th by LJD65536 · · Score: 1

    My first experience with something like object oriented program was back in the 60's using SIMSCRIPT, a simulation language similar to SIMULA. The language was actually a preprocessor to a Fortran compiler. The code generation idioms used in the translation were very interesting and could be used as a way of writing object oriented Fortran.

    I'm not sure whether SIMSCRIPT came before or after SIMULA but I believe they were developed around the same time with similar ideas in mind. In SIMSCRIPT objects were called "entities" and classes were called "entity types". Entities had most of the features of what we now call objects. They had attributes, behaviours, agregation and a limited form of inheritance. There was a particular base class of entities called event-notices that were used wre used to schedule events in simulated time.

    The power of this object orient approach to simulation comes into focus on problems where the behaviour of individual entities is well understood but consequences of interaction between entities boggles the mind. You write subroutines to model the response of each entity type to each event type, set some initial conditions, and let it rip. There are a significant number of engineering problems that fit this pattern.

    This type of simulation can easily be written in C++, or any language that supports classes, by writing a simple scheduler that sequences event objects in simulated time.

    Some examples are useful to illustrate the point. In each cases, it is relatively easy to imagine modelling the behaviour of each individual class in spite of the fact that the overall problem seems daunting. (These are actual problems that have been simulated with this technique.)

    Simulation of an aircraft running a gauntlet of air defences. Classes: missiles, launch events, flares, manuever events, tracking radars, jammers, etc

    Network traffic simulation. Classes: packets, routers, transmission lines, store events, forward events etc

    Simulation of mutual interference among cell phone users. Classes: Cell phones, Base stations, calls, start of call events, end of call events etc

    Disaster casualty evacuation. Classes: ambulences, dead, wounded, ambulence arrival events, street obstructions etc

  267. The best place for an engineer to start by sendmeyer · · Score: 1

    is Matlab! We're not computer scientists, Matlab is an engineer's tool Its strengths: 1. matrix math, nothing beats it 2. numerical analysis 3. nonlinear systems if you need a gui, it has built in GUI features, and if you have functions built in other languages, it has modules for C, C++, java, fortran and if it isn't fast enough for you, then you probably could write the whole thing in C/ C++ only if you needed a GUI it's the best tool for college engineers, got me through EE just my 2 cents

  268. OO is not a silver bullet by Anonymous Coward · · Score: 1, Interesting
    OO works well for 90% of the problems out there. It falls on its facy miserably for the other 10%. Most engineering problems fall in that 10%.


    That's why you've never seen a good, useful, large-scale, general-purpose application written in a language that forces OO on everything (like Java). It just falls on its face for a small, but noticable subset of the CS problems out there.


    For engineering and scientific work, nothing beats a functional language like Scheme, if you have the time to get over the learning curve. If not, traditional structured programming does well (Fortran, C, Basic, Pascal, etc.)

  269. Slightly Unrelated by Dwonis · · Score: 2

    I think we need another compiled language with Python's syntax. I started using Python again after using Perl and C++ for a while, and I found it incredibly clean and easy to use. It's just so clean compared to C++.

  270. Me too... by Wavicle · · Score: 2

    I'm just going to add another "Dead on" response.

    I'm an OOP fanatic myself. OOP is a wonderful tool for most tasks. The article author's tasks however aren't among those.

    A good example of his issues is a Mandelbrot program. If you want code to solve a single problem, like rendering a Mandelbrot set, OOP is not going to give you any advantage. The problem is specific to matching a set of input data (the set boundaries) to its corresponding result (the set). If you wrote this using OO, the meat of the software would be a single Mandelbrot object. Everything else would be necessary fluff for display and handling mouse clicks.

    However, if you needed something that would render Mandelbrots, Julias, and Recursive Serpentine something-or-others then OOP would be an appropriate tool. The fractal itself is an object and the higher level managing code doesn't need to know anything about the fractal objects except that they are derivatives of a base fractal class and therefore support an intelligent set of generic methods.

    My experience with engineering software written in Fortran has been that the program is tightly coupled to one narrowly scoped problem (like the Mandelbrot example) and doesn't lend itself to an OOP implementation.

    --
    Education is a better safeguard of liberty than a standing army.
    Edward Everett (1794 - 1865)
    1. Re:Me too... by sketerpot · · Score: 2
      Exactly. A good example of the OO way of doing a fractal program, lack of optimization notwithstanding, is KFract, which usually comes with KDE. It has different objects for different types of fractals and could be extended quite easily, but if you just want something to draw a Mandelbrot, you can do that in a page of BASIC.

      By the way, an AC first post got modded up to 5!

  271. finite element by Anonymous Coward · · Score: 1, Informative

    there is a very nice OO program that has just been released under GPL by EDF (électricité de france) written in Python & Fortran to solve engineering problems (finite element modeling ) that you might want to check as an example

    http://www.code-aster.org/

    (the doc is in french though !)

    an other good place for scientific applications under linux is:

    http://sal.KachinaTech.com

    check it out :-)

    & happy new year

  272. my experience by slashdot2.2sucks · · Score: 2
    Last summer I did a REU at Los Alamos and my mentor who writes and uses plasma code for a living told me that he had never even used pointers before. He said that he didn't need pointers or object anything because that stuff is only for CS people writing GUI stuff and Mickey Mouse programs.

    However this is a man that writes in Fortran 90. And Fortran 90 does contain pointers (very ugly syntax) and OO stuff if he would ever need to use them. (I would complain about the ugliness of his code too, but I know my shit stunk too when the deadline was coming in)

    On the other hand I have met a professor that prefered C++ because he had many projects and they all very large. He wanted maximum code reuse and all self contained pieces.

    And also it is obvious that classes are extremely valuable for other types of math than basic arithmetic like linear algebra and some abstract algegras.

    I myself prefer C for its speed/simplicity/size and always having a compiler. I generally make very ugly use of inlines, macros, and global variables to cut code size down without having classes. For bad example

    int e
    #define VECTOR(X) for(e=0;e<3;++e) {X;}

    (and then unroll the loops) which applies some statement X component wise, so I could add vectors like VECTOR(a[e]+b[e]). Yes, I know it is ugly, but damnit I have had code that took a month on 9 computers and I just didn't have any extra time for the performance hit of C++.

  273. I think you asked the wrong question. by Anonymous Coward · · Score: 1, Insightful

    There is probably no problem that can be solved by OOP and not procedural programming.

    But then there is probably no problem that can be solved by procedural that can't be solved by machine code.

    The question should be when is it more appropriate to use OOP instead of Procedureal programming?

    For small simple programs procedural is often enough, but the bigger the problem the more chaotic procedural can become.

    OO can be safer as everything is kept in it's own little container. For example you have a simple snake game with a single snake. You have a snake object that looks after the snakes direction and has an array that looks after the location of it's body on the map. If you have a single snake it is easy to write it procedurally because all you need is to have a single array that looks after it's body. But what if you want to add a second snake? with OO all you need to do is create a new snake object. With procedural you would have to extend your snake array so that it can look after the second snake as well. Then you want to add a third snake, or X number of snakes.

    Again it is all possible with procedural, but what is simpler to do?

  274. OOP criticism from author of STL by igrek · · Score: 2

    Sure. Here's the quote from An Interview with A. Stepanov:

    STL is not object oriented. I think that object orientedness is almost as much of a hoax as Artificial Intelligence. I have yet to see an interesting piece of code that comes from these OO people... I find OOP technically unsound. It attempts to decompose the world in terms of interfaces that vary on a single type. To deal with the real problems you need multisorted algebras - families of interfaces that span multiple types. I find OOP philosophically unsound. It claims that everything is an object. Even if it is true it is not very interesting - saying that everything is an object is saying nothing at all. I find OOP methodologically wrong. It starts with classes. It is as if mathematicians would start with axioms. You do not start with axioms - you start with proofs. Only when you have found a bunch of related proofs, can you come up with axioms. You end with axioms. The same thing is true in programming: you have to start with interesting algorithms. Only when you understand them well, can you come up with an interface that will let them work.

  275. Right tool for the job. by pagercam2 · · Score: 2, Interesting

    I am originally a mechanical egngineer and have some expereince with finite element/finite difference work . The short answer is that no OO techniques, don't apply to many engineering tasks. I can remeber not that long ago that entering a bookstore or technical bookstore there would be three of so book cases covering 20-40 languages, now there is one bookcase of C/C++, one of java and half a bookcase of other which seems to mean scripting languages more that anything else like Perl,Tck, Ruby etc... . Those 20-40 languages each had a specialty
    Fortran for math/engineering
    C for systems programming
    Prolog for expert systems
    LISP for AI
    Snobol for text processing
    Cobol for business
    Pascal for learning
    Ada for formal systems
    etc .....
    Now the answer is always C/C++/Java, C is realitively general purpose, but C++ is generally 20% slower and larger than a equivalent C application. Java is easier, but I find it strange reasoning that garbage collection is prefered, isn't writing your application correctly a better solution than having the computer clean up after you, kinda like a teenager not putting thier dirty underwear in the hamper becasue Mum will do it eventually. Assembly is always going to be fastest, but the hardest to debug/maintain, the OO languages make life easier, but all the abstraction causes significant speed loss and code bloat. I keep on hearing poeple say that code size and effiency don't matter as thier machine is fast enough and memory is cheap, but Intel is selling faster processors because of inefficient code and people are always adding more memory. C++/Java are fine and are the best solution to some problems, just not all problems. The market is contracting to the point that non C++/Java compilers are rare, and the options will not exist. SW people seem to spend an inordinate amount of time debugging and this is the area that would have the biggest payoff, but heavily typed languages haven't seem much sucess in the market. I spent 6 years, working in Occam a parallel processing language, that have very tight rules and was a formal language, such that there was only one possible solution to given code. We always used to say that in 'C' code, if you got your code to compile you were 20% done, and required the next 80% for debug, while Occam compilation was more painful, getting it to compile you were 80% done, that sort of help makes you more productive than anything else. People hated the compiler complaining about seeming insignificant errors, but the compiler was finding mistakes and helping me rather than hoping that I knew what I was doing. This helped me build 80 processor sonar systems in 11 months, well before any beowolf cluster.

  276. 'Ask Slashdot' has become a troll topic by Logos · · Score: 1

    This post is dead on, but unfortunately too far down the post list to be seen by anyone.

    OOP vs. Procedural there's an original question.

    Let's see what else has been up on Ask Slashdot lately:

    Satellite Command Security? -- Security through Obscurity, definitely a new one for /.

    Handling Discrimination in the IT Workplace? -- This one was a guy claiming he was being discriminated for his age, and then explaining how this happens from everyone he meets, after a period of time on the job. Yeah its everyone but him.

    MS Office for OSX? Why not for Unix as Well? -- Troll the unix crowd with M$ and Apple in the same sentence.

    Is Assembler Still Relevant? -- I am sure that this was a stunner to most, but to the few in the dark, an NT sys admin was arguing that not knowing computer architecture didn't hinder his job. Really useful topic, could this be any more subjective?

    Fast Track to a CS Degree? -- This one was good. A self taught programmer asking where he could pick up a degree in a year. That wasn't a troll honest.

    Responsible Handling of Billing Information? -- This was my favorite, a guy picks up an independent cowboy hack job. In over his head, he turns to slashdot for advice on how to architect the application that some poor schmucks are too ignorant, or too cheap to realize how much it is really going to cost them.

    Its a shame, because every once in a while there are questions that pertain to more than just the poster and the prima-donnas who feel the need to show off what they know in response to subjective and often religious topics.

    Cliff, get a grip man, its starting to look like the National Enquirer or Jerry Springer around here.

    (Mod me down. who cares. It won't improve the quality around here either way)

    --
    We are agents of the free
  277. Check out Mathematica by Anonymous Coward · · Score: 0

    It will give you the best of both worlds - www.wolframresearch.com PS I don't work for them, just think its a great tool an has a very powerful multi-paradigm programming language

  278. There is more under the sun than OOP and PROC by Anonymous Coward · · Score: 0


    Aspect Oriented Programming.

    I understand that google has good notes on this.

  279. OOP - It's about Structure (I'd say) by Pinky · · Score: 2, Insightful

    I've always viewed Objects and object oriented desgint to be usefull for structuring programs - that is making moduals simple to glue together.. getting rid of "glue bugs" (problems that occure when intergrating moduals). I don't think that Objects help make a program fast or efficient.. if anything they seem to work against it, making data structures fatter and blocking possible optimisations that could come from tigher integration. This is fine with me, however, since most of my problems come from people not understanding how each others moduals work or making errors that come from simply being un-experienced with someone else's code.

    I think you're looking at a tool that can be used to help structure, isolate and make code self sufficient to help with calculations and modeling.

  280. I work on the same thing you do by glyph42 · · Score: 2, Insightful

    I have implemented Monte Carlo radiation transport algorithms (read Global Illumination Renderers) and it would have taken me three times longer to do it without C++.

    What people forget is that every little structure, every little piece of data can be considered an object. You have samples for your Monte Carlo system? Make a class. You have some kind of representation of the environment? Make classes. You have radiation sources? Make classes. You have several sampling techniques that can be chosen at runtime? Make classes.

    Why? Haha. Because you get type-safeness, you get reusable code, you get increased readability, you get increased writability (no thinking "what was this int for now?) but *especially* the type-safeness, and it provides a nice framework for you to organize your code into (objects). Did I mention the type-safeness? How it saves yor brane from having to remember your structures?

    Is this more code? Sometimes. More lines, yes, but usually much more readable (shorter lines). Is it slower to do it this way? Well, I didn't win the APICS programming competition by not using C++ :)

    I use classes for just about everything! People forget that if you program this stuff *well* in C++, it gets compiled away! It's not a "solution to an engineering problem", it's a tool! It gets the compiler to do a lot of things for you that you used to have to keep track of in your head. You can even do OOP in C, for instance, by pretending to do your own namespaces (adding prefixes to all your structs and functions) but why not let the compiler do it for you?

    BTW, I strongly believe in the OO/procedural hybrid that is present in languages like C++. Data and functions are organized into objects, but the functions themselves are still procedural on the inside. So OOP is a tool for organizing your code!

    That's so important I want us all to say it together: OOP is a tool for organizing your code.

    This concludes today's lecture :)

    --
    Music speeds up when you yawn, but does not change pitch.
  281. Use of OOP in numerical software by Anonymous Coward · · Score: 0

    1) You are doing a numeric simulation/computation that involves a lot of state that ends up as global data structures. A class is a nifty way of bundling that state together with the operators on that state.

    2) Model-view-controller pattern allows a clean separation between model (your platform-independent engineering calculations) and view (your GUI data visualization).

    3) You have an optimization method (conjugate-gradient, Newton-Raphson) that you want to make generic. Making your function an abstract class with a virtual EvalFunction method allows you to plug-in any function into your optimizer -- this is run-time generacity -- templates are the compile time counterpart.

    4) (mentioned by other posters) -- STL or STL style classes for collections -- application to sparse matrices, etc.

  282. (Re:We do it!) Lots do!! by MarkMac · · Score: 1

    Glad to read about your applications! Of course, you are hardly alone in such endeavors! Half of the October 2001 issue of the Communications of the ACM was dedicated to High Performance Computing using Java. For a more immediate and applied example of using O-O methods for engineering type problems, have a look at the excellent recent book Object-Oriented Implementation of Numerical Methods: An Introduction using Java and Smalltalk by Dibier H. Bessett (Academic Press, 2001). I am sure it isn't too hard to find lots of other examples.

    1. Re:(Re:We do it!) Lots do!! by Bill+Barth · · Score: 1

      Are there MPI bindings for Java?. (I'd hate to have to do the socket calls myself.) :)

      --
      Yes...I am a rocket scientist.
  283. try TIM by davidone · · Score: 1

    Look at "The Incredible Machine" by Sierra.
    A bit old but a very fine example of object
    orientation applied to physics.

  284. [OT] Re:Speed of OOP... by Anonymous Coward · · Score: 0

    Not quite. When you yawn, the hairs inside your ear which resonate to give you the impression of sound flex. Their resonant frequency is briefly altered. This results in you perceiving a higher tone than is being played. There is no time-dilation.

  285. Not OO but Generic Programming. by anandsr · · Score: 1

    You do not need OOM because he has a lot
    of equations that have to apply to different data.
    This is the opposite of what OOM is designed to do.
    OOM takes data as the central concept, while you
    need procedures to be the central concept. Luckily
    C++ was designed to be a multi-paradigmed Language.
    It is actually among the best language for doing
    generic programming. Maybe Simula can also be
    as good. If you have read "Design and Evolution of
    C++" you would know that C++ was inspired by Simula
    not C. C was taken as the base because it was the
    most popular of the languages.

    STL of C++ is an example of Generic Programming.
    If you are going to use C++ for your work, you
    could start with a book on the design of STL. I
    couldn't recommend you one because I haven't really
    done any STL programming.

  286. What OOP is, and isn't by Anonymous+Brave+Guy · · Score: 2
    Don't you already have discrete data types for these things? And don't you already have functions that operate on those discrete datatypes? Then you're already doing OOP.

    Not really. You might be doing what some OO guys call "object-based" programming (and other non-OO guys call myriad other things), but it's not really OOP. OOP implies rather more than just using your own data types.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  287. Bit unfair by Anonymous+Brave+Guy · · Score: 2

    I'm sorry, but anyone who claims C++ has "too much overhead" over C doesn't know what they're talking about.

    There is no reason that this must be the case. C++ strongly adheres to the "zero overhead principle", which says that if you don't use a feature, you shouldn't pay for it. This is directly relevant to things like virtuality (which is optional in C++) and exceptions.

    The only major difference between C++ and C code to do the same thing is the quality of the compiler. C compilers used to have a big headstart in the optimisation stakes, but this is no longer the case (at least, not nearly as much).

    And before anyone replies and claims that virtual functions, exceptions and such are all horribly slow, just stop and think what you'd have to do to get the same results in C, and tell me how that's going to be faster than a highly optimised, compiler-generated version of the same thing. :-)

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  288. Efficiency is probably the limiting factor by tamboril · · Score: 1

    ...because engineering and mathematics problems are almost certain to need deeply-nested loops eventually. Alas, memory allocators (for C++, anyway) are still painfully slow, and because of this, the speed of your program will be inversely proportional to the level of granularity to which you OO-ify your problem. We all know how slow simple algorithms can be if you have an object for an 'integer'...that gets new'd and deleted a zillion times all over the program.

  289. More than syntactic suger, though by Anonymous+Brave+Guy · · Score: 2
    Operator overloading is just syntactic sugar...

    Not in some cases. Generic programming in C++ would be heavily limited without it, and some of it is used implicitly.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  290. C++ and Engineering & Science by lmenke · · Score: 1

    The simple answer is yes. In fact C++ is a very powerful tool for scientific programming. Solid scientific programming rests on structures such as abstract data types (i.e., containers) such as multi-dimensional arrays, maps, linked-lists, trees; concepts such as common structure; data encapsulation, templates, etc. One book that I would recommend is Scientific and Engineering C++: An Introduction With Advanced Techniques and Examples by John J. Barton, Lee R. Nackman ISBN: 0201533936, 1994. This is one of the best and literally breath-taking books on scientific C++ programming; the chapters on Arrays and Templates are worth the price alone. Do not be fooled by the publication date of 1994, the template concepts illustrate are only now coming into use. Some of the material is advanced, however, the books web site allows down loading of all example source code. Lorenz H. Menke, Jr. Lockheed-Martin

  291. Comments of OOP from the industry by Anonymous Coward · · Score: 0

    You have heard enough from those brain washed academics who had more theory then practise, now try the following:

    http://www.embedded.com/1999/9908/9908feat1.htm

  292. And yet... by Anonymous+Brave+Guy · · Score: 2

    ...here we are at work, seven years after starting a major project in C++, with about 50 man-years of development on the project behind us, and OO is still working very well indeed. For comparison, we now match the previous incarnation of software (written in C) on almost all features, but that took nearly five times as long to write, and wound up so unmaintainable that we've come in to clean up. Looking at the spaghetti they made out of a complex design, and the number of bugs they never did manage to fix, and comparing it with the nice OO framework we have in place, it's easy to see why, too.

    This is an instrument control application, BTW, with a lot of mathematical analysis of data obtained through the instruments and a pretty powerful GUI/macro language on the front end. The use of OO has allowed us to design careful frameworks for the IC, maths and GUI, into which new components plug. One of the major claimed benefits of OO -- the ability to have code you haven't even written yet work with what you're writing now -- has paid off for us big-time.

    I agree with some of Stepanov's points; there are indeed some fundamental flaws in a pure OO methodology. However, being pragmatic, they are relatively insignificant and you can work around them. If you choose a mixed-paradigm language such as C++, several of them immediately disappear anyway.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  293. I still write in C++ :-) by Anonymous+Brave+Guy · · Score: 3, Interesting

    Yep, some of us are still slogging on, writing our MLOC projects in C++; there's no reason for us not to.

    The thing is, we use C++ in a smart way. You keep the low level stuff at low levels, instead of polluting your whole code base with it. That immediately kills most anti-C++ "it's not safe" arguments. You then write mid level building blocks from the low level stuff, and you write high level code using those building blocks. Most of the code we write today uses concepts every bit as high level as most other mainstream languages, often more so, because we use the tools for abstraction that C++ provides appropriately.

    IME, the reason many people give up on C++, and switch to "higher level" languages, is that they've never really understood the abstraction tools in C++, and have always just used it as a "better C" with a few objects around in a badly designed hierarchy. Our friends over at MS showed the world how not to do it when they designed (and I use the term loosely) the MFC, which is a thin wrapper around C code, and not a proper OO framework at all.

    If a few more programmers went out and learned their craft, instead of trying to use a powerful tool like C++ without learning the ropes first (but it's OK, they program C, so they don't need any more training to know C++) then fewer of them would decide that "C++ sux" and run away.

    Of course, the target audience for C++ is, and really always has been, the programmers at the top who are prepared to make the effort to learn to use it. Those who do, reap the rewards, and find many "higher level languages" horribly limited in comparison.

    Just MHO, of course, but I've certainly seen it often enough to be sure of that opinion.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  294. Be careful that you don't hurt yourself... by Mike+Greaves · · Score: 2

    ...because you're hurting me. ;-)

    I think you just single-handedly proved the value of OO features in the language itself. The difference in readability between the previous C++, and your C implementation is, frankly, striking.

    --
    -- Mike Greaves
  295. Think macro not micro to get benefit from OO by anorlunda · · Score: 2, Insightful

    I'm an old FORTRAN guy who swtiched to objects, so I can relate as to the initial conceptual difficulty of choosing which objects and why. My best advice is to leave your engineering problem X code intact and think about how to encapsulate it to do more than you imagined in the past.

    I worked with power grid problems (load flow). Think of it as glorified E=I*R. In the beginning, we could accomplish 0.04 cases per hour. Today's computers run more like 4,000,000 comparable cases per hour. That's more than ample reason to think differently about how to handle a case.

    One way to take advantage of the extra computing power is to embed the engineering solver prodedures in optimizing programs. A linear programming engine object can be linked to my load flow encapsulated object. Together they might solve a million what-if cases to produce one optimum result.

    A 2nd example. The solver can be encapsulated in objects that make stochastic pertubations of key parameters. Thus your deterministic engineering problem solver could become part of a higher-level solver that gives probability distributions as results.

    A 3rd example: Modern load flow solvers are encapsulated in objects so that they can be called by higher level programs. GIS users can sketch out a new housing development and the housing object can create and place the needed poles, tunnels and wires and then turn to the 1960s-vintage procedure to calculate voltages and short-circuit currents then check the anwers against the building code objects. That could not have been achieved wihtout object encapsulation of the solvers.

    A lot of the other replies to your post focused on the use of objects at the micro level, linked-lists, wires, resistors, etc as the objects. My advice is to look in the other direction, macro rather than micro. Use them to stretch your thinking about what's possible to do with your engineering algorithms.

    Even brand new programs sometimes benefit from cutting off the OO at the lowest levels. Ask yourself why C++ keeps ints, chars and so on as non-object atoms while Smalltalk lets you make objects of everyting down to ints and chars and even bits if I remember correctly. It's lots of fun to play with but the overhead of too many micro level objects is great. All in all, I've gained much more benefit from objects that focus on the macro management of algorithmic solvers rather than the micro details. That's one of the problems I have with MathCAD use; as soon as the CAD programs solve the problem, they become a hindrance to encapsulating the result as an object to be used by higher level programs.

  296. In defence of C++ by Anonymous+Brave+Guy · · Score: 3, Insightful
    You obviously never read the slashdot article about how C++ at runtime must instantiate all the objects and do some other funkiness that makes startup time slower than C.

    I read it, and gave up partway through the discussion, because most of the comments made were so much ill-informed FUD that it actually made me angry. It's true that C++'s biggest problem is the ignorance of the programming community, but I had hoped for better from the /. community until I read that discussion.

    The extra overhead involved in initialising objects in C++ is similar in both purpose and time consumption to the overhead when you first load a C program. It may take marginally longer, but it's measured in milliseconds, and a one-off when you first start up. It's one of the few places where C++ can genuinely be slower than C, and it's still hardly worth mentioning.

    Oh and here is an article you may want to read -> http://www.gamedev.net/reference/design/features/w hatlang/page3.asp It talks about some of the tradeoffs of using C++ vs C.

    I really hope your perspective isn't based on articles like that. It's well-meant, I'm sure, but there was never any debate about whether C++ was slower than C in informed circles, because the answer is obvious: no. Whether you look at the theory of the languages (try reading The Design and Evolution of C++, by Bjarne Stroustrup for some insights) or simply code generated from C++ and the equivalent functionality in C, you find the two comparable on all counts. There is far more variability in quality between compilers of either language than there is between the two languages. In fact, some language features allow C++ to make optimisations C couldn't even dream of, bettering it several fold in performance.

    Also there are other reasons why C++ is not that good a programming language and here is a guy who was talking about creating D programming language -> http://www.digitalmars.com/d/ and some of his reasons for this.

    ROFLMAO. I'm sorry, but this is just not carrying any weight with me. Let's look at a few quotes from the first couple of pages, and see how the author demonstrates a lack of consideration on his part, not that of the group behind C++.

    Yes, C++ does provide the meta programming ability to implement resizable arrays and strings like the vector type in the STL. Such fundamental features, however, ought to be part of the language.

    No, that is exactly the wrong decision. These are not fundamental features in a language with low level support. Much better to provide a simple language with solid foundations, and build a powerful library on top, than to clutter a language with "powerful" features, but then find the next time you need a new powerful feature, you have to change everything around, or can't add it at all. These features are still available in C++; what difference does it make to the developer whether they are built in or part of a standard library?

    Features To Drop: Multiple inheritance. It's a complex feature of debatable value. It's very difficult to implement in an efficient manner, and compilers are prone to many bugs in implementing it.

    And yet, many languages (not just C++) implement MI quite happily, in various ways, with good efficiency and few bugs. Speaking as someone who uses this feature on a regular basis in large application frameworks, I can say with some authority that it's rarely appropriate, but when it is, it's horrible to be without it. Supporting interface inheritance alone is not an adequate solution to replace many useful MI idioms, however much those without MI like to claim otherwise.

    Features To Drop: Operator Overloading

    And how exactly were you planning to write useful generic algorithms without this? Many critics slam op overloading, and many of the same advocate the introduction of generics into their language of choice. Few have thought it through enough to see the connection. Again, C++ got this one right.

    Features To Drop: Creating object instances on the stack. In D, all class objects are by reference. This eliminates the need for copy constructors, assignment operators, complex destructor semantics, and interactions with exception handling stack unwinding. Memory resources get freed by the garbage collector, other resources are freed by try-finally blocks.

    Riiiight. So we're going to improve on C++ by removing the ability to write classes with value semantics, or indeed programmer-definable semantics at all. Further, we're going to be replacing the powerful RAII idiom with the rather underpowered and error-prone try-finally construct. And this is progress?

    Features To Drop: Non-virtual member functions.

    Unless you're going to provide a smart alternative, you just hit your performance big-time. In doing things like this, you cripple your language for developing truly high performance apps.

    Features To Drop: Support for 16 bit computers.

    OK, let's rule out writing for embedded systems completely as well.

    I could go on, and dismantle many of the other myths, personal views that are far from universal and downright misleading claims on the site, but I don't see much point. There are certainly flaws in C++ -- some of which will be addressed in the next revision -- but things like having MI and op overloading are not among them. Putting C++ down on that basis, in the face of informed opposition, just makes you look like you haven't done your homework.

    You know, the best bit of that page is the "Who D Is For" bit. I guess I qualify, as do many I have worked with, on about 75% of those counts. Yet the arguments given in the previous "Features To Drop" section would immediately convince me that D wasn't a serious tool.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  297. Apology... by inha · · Score: 1

    *blush* I went home and read my copy of Booch's (well, the beginning), and Budd's "Object-Oriented Programming".

    I now remember the existence of object-based systems. Forgive me for saying you were wrong. You were not. Now I even understand (again) why you stated OOP != encapsulation! (Quick learner, aren't I? =)

    Also, reading my comment again, I noticed that the part of polymorphism was also, if not utter crap, easily misinterpreted, again because I seem to have a bit different view of polymorphism than the rest of the world - well, I have my state, behaviour and identity :)

    Polymorphism as in pure polymorphism is essential for object-orientation. I thought of polymorphism as it was only "ad hoc polymorphism" (overloading), and not pure polymorphism.

    But now I'm corrected, thanks to you, igrek. Feel free to point out any other unbelievably crappy opinions in my previous (or this!) comment.

  298. The Zen of Complex Things by Tablizer · · Score: 1

    (* OO languages exist at the "high" end of the language-level spectrum. They're geared toward managing code complexity in the face of a problem domain which is conceptually complicated, primarily by encapsulating bits of the problem domain into digestible and self-contained sub-problems. *)

    That is a bunch of brOOchure hot air. There is no public evidence that OOP is "higher" nor "better" than other paradigms. (See Yourdon's research.) Often OOP books and hype-rags compare decent OOP to *bad* code/design in other paradigms to fudge the results.

    The idea that OOP breaks things down into "easier to digest parts" (more than other paradigms) is also hogwash. The problem is that truly complex things have no *one* border of division. They are multidimensional. The borders or boundaries needed by one user are likely insufficient or inappropriate for another user/viewer.

    IOW, "one encapsulation fits all" is a tough goal. OOP's encapsulation borders are one-dimensional in a multi-dimensional world.

    More OOP reality checks:
    http://geocities.com/tablizer/oopbad.htm

  299. definition warning by Tablizer · · Score: 1
    While OOP has some advantages in a traditional setting, where it really shines is when you use OOA/D (OO Analysis and Design)

    This often leads to a terminology battle. OOP is relatively easy to define: using classes. OOP also has historical roots in Simula-67 and Smalltalk.

    However, talking about analysis and conceptual model gets into how an individual's grey matter works, and the grey matter is a grey area (pun intended).

    IOW, defining something based on a moving target, differences in individual's heads, is risky biz. (Another approach is with charts, but this has definition problems also.)

    Just something to keep in mind.

  300. bad code == job security by Tablizer · · Score: 1

    (* [rules] are not fair.*)

    Again, if you don't like my rules, suggest your own. Anybody can complain. The hard part is presenting good alternatives.

    (* I posted a counterexample to this from my own work, just the other day. *)

    This field needs Yet Another Anecdote like a hole in the head.

    (* The previous effort was written in C *)

    I hardly consider C the pinnicle of procedural/relational programming. Further, many C experts cannot or don't know how to use tables to better organize and manage code projects. I agree that procedural *alone* does not scale very well without speggetti. Tables are the Scaling Glue of procedural IMO.

    (* Their code is the type of spaghetti that is sadly common in real world procedural work *)

    I agree that much of real world code (in all paradigms) if often crap. However, this is usually because lack of incentives and/or punishment. The reality is that bad code is job security.

    I would also point out that you have the benefit of hind-sight in this case for the OO side.

    Also, I would like to see some snippets of this alleged bad procedural code. Put your code where your mouth is.

    Note that your "case study" (anecdote) did not tilt the score in Yourdon's work. Why should one believe you over Yourdon?

    (* Here you make numerous clear statements about what OOP experts say, and what people think about OOP. And yet, you provide no evidence to support any of it; not a single citation is present in that section. *)

    What use is "Bob said on webgroup X in 1998 that......". Everybody has an opinion. If you disagree with a quoted OO fan, then simply ignore it. Opinions of OO proponents are all over the map. Making every OO fan happy is impossible.

    If you want quotes from an "expert", may I suggest my commentary to Bertrand Meyer's work.

    (* You drum up some old arguments long since given up as if everyone today still believed them *)

    As a frenquentor to comp.object, I can tell you that there is *no concensus* OOP opinion/definition/methodology. Lack of consistency is one of the main problems with OO these days.

  301. Can we argue reality not theory, please? by Anonymous+Brave+Guy · · Score: 2
    Again, if you don't like my rules, suggest your own. Anybody can complain. The hard part is presenting good alternatives.

    And again, I repeat that I don't have to. I'm not the one trying to justify my claims about OOP.

    (* I posted a counterexample to this from my own work, just the other day. *)

    This field needs Yet Another Anecdote like a hole in the head.

    On the other hand, if you refuse to accept anecdotes from the many OO developers who use the technology every day in the field, how can you possibly claim to have formed a useful, unbiased opinion? There are many such anecdotes around. In persisting in ignoring them, and attacking what you perceive OO theory to be based on your own theories, you are detaching yourself from reality. The reality is that while not perfect, OOP works very well for a lot of people in a lot of situations.

    I would also point out that you have the benefit of hind-sight in this case for the OO side.

    Hardly. When the procedural code was written, our clients had double figures of experts in the field concerned to help them derive the algorithms and check the details. Now, they have two, whose knowledge doesn't even cover the whole field. Details frequently come to light months or even years after we first support a piece of hardware or analysis, and require fundamental changes to our instrument control or mathematical algorithms. Our need to adapt to changing requirements is way, way higher than that of the original procedural code. This can be objectively demonstrated simply by counting the change requests made over time. And we're succeeding, where they failed.

    Also, I would like to see some snippets of this alleged bad procedural code. Put your code where your mouth is.

    And you know damn well that any industrial-scale example is going to be both too unwieldy to show you, and certainly the public, and also covered by copyright meaning it can't be shown outside of the companies concerned. Where are your industrial-scale examples of OOP failing? Where are your industrial-scale examples of OOP projects failing? Even given that projects fail, if you're going to have a go at OOP, you need to show convincing evidence that more OOP projects fail than those using other methodologies, and that the cause of that failure was definitely OOP. I don't see even the slightest evidence of such research on your site, and without it, your arguments are purely academic.

    What use is "Bob said on webgroup X in 1998 that......". Everybody has an opinion.

    Yep, and those of us whose opinions come from real experience using the technology concerned, they have rather more validity in any sensible study than those from people whose arguments are based on theory, not practice.

    If you want quotes from an "expert", may I suggest my commentary to Bertrand Meyer's work.

    Sure, just as soon as you issue a similar critique of procedural programming, based on the books written many years ago when it first came out, instead of the current, vastly different state of the art.

    As a frenquentor to comp.object, I can tell you that there is *no concensus* OOP opinion/definition/methodology. Lack of consistency is one of the main problems with OO these days.

    You think all programmers should agree about tools and technologies, and there should be no discussion or disagreement? How are we to make progress then?

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  302. hey, this is interesting... by Anonymous Coward · · Score: 0

    with the vtable being defined by running code you can load modules into the c program during runtime that define new classes.

    You could literally have a module for round pipe and a module for rectangular pipe and load them while your program is running.

    The C++ definitions are all static and you can't extend them once they are compiled, except maybe by loading in a module that is a subclass of base class that is already loaded.

    And you could have a multidimensional vtable if you have complex data types that can't be expressed in a single dimension.

    This gives you a lot more flexibilty than C++ offers, at the cost of having code that is slightly harder to read.

    1. Re:hey, this is interesting... by Ayende+Rahien · · Score: 2

      > You could literally have a module for round pipe and a module for rectangular pipe and load them while your program is running.

      Please explain what you mean here, I'm not sure that I understand you.

      > And you could have a multidimensional vtable if you have complex data types that can't be expressed in a single dimension.

      Yuck! Just thinking about it gives me the shivers.
      Anyway, why would you want to have this? I can't think of anything that can't be expresses in a single dimension.
      It might be more conveient to have something like:
      vtbl[0]//math functions
      vtbl[1]//UI functions
      vtbl[2]//File functions

      But that is just being evil for evil's sake. You sort the functions by some order, but it only intreduce another level of indirection, and another level of complexity, where using a staight v-table would be better.

      And, anyway, you can do it much more easily on C++ via interfaces. Where this actually makes sense.

      --

      --
      Two witches watched two watches.
      Which witch watched which watch?
  303. adding new types vs. adding new operations by Tablizer · · Score: 1

    (* However, the OO framework is much more easily extensible than its procedural counterpart. You can add new subtypes of Expression, and have them immediately fit into your existing framework, without changing any of your existing code *)

    OOP generally favors adding new "types", while procedural favors adding new operations (WRT change effort). It is generally a zero sum situation in past "contests" like this. (Unless it can be shown that one is signif more likely than another.)

    However, at least in my domain, "types" are too fat a granularity of division. I tend to let features be able to combine independently of any notion of "type". This creates greater extensibility, especially for combinations of features that could not be foreseen in advance.

    1. Re:adding new types vs. adding new operations by Anonymous+Brave+Guy · · Score: 2
      OOP generally favors adding new "types", while procedural favors adding new operations (WRT change effort). It is generally a zero sum situation in past "contests" like this.

      I accept that it's easier to create new types in an OO system. If you're using a language that is pure OO, then I also accept that it's harder to add operations, if that operation happens to work with multiple types; most OO systems do not support a sufficiently powerful multimethod concept, and this is a genuine flaw in current OO methodology. In languages that do not mandate this, though -- C++ being the most obvious example -- it's no harder to add a function using multiple types than it is in the closest equivalent purely procedural language, C. The solution to the problem -- the aforementioned multimethods -- is widely known as well, but simply not very well researched yet. This is probably because the problem is so small that the research is focused elsewhere.

      However, at least in my domain, "types" are too fat a granularity of division. I tend to let features be able to combine independently of any notion of "type". This creates greater extensibility, especially for combinations of features that could not be foreseen in advance.

      But you haven't demonstrated that. You haven't even provided any examples. You have just stated it, flat out, without the slightest supporting evidence. This is typical of the arguments throughout your site, and why I refuted your conclusions in my original post.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    2. Re:adding new types vs. adding new operations by Tablizer · · Score: 1

      (* But you haven't demonstrated [granularity problems with "types"]. You haven't even provided any examples. You have just stated it, flat out, without the slightest supporting evidence. This is typical of the arguments throughout your site, and why I refuted your conclusions in my original post. *)

      May I suggest:

      http://geocities.com/tablizer/mellor.htm

      Especially note the "PC customer" example in the middle.

    3. Re:adding new types vs. adding new operations by Anonymous+Brave+Guy · · Score: 2
      May I suggest:

      http://geocities.com/tablizer/mellor.htm

      Especially note the "PC customer" example in the middle.

      I fail to see your point. There is no need to use the hierarchy you mention there in an OO model for a computer, and indeed doing so would be an unnecessarily restrictive and poor design.

      A less elaborate and much more practical model, for such hypothetical uses such as printing or persisting data, would be a single object consisting of several members, one for each indicator. The type of those could be an enumeration or numeric value in simple cases, or a reference to an object of a type corresponding to each item of data, to allow for more extension for complicated properties. Note that switching from one of these strategies to the other is trivial at any time, and they can be freely interchanged.

      One way to model ordering a PC according to your high/mid/low level and business/home use model would be to have a factory arrangement reflecting those hierarchies, perhaps based on multiple inheritance, and generating objects of the "computer" type mentioned above. Now you can have your flexibility and still the convenience of multiple factors, and the design is still clear and simple. WTP?

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    4. Re:adding new types vs. adding new operations by Tablizer · · Score: 1

      (* There is no need to use the hierarchy you mention there in an OO model for a computer, and indeed doing so would be an unnecessarily restrictive and poor design. *)

      Division into polymorphic subtypes is what the originator OO author used. It was not my idea.

      (* One way to model ordering a PC according to your high/mid/low level and business/home use model would be to have a factory arrangement reflecting those hierarchies *)

      I abandoned the "hierarchy" altogether. Those two aspects are orthogonal. Making trees out of orthogonal features is usually bad modeling in my book. That is one reason why you get silly proliferation of class names like ManagedUnbufferedSortableNonPersistableCollection( ).

    5. Re:adding new types vs. adding new operations by Anonymous+Brave+Guy · · Score: 2
      Division into polymorphic subtypes is what the originator OO author used.

      OK, so what were his credentials? Trying to force things like that into a hierarchy is a newbie mistake. It's not fair to compare newbie OO skills with expert p/r skills. No experienced OO designer worth his salt would use a whole hierarchy of classes where one would do. Wasn't that the point I, and several others, were making at the start of this subthread, in response to a suggestion that did exactly that?

      I abandoned the "hierarchy" altogether. Those two aspects are orthogonal. Making trees out of orthogonal features is usually bad modeling in my book.

      It's bad modelling in my book, too. That's why I suggested using multiple inheritance, to combine the two indepedent aspects as necessary. You can combine any others you like as well; your factory classes are independent of your "computer" object's structure, and can produce computers in any useful way, without compromising the basic data type.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  304. If you rely on anecdotes, do it right by Tablizer · · Score: 1


    (* I'm not the one trying to justify my claims about OOP *)

    Make up your mind. Do you claim OOP is objectively better than procedural/relational or not? If so, then present evidence beyond pet anecdotes.

    (* On the other hand, if you refuse to accept anecdotes from the many OO developers... *)

    Anecdotes point both ways. People who survey anecdotes both ways, like Edward Yourdon's group, find no detectable advantage.

    One anecdote is insufficient evidence, no matter how much you talk about it.

    (* And you know damn well that any industrial-scale example is going to be both too unwieldy to show you, and certainly the public, and also covered by copyright meaning it can't be shown outside of the companies concerned. *)

    That is your problem, not mine. If you can't show the code you rag on, then don't bring it up.

    Note that I *don't* claim that procedural/relational is objectively better. I suspect it is *subjective*. After all, software engineering (making software more change-friendly) is mostly about communicating with other developers and not so much machines. However, OO proponents often extract how best to manage/communicate with their *own* neurons onto everybody else's neurons.

    (* they have rather more validity in any sensible study than those from people whose arguments are based on theory, not practice. *)

    Again, anecdote surveys don't support OOP.

    (* Sure, just as soon as you issue a similar critique of procedural programming, based on the books written many years ago when it first came out, instead of the current, vastly different state of the art. *)

    I am not sure what you mean. Meyer's book is dated 1997. Is this already "legacy"?

    (* You think all programmers should agree about tools and technologies, and there should be no discussion or disagreement? How are we to make progress then? *)

    You are putting words in my mouth. I am simply responding to complaints that I allegedly don't represent "mainstream" OO viewpoints by saying that there is *no* mainstream OO viewpoint. I am just the messenger.

    1. Re:If you rely on anecdotes, do it right by Anonymous+Brave+Guy · · Score: 2
      (* I'm not the one trying to justify my claims about OOP *)

      Make up your mind. Do you claim OOP is objectively better than procedural/relational or not? If so, then present evidence beyond pet anecdotes.

      Not necessarily, no. As far as I'm aware, I never have. Procedural and OO both have their strengths and weaknesses, and my favourite language, C++, allows me to combine them as I see fit.

      What I have done is demonstrate that OO design can be markedly more successful than procedural under some circumstances, based on a large-scale, real world example that allows for direct comparison by meaningful metrics. This is a counterexample to many of the anti-OO claims you make on your web site. Hence your claims are not universally true, which is the impression you are clearly trying to give, in spite of the little disclaimer you keep conveniently inserting.

      Note that I *don't* claim that procedural/relational is objectively better.

      Really? From your other reply to me on this thread, to which I've just replied:

      However, at least in my domain, "types" are too fat a granularity of division. I tend to let features be able to combine independently of any notion of "type". This creates greater extensibility, especially for combinations of features that could not be foreseen in advance.
      That sounds pretty darn much like an "objectively better" claim to me.
      Again, anecdote surveys don't support OOP.

      So you keep saying, yet your anonymous and uncited surveys offer vastly different conclusions to my own experience, and clearly that of many others, given the continuing popularity of OO after years of use. Where are these surveys? Can you give an on-line citation or two?

      I am not sure what you mean. Meyer's book is dated 1997. Is this already "legacy"?

      In software development terms? That's ancient history. Much of the OO technique being developed in real applications today come from the current popularity of languages such as Java and C++, and from the current crop of "component" technologies (COM, CORBA, etc.) that are essentially simple OO frameworks. The state of the art in each of these was vastly different five years ago from what it is today. If you need to see how fast things have changed, compare the C++ examples in Design Patterns (1995) -- then a revolutionary book in the OO world -- with the applications of those patterns in Modern C++ Design (2001) -- the closest published work I know of to "state of the art" C++. In 1995, patterns were clever. Today, their use is routine. Their very existence is based, by definition, on the fact that people are discovering OO solutions to recurring problems.

      You are putting words in my mouth. I am simply responding to complaints that I allegedly don't represent "mainstream" OO viewpoints by saying that there is *no* mainstream OO viewpoint. I am just the messenger.

      Hardly. There is no single mainstream viewpoint, certainly, because there is more than one way of solving many problems. However, as someone who also lurks around comp.object, I'm well aware that any given expert's proposed solutions are based on reasonable premises, and not the faddish claims of naive management from years ago. The opinions you express, and the claims you make about "expert opinion", are quite opposed to anything I've seen on comp.object recently.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  305. Is performance really all that important anymore? by Anonymous Coward · · Score: 0

    People keep claiming that Fortran is faster. But is it really so much faster that this is important?

    It is more important to choose the proper algorith here than the language you choose. A bash script using O(n) and a large data set is faster than a hand tuned assembler algorith that is O(n^2).

    And even if Fortran was only 10% faster then with todays processors the fact that a job runs in 11 seconds instead of 10 isn't all that big a deal. It probably isn't even noticable. It might have been a big deal back in 1975 when it took 11 hours instead of 10 hours on a 286. But not anymore.

    I think that other features than performance matter with Fortran. It looks like the data structure sizes are fixed across all implementations and that the math functions are optimized to use IEEE standards. But there are libraries for these same purposes in C and C++ that are probably just as good.

  306. Waveforms? by sohp · · Score: 2

    Here is an example entitled Identifying Objects: A Case Study and Class Exercise giving an example of waveform rendering on an oscilloscope (see page 5), appropriately enough based on work done at Tektronix. Is that enough of an "engineering problem" for you?

  307. Only Pre-1998 OOP stinks? by Tablizer · · Score: 1


    (* Procedural and OO both have their strengths and weaknesses *)

    Perhaps, but I never get a strait answer about when, where, and why. If it is not clear when to use what and the usage opinions overlap, then it makes more sense to stick with *one* paradigm for consistency and training's sake.

    (* What I have done is demonstrate that OO design can be markedly more successful than procedural under some circumstances *)

    Perhaps, but you expose very little specific insight into this single case. We can't learn from it. Perhaps somebody could spot key flaws in those guys' procedural code if we could actually see it and make it better procedural/relational code. There is a dearth of published info on how to make procedural/relational code change-friendly.

    (* which is the impression you are clearly trying to give, in spite of the little disclaimer you keep conveniently inserting. *)

    So, how long have you been a mind-reader?

    (* That sounds pretty darn much like an "objectively better" claim to me *)

    It is a personal observation. A "cliche" if you will, similar to the sound-byte cliches people use to justify OOP to PHB's and other vapor-heads.

    I would note that my 1-D "type" observation is similar to Stepanov's (a nearby message), and independently concluded.

    (* So you keep saying, yet your anonymous and uncited surveys offer vastly different conclusions to my own experience *)

    I often get emails from people who see OO projects fail or go over budget and bloat up. Summary anecdotes are completely useless for decent comparisons, I am sorry to say. I *did* cite Edward Yourdon. Perhaps the details of his work is not available on the web, but it is at least as much as you guys have to offer.

    (* In software development terms? [1997 is] ancient history. Much of the OO technique being developed in real applications today come from the current popularity of ...... The state of the art in each of these was vastly different five years ago from what it is today.
    *)

    So all the bragging about OOP before 1998+ was all wrong and now revised?

    If the hype before 1998 was mostly crap, then how do we know that post 97 is *not* crap?

    You are defecating in your own room.

    Shouldn't it be perfected in isolation first, and THEN shoved down everybody's throats? Or, are we just all Sun's Guinney Pigs?

    (* (COM, CORBA, etc.) that are essentially simple OO frameworks *)

    I have rarely heard these referred to as "simple". So for, they mostly get lip service instead of actual use in the trenches. (And don't bother citing exceptions. I don't question their existence.)

    (* Their very existence is based, by definition, on the fact that people are discovering OO solutions to recurring problems. *)

    Most OOP "patterns" are *trivial* Boolean and/or relational formulas in the non-OO world. They are a big deal in OOP because OOP makes them complicated and have thus become an intellectual status symbol.

    (* The opinions you express, and the claims you make about "expert opinion", are quite opposed to anything I've seen on comp.object recently. *)

    I suggest you bring them up there. I rarely find a consensus on ANYTHING there. For example, the issue of whether OOP models the real world or should model the real world goes round and round for months among OO fans.

    1. Re:Only Pre-1998 OOP stinks? by Anonymous+Brave+Guy · · Score: 2
      (* Procedural and OO both have their strengths and weaknesses *)

      Perhaps, but I never get a strait answer about when, where, and why. If it is not clear when to use what and the usage opinions overlap, then it makes more sense to stick with *one* paradigm for consistency and training's sake.

      Of course there's no "straight answer". OO is better suited to some sorts of design than others, and individual experience is often the basis on which the decision is made. However, the fact that there are so many "anecdotes", some in favour of OO, others of procedural, makes it quite clear that both can be advantageous when used by the right people in the right way. Of course, I agree that it would be great to find some concrete and well-evidenced guidelines for this, but in the meantime, experience will have to do.

      (* In software development terms? [1997 is] ancient history. Much of the OO technique being developed in real applications today come from the current popularity of ...... The state of the art in each of these was vastly different five years ago from what it is today. *)

      So all the bragging about OOP before 1998+ was all wrong and now revised?

      No. Much of the bragging was justified, at least from the point of view of the braggers. However, OO was too much of a buzzword in the mid-90s, too many idiots got involved, and started claiming it was magic, which of course it isn't. Much the same happened for Java a bit after that, and is currently happening for "web services". Time shows each to be a useful technology in the right circumstances, but rarely as fantastic as the most evangelical make out during a period of hype. Mercifully, such idiots seem to have left OO behind for the most part just now, and we can discuss things in a rational and constructive way instead.

      (* Their very existence is based, by definition, on the fact that people are discovering OO solutions to recurring problems. *)

      Most OOP "patterns" are *trivial* Boolean and/or relational formulas in the non-OO world. They are a big deal in OOP because OOP makes them complicated and have thus become an intellectual status symbol.

      OK, here is a simple challenge: look at the patterns in the "gang of four" book (I assume you've read it, since you're expressing an opinion on the subject) and tell me the "trivial" Boolean and/or relational formula to which each corresponds in the non-OO world. There aren't many, and if they really are trivial as you claim, it shouldn't take any longer than it's taking me to write this reply.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  308. If all you know is dBase IV, everything's a nail? by CRConrad · · Score: 1
    The "Tablizer":
    If it is not clear when to use what and the usage opinions overlap, then it makes more sense to stick with *one* paradigm for consistency and training's sake.
    So what you're saying is pretty much "If you're too dumb to figure out when to use a hammer and when to use a wrench or a screwdriver, then it makes more sense to stick with *only* a hammer for consistency and training's sake.", right?

    Remind me not to hire you to do any carpentry for me, Bryce...
    --

    Christian R. Conrad
    mail me at iki.fi ; same user ID as here
  309. Re:If all you know is dBase IV, everything's a nai by Martin+Spamer · · Score: 2


    So what you're saying is pretty much "If you're too dumb to figure out when to use a hammer and when to use a wrench or a screwdriver, then it makes more sense to stick with *only* a hammer for consistency and training's sake.", right?

    And every requirement becomes a nail to be beaten into submission. lol:)

    p.s. This is a well known usenet troll.

    http://groups.google.com/groups?q=%22topmind@tec hn ologist.com%22+troll&btnG=Google+Search
    http://groups.google.com/groups?as_uauthors=topm in d@technologist.com%20&hl=enSo

  310. Stick to the issues, please by Tablizer · · Score: 1

    I could not figure out why the mod values suddenly dropped after a few days of relatively stable levels. Then I saw your handle. You and the Zenvague gang over at the Z have barged in and done a little score trolling it seems.

    Regarding your worn-out hammer cliche, it would be like OO expert A uses a hammer on part 1 and a screwdriver on part 2, but OO expert B uses a screwdriver on part 1 but a hammer on part 2. It seems fairly clear that one could use *just* a screwdriver on both parts (assuming good experts) and get similar results WRT quality.

    Mixing paradigms may give say a 5 percent benefit, but at the cost of less consistency and double the training and almost double the complexity of the language. You sacrifice consistency, training costs, and language complexity for a really minor gain. That is not logical, Captain.

    BTW, I see you chose to ridicule me instead of address the Yourdon and Stepanov issues. How CRC of you.

  311. Nothing External by Tablizer · · Score: 1

    This is a well known usenet troll.

    Tell me something. Is a "troll" somebody who is wrong, or just somebody who is annoying?

    I may indeed be annoying, but nobody has shown any decent evidence that OOP is better other than vague cliches and feel-good statements about it.

    In the end, someday distant they will discover that it is probably mostly subjective. OOP maps to some people's heads better than others it seems. However, there is nothing about it that objectively fits the real (external) world better nor real world change-patterns better. (At least in my domain.)

  312. Reply Part 2 by Tablizer · · Score: 1

    I missed some paragraphs on the first pass.

    (* The database is at the core of our whole application, and the APIs we designed to access it are still standing, *)

    Care to list the interfaces here?

    (* You can write data from an OO program out to any format file you like, just as you can with procedural languages *)

    This greatly depends. I would be glad to take the issue up at comp.object.

    (* Writing a good wrapper, which provides a mapping from your OO system's concepts onto the procedural API, can take much longer, of course, but adds value in the process. *)

    Such as?

    (* Do you know what multiple inheritance is? *)

    Using multiple inheritance for many of the problems I describe does not seem very popular even with the OOP crowd. It generally seems to be used for *diverse* properties being inherited, not potentially overlapping or interfering properties.

    (* And yet, every serious OOP instruction I have ever experienced, in print, at a training course or from senior staff at work, has been quick to stress that inheritance should not be overused. *)

    Well, such warnings did not make it into most of the OOP books on my shelf. It is a well-known "newbie fault". If it is such a common disclaimer, then why are all the newbies missing it?

    (* Those would be pretty similar to the "ideal" conditions for any programming paradigm. *)

    OOP seems *more* sensitive to such imperfect conditions than p/r. Richard McDonald, an OOP proponent on comp.object holds that opinion more or less. I suggest you take it up with him since you two probably think more alike.

    (* I've got to about halfway down the page now. I could go on, and I'm half tempted to have a go at your final conclusions, but I don't see much point. *)

    I would rather see an OOP business example and/or code kicking p/r's ass using whatever metrics you choose (and can justify). My cliche pages to counter OO cliches are simply bonus information. The burden of public evidence of objective OO benefits is in your hands. Are you up to it, or just another talking head? (Remember, I don't have the same burden because my viewpoint is that they are subjective.)

    1. Re:Reply Part 2 by Anonymous+Brave+Guy · · Score: 2
      (* The database is at the core of our whole application, and the APIs we designed to access it are still standing, *)

      Care to list the interfaces here?

      I obviously can't list the whole thing in detail; that would be around 250,000 lines of code.

      The basic idea is that our database is OO, and each type of instrument that we can control, measurement we can take, etc. is modelled as a type. The whole UI and macro language is based on the concept of invoking operations on the objects of those types, and is completely configurable from data files (in the case of the UI) and provided for free by the framework (in the case of the macro language). This works very well, since most of what our application does can be modelled naturally as a signal to an instrument or an action on some resulting data. More complex situations, such as secondary results derived from multiple primary sources, are also modelled naturally in this environment.

      (* Writing a good wrapper, which provides a mapping from your OO system's concepts onto the procedural API, can take much longer, of course, but adds value in the process. *)

      Such as?

      A good OO GUI framework will present the rest of the application with general concepts, and map them onto the specifics of the platform in use, freeing the higher levels of platform dependence. As I mentioned before, this is no different to providing an isolation layer in procedural programming, and costs no more.

      Using multiple inheritance for many of the problems I describe does not seem very popular even with the OOP crowd. It generally seems to be used for *diverse* properties being inherited, not potentially overlapping or interfering properties.

      Basic multiple inheritance typically is indeed used for diverse properties. However, some elegant idioms allow convenient mixing in of overlapping or interfering properties as well. The "decorator" pattern is a good example of this.

      (* And yet, every serious OOP instruction I have ever experienced, in print, at a training course or from senior staff at work, has been quick to stress that inheritance should not be overused. *)

      Well, such warnings did not make it into most of the OOP books on my shelf. It is a well-known "newbie fault". If it is such a common disclaimer, then why are all the newbies missing it?

      It's made it into several of the books I've read. As for the newbie fault, well, they're newbies. I bet they couldn't factor a complex procedural algorithm into elegant subroutines as well as a more experienced programmer, either.

      I would rather see an OOP business example and/or code kicking p/r's ass using whatever metrics you choose (and can justify).

      The example I gave before is compelling. In a direct comparison between a procedural approach and an OO one to the same problem, the OO solution has been developed more than 10 times faster (objective fact), in spite of inferior information available (objective fact, based on documentation and human knowledge available then and now) and much more frequent changes in requirements (objective fact, based on formal requirements specs and feature requests).

      Obviously, I can't send you all the code to examine, so I have to assume that you trust my information if this is to be a useful conversation. But I have no reason to lie; I do not claim this is a universal truth, just a single example that meets your criteria.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    2. Re:Reply Part 2 by Tablizer · · Score: 1

      (* I obviously can't list the whole thing in detail; that would be around 250,000 lines of code. *)

      I only asked for the basic DB interface descriptions. If your DB interfaces take 250,000 lines of code, I question your programming skills or suspect scope creep anyhow.

      (* and each type of instrument that we can control, measurement we can take, etc. is modelled as a type. *)

      I have never found a good use for "types" (taxonomies) of things in biz apps. I get more flexibility allowing features to recombine independently at the smallest granularity practically possible. "Types" are like being forced to pick a political party when what you really want is to vote on specific issues. I don't know if engineering applications have this granularity problem, but biz apps do in my observation.

      I realize that some humans may be able to grok things better when features are aggregated into some kind of taxonomy (types), but IMO, that is not the best road to change-friendly software. (An intermediate "template" table/list can be used to serve as a template for common combinations of features. However, it should not be considered an ultimate source of organization.)

      (* A good OO GUI framework will present the rest of the application with general concepts, and map them onto the specifics of the platform in use ... *)

      GUI design/frameworks is a complex issue that cannot be addressed here. IMO, most GUI info is *data* and should not be in code (ex: coordinates, widths, etc.).

      (* Basic multiple inheritance typically is indeed used for diverse properties. However, some elegant idioms allow convenient mixing in of overlapping or interfering properties as well. *)

      A specific example may help illustrate our different philosophies. However, the use of MI for related features is generally controversial among OO crowds. You risk real debugging nightmares like overlapping (same named) methods.

      (* As for the newbie fault, well, they're newbies. *)

      But why is that *particular* mistake common?

      (* The example I gave before is compelling. *)

      No, because it is invisible to us. And, the p/r may just be bad p/r. We can't know for sure until it is exposed for scrutiny. Until it lands on the Whitehouse lawn........

      (* Obviously, I can't send you all the code to examine, *)

      Couldn't you articulate and/or illustrate one particular feature or issue that made the OO version allegedly better/shorter/change-friendly?

      (* just a single example that meets your criteria. *)

      "Publicly inspectable" is one of my criteria.

    3. Re:Reply Part 2 by Anonymous+Brave+Guy · · Score: 2
      I only asked for the basic DB interface descriptions. If your DB interfaces take 250,000 lines of code, I question your programming skills or suspect scope creep anyhow.

      You miss my point. All of our instrument control logic, for example, is modelled as operations on the instrument types concerned. That logic is therefore part of the DB interface offered to the UI, macro language, etc., which all use quite general rules to access anything modelled in the database.

      The underlying interfaces to access the actual database are all encapsulated in base classes, on which the classes providing the types above are based. They are just based on a DB library (varying, depending on how we're building).

      IMO, most GUI info is *data* and should not be in code (ex: coordinates, widths, etc.).

      Well, you're entitled to your opinion, of course. However, noting the number of OO GUI toolkits out there, and the fact that so much software is written using them, clearly others do find an OO model for a GUI useful.

      However, the use of MI for related features is generally controversial among OO crowds.

      The use of MI generally is controversial. Those who program in languages with it think it's great. Those who think Java really "supports" OO programming frequently insult it in religious attempts to defend their language's position. And then they provide absurd and vastly overcomplicated idioms to do what would be trivial with proper MI.

      (* As for the newbie fault, well, they're newbies. *)

      But why is that *particular* mistake common?

      Dunno. Maybe it's because they lack experience, and tend to overuse "flashy" features. This is true of newbies in general, so I see no reason for newbies to OO to be any different.

      (* The example I gave before is compelling. *)

      No, because it is invisible to us. And, the p/r may just be bad p/r. We can't know for sure until it is exposed for scrutiny.

      And as I pointed out before, that's why no-one is taking up your challenge. Most decent examples of this, certainly industrial scale projects, aren't open source. If you genuinely want to get useful information here, don't start by cutting off the vast majority of your possible sources.

      And yet, here I have a large-scale, long-term project, where an OO and a procedural approach are directly comparable. I can't show you the whole code, but I have provided objective metrics in terms of time to write it, and the demands placed upon the development.

      Your only replies seem to be "It doesn't count if we can't see the code" and "Well, maybe the procedural guys sucked". Those are hardly convincing arguments. The procedural guys sucked so much that it took them ten times longer to write their version, in spite of having fewer demands placed on them and more expert knowledge available? Wow, they must have been really bad. Makes you wonder how they ever got jobs as professional programmers at all, all 20 of them. Either that, or I'm working in a room with 5 Linuses.

      You may choose to believe me or assume that for some reason I'm making this up, but here I have at least one example that clearly satisfies your challenge.

      Couldn't you articulate and/or illustrate one particular feature or issue that made the OO version allegedly better/shorter/change-friendly?

      Not really. The major benefits don't come from individual features. The strength of the system comes from having a clear overall design, something that deteriorated in its procedural predecessor. Most of the work fits into three "frameworks", one for the instrument control, one for the maths, and one for the UI. These frameworks set out a clear pattern for development, as any good design would, and make explicit the relationships between various aspects.

      For example, to change the way something works for all instruments in a particular series, you know immediately that the common functionality will be in the base class for that series, and you also know immediately that changing that base class will affect all instruments that don't specifically override the behaviour (but you still have the latter option if you don't want your change to be made everywhere).

      In comparison, the procedural version of the project would have several versions of the algorithm concerned, but each instrument's code must explicitly call the correct algorithm for that instrument, every time. The fact that an instrument always calls the same group of related algorithms has not been modelled, and sure enough, several of the bugs that have come out are because someone called the wrong function. Careless, maybe, but a risk you take with the procedural design.

      Using OO lends a helping hand to guide the developer in finding his way around. It also, to an extent, helps to enforce the overall architecture. It's easier to plug in a new bit of code when you already know where it has to go and what essential interfaces it's going to use. You can do any of this in procedural as well, of course, but in my experience it's harder work and more error prone.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  313. can vs. can better by Tablizer · · Score: 1

    (* OK, so what were his credentials? *)

    Creditentials are no guarentee of better software design anyhow. I wanna see self-standing open evidence, not puffery.

    BTW, the originator is an author of many C++ books.

    (* It's bad modelling in my book, too. That's why I suggested using multiple inheritance, to combine the two indepedent aspects as necessary. *)

    This tends to only work if they are *completely* independent. If there is dynamic overlap, then you may constantly be doing the "noun shuffle" as described on my webpage.

    Other OO proponents would probably recommend the (bloated) decorator pattern over multi inher for such, BTW.

    1. Re:can vs. can better by Anonymous+Brave+Guy · · Score: 2
      BTW, the originator is an author of many C++ books.

      So is Herb Schildt, but look at the various FAQs and web pages dedicated to him, and you'll soon see how the experts view him. When I said "What were his credentials", I meant what real-life projects has he brought home using OO techniques -- as you say, self-standing examples, not puffery. I find it easy to believe that a theoretician could have made the statement you claim, but hard to believe anyone with much time in the trenches would do so.

      This tends to only work if they are *completely* independent. If there is dynamic overlap, then you may constantly be doing the "noun shuffle" as described on my webpage.

      Well, as noted previously, you can use things like mix-in idioms as well. I've never had any problems modelling dynamic overlap situations with OO techniques so far. Are there particular circumstances you have in mind?

      Other OO proponents would probably recommend the (bloated) decorator pattern over multi inher for such, BTW.

      Decorator is no more bloated than having a list of functions to call and iterating through it in a procedural language. I suspect it's unnecessary here, but the pattern itself is sound when used in the right place -- that is, after all, pretty much the definition of a design pattern.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    2. Re:can vs. can better by Tablizer · · Score: 1

      (* I've never had any problems modelling dynamic overlap situations with OO techniques so far. Are there particular circumstances you have in mind? *)

      I just find tablizing them helps me manage, view, and grok the information and relationships better. What F's up one person may not necessarily F up another. Software engineering is mostly about communicating between developers (including the future self), and not so much machines.

      (* Decorator is no more bloated than having a list of functions to call and iterating through it in a procedural language. *)

      Most of the time the information is factorable into attributes. Actual need (or benefits) to put program code in such tables is relatively rare, or at least a very small percent of the columns. Factoring into attributes makes the tables even more concise.

      Tables are generally easier to sort, filter, and search than code. (AKA "dynamic viewing".) They come that way out-of-the-box for the most part. You don't need a fancy IDE to get that.

      The root of software engineering is making it easier and quicker to "manage a bunch of stuff". Code is just too hard to grok compared with tablized control info IMO.

  314. Perhaps C itself is the problem by Tablizer · · Score: 1

    (* for example, is modelled as operations on the instrument types concerned. *)

    Like I said, I am highly skeptical of anything modeled with "types". Anyhow, show us your code and amaze my procedural/relational ass. Talk is cheap. I get email of anecdotes of OO failures also.

    (* Well, you're entitled to your opinion, of course. However, noting the number of OO GUI toolkits out there, and the fact that so much software is written using them, clearly others do find an OO model for a GUI useful. *)

    Or, it could be a fad. API providers tend to clone each other's approach to play it safe.

    (* And then they provide absurd and vastly overcomplicated idioms to do what would be trivial with proper MI *)

    Example?

    (* Maybe it's because they lack experience, and tend to overuse "flashy" features. *)

    So you indirectly admit that some of OO's popularity may be due to a "fad factor".

    (* Most decent examples of this, certainly industrial scale projects, aren't open source. If you genuinely want to get useful information here, don't start by cutting off the vast majority of your possible sources. *)

    You seemed to have cut off Yourdon's research.

    (* And yet, here I have a large-scale, long-term project, where an OO and a procedural approach are directly comparable. *)

    I am not even sure C is capable of "decent p/r". (I know I will alienate C fans, but I cannot see how it can be competitive from a SE standpoint. It just does not gel with me.)

    (* Your only replies seem to be "It doesn't count if we can't see the code" and "Well, maybe the procedural guys sucked". Those are hardly convincing arguments. *)

    And your one anecdote is more convincing than other's, including Yourdon's surveys? Double standard? If you are so hellbent on anecdotes, why ignore Yourdon's work?

    (* The procedural guys sucked so much that it took them ten times longer to write their version, ....*)

    I had a similar experience between C and a higher-level procedural/relational language. I started writing a hobby MIDI sequencer in C. Although I got it working, I abandoned C for the other language when PC's got fast enough. My productivity was many-fold higher.

    (* The major benefits don't come from individual features. The strength of the system comes from having a clear overall design, something that deteriorated in its procedural predecessor. *)

    Well, then they did something wrong. The 3-graph p/r model works and scales. Perhaps they deviated from it for some odd reason, or your domain is somehow different in that regard.

    (* For example, to change the way something works for all instruments in a particular series, you know immediately that the common functionality will be in the base class for that series, and you also know immediately that changing that base class will affect all instruments that don't specifically override the behavior (but you still have the latter option if you don't want your change to be made everywhere)......*)

    Like I keep saying, variations do *not* fit naturally into trees nor align on clean method boundaries in my domain (Overriding 1/3 of a method is a royal pain). I have asked for biz taxonomies that can take advantage of such WRT to variation-management. They have all failed.

    Maybe for some reason your "instruments" have a stable and granularity-predictive taxonomy about them. I don't know, I never worked there. It would be interesting to analyze the change patterns to see which organizational schemes require the fewest changes, etc.

    (* It also, to an extent, helps to enforce the overall architecture. *)

    My apps are *not* willy-nilly (except maybe to those who only know how to grok OO).

    (* You can do any of this in procedural as well, of course, but in my experience it's harder work and more error prone. *)

    Could that be subjective (person-dependant)? People make different kinds and patterns of mistakes. Human errors are as distinctive as faces. (And some faces are errors :-)

  315. Hoodwinking PHB's by Tablizer · · Score: 1

    (* Of course, I agree that it would be great to find some concrete and well-evidenced guidelines for this, but in the meantime, experience will have to do. *)

    Well, individual anecdotes are barely better than no evidence. I know it bothers you, but I have to reject "closed" anecdotes. Science has learned the hard way that they are only good for investigation leads, and generally not evidence itself.

    (* However, OO was too much of a buzzword in the mid-90s, too many idiots got involved, and started claiming it was magic, *)

    Do you really think that idiots dissappear that fast? Especially when OO cliches still work on PHB's.

    BTW, my procedural/relational version of some of the GOF (and popular) patterns are at:

    http://geocities.com/tablizer/prpats.htm

  316. Sets vs. Trees by Anonymous Coward · · Score: 0

    I have some further questions and comments about your example.

    (* For example, to change the way something works for all instruments in a particular series, you know immediately that the common functionality will be in the base class for that series, and you also know immediately that changing that base class will affect all instruments that don't specifically override the behaviour (but you still have the latter option if you don't want your change to be made everywhere). *)

    What I find works better for my domain is to "classify" things using sets, and not trees (inheritance). You specify which set a thing belongs to. Then it can "inherit" anything that it's given set(s) is supposed to inherit.

    I realize that multiple inheritance is roughly a set mechanism, but it does not manage overlaps very well IMO. For example, class A may do action X for operation 1, and class B may do action Y for operation 1. However, what if we had a rule like:

    If in set A and in set B, then do Z.

    The set membership does not change, but the behavior might. In procedural programming generally only the rule would be changed, not the position of the code that implements Z. OO would likely try to associate Z with *what* gets that operation. The problem is that rules for "triggering" a given operation are fairly likely to change. Thus, grouping by task instead of by the thing being operated on results in less code rearrangement it would follow.

    (* In comparison, the procedural version of the project would have several versions of the algorithm concerned, but each instrument's code must explicitly call the correct algorithm for that instrument, every time. *)

    I am not sure what you mean here by "explicit". Like I said, if a given group shares something in common, then use set membership (such as a Group-X checkmark in an Instrument table. Tablizing such allows association changes to be made without recompilation).

    Are you also saying that the OOP version would *not* have "several versions"?

    1. Re:Sets vs. Trees by Anonymous+Brave+Guy · · Score: 2
      I realize that multiple inheritance is roughly a set mechanism, but it does not manage overlaps very well IMO. For example, class A may do action X for operation 1, and class B may do action Y for operation 1. However, what if we had a rule like:

      If in set A and in set B, then do Z.

      If you have that kind of rule appearing, then clearly Z is not both a type of A and a type of B, and the inheritance model is not appropriate. In any real example, this should have been obvious from the word go. Genuine derived types don't suddenly not become derived types in real cases, even in response to significant changes in requirements. (If the requirements change is severe enough that this does not apply, then the possibility of a complete change of design is indicated anyway. I don't think I've ever seen such a total change in requirements in practice, however.)

      I am not sure what you mean here by "explicit". [...] Are you also saying that the OOP version would *not* have "several versions"?

      The OOP version has several versions of the algorithm, but all instruments of the same type automatically call that type's version of the algorithm, because the code is in the base class that is automatically shared. This is a very frequent requirement in the field I'm working in. In the procedural equivalent, a separate, explicit call to the correct routine is required in each case. This introduces a possibility for errors, and as noted previously, this is not a purely theoretical complaint; such errors frequently happened in practice.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    2. Re:Sets vs. Trees by Tablizer · · Score: 1

      (* If you have that kind of rule appearing, then clearly Z is not both a type of A and a type of B, and the inheritance model is not appropriate. *)

      Exactly, and why risk this happening after much of your design is already devoted to tree-based taxonomies?

      (* If the requirements change is severe enough that this does not apply, then the possibility of a complete change of design is indicated anyway. *)

      I view the problem on a continuous scale, not all or nothing. But then again, I am talking about custom business software, and do not know the widgets that you deal with. My domain spends a lot of time trying to model the whims of PHB's, marketers, and politicians. Perhaps your widgets change with more predictably than these guys. You are modeling unintelligent machines, while I am trying to model half-intelligent machines (and their change patterns).

      (* because the code is in the base class that is automatically shared. *)

      It is not automatically shared. You have to *explicitly* tell the class who its parents are. How is this different than indicating which set(s) a widget belongs to? (Via a field setting in a table.)

      I am not seeing the alleged error prevention.

      (* In the procedural equivalent, a separate, explicit call to the correct routine is required in each case. *)

      Not if the behavior is tied to which set the widget belongs to. In some cases one may indeed want to tie the behavior to a specific widget, but in others it can be tied to sets. It seems you perhaps did not explore your procedural/relational options thoroughly enough since you only presented the procedure call option.

  317. The limited scope of your claims is the problem by Anonymous+Brave+Guy · · Score: 2
    (* Maybe it's because they lack experience, and tend to overuse "flashy" features. *)

    So you indirectly admit that some of OO's popularity may be due to a "fad factor".

    I didn't indirectly admit it, I said it outright several posts ago. However, my comment quoted above is not in any way evidence to support that, as you seem to be implying. OO has been around for decades and it's still here, so I find any claim about it being a fad to be a little laughable.

    You seemed to have cut off Yourdon's research.

    I'm still waiting to see a citation so I can go read it. I'm also still waiting to hear any other evidence. Most of your argument so far seems to have been based either on your own subjective views, which I don't share, on this survey of Yourdon's, which you haven't cited that I've seen, or on pure faith. My argument is based on personal experience, both theoretical and practical, which suggests that while some of your criticisms are valid, the big picture is far from as bleak as you make out.

    (* The major benefits don't come from individual features. The strength of the system comes from having a clear overall design, something that deteriorated in its procedural predecessor. *)

    Well, then they did something wrong.

    Sure they did. They lost control of their design, and the project failed. That happens frequently in software development. However, given that their project failed and ours didn't, we must ask why. The major differences are in the teams who wrote the code and the technologies used. Given that we know the original team was both bigger and more highly qualified in the domain concerned, we can only conclude that the different technologies and techniques used in development were the deciding factor.

    The 3-graph p/r model works and scales. Perhaps they deviated from it for some odd reason, or your domain is somehow different in that regard.

    Did it occur to you that your "business applications" domain is only a significant minority of all programming that gets done? The rest of the world is different. If you're going to go around criticising OOP in a limited case, you need to make a prominent disclaimer that your comments apply only to using OOP for writing applications in your domain every time.

    I also note that you continuously lump relational programming techniques in as if they were part and parcel of procedural programming. They are not. Few of the languages I would say support procedural programming have built-in support for relational operations, so I claim that the two are separate. It is unfair to claim that OOP does not much improve upon procedural techniques, when you yourself use table-driven methods instead because the simple procedural approach doesn't work for you, either.

    Moreover, your table-driven approach is right at home in the database world, but I claim that it is largely or totally irrelevant in many other fields. The instrument control system in my example is not full of separately configurable parts, it's full of things that are clearly and necessarily dependent. OO models this perfectly. A table-based approach to the sort of dispatching we do would only allow for needless errors as a result of invalid or missing data. It is simply the wrong tool for the job, while OO is a suitable one, in this particular case.

    Like I keep saying, variations do *not* fit naturally into trees nor align on clean method boundaries in my domain

    There you go again: in your domain. The rest of the world works differently. In the domain of the example I gave earlier, we control a whole family of instruments. Each has some basic properties, such as uniform interfaces to talk to the hardware and GUI. There are several series of instrument, used to measure different types of property, and these do not (and will never) overlap, since it makes no sense in the area of science concerned for them to do so. There are then several instruments in each series, of varying capabilities. We model this using a simple inheritance hierarchy, and it works very well. Each class genuinely is a type of the parent class, which is the only correct use of full inheritance in an OO system. Our whole application rests on several such hierarchies, but because we only use inheritance in appropriate places (containment is a far more common relation between classes in our model), we rarely have problems with this.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    1. Re:The limited scope of your claims is the problem by Tablizer · · Score: 1

      (* OO has been around for decades and it's still here, so I find any claim about it being a fad to be a little laughable. *)

      It has only been in the mainstream for a little more than a decade. Most fads *were* around somewhere (usually a lab or two) before hitting big-time. IOW, one such look at the time in the limelight, and not the time since birth. Expert Systems and CASE and heavy top-down were around long before they had their days in the sun.

      (* I'm still waiting to see a citation so I can go read it. *)

      It is cited in the book Rebirth of the American Programmer.

      (* the big picture is far from as bleak as you make out. *)

      Like I said, I believe that paradigms are probably subjective. Those with OO heads will do better with OO and visa versa. It is the idea that OO is objectively better and a "step up the evolutionary ladder" is the crap that I am fussing about.

      (* However, given that their project failed and ours didn't, we must ask why. *)

      I suspect it is largely because you had good software engineering training in your paradigm but that they had not in theirs. SE Books that talk about effective use of procedural and relational technology *in conjunction* are very rare.

      (* Did it occur to you that your "business applications" domain is only a significant minority of all programming that gets done? *)

      I have readily agreed that "one size does not fit all (domains)". BTW, I am not sure what you intended "significant" to modify.

      (* you need to make a prominent disclaimer that your comments apply only to using OOP for writing applications in your domain every time. *)

      Every time? That is a little extreme, wouldn't you say?

      (* I also note that you continuously lump relational programming techniques in as if they were part and parcel of procedural programming. They are not. Few of the languages I would say support procedural programming have built-in support for relational operations, so I claim that the two are separate. It is unfair to claim that OOP does not much improve upon procedural techniques, when you yourself use table-driven methods instead because the simple procedural approach doesn't work for you, either. *)

      I consider procedural and relational a yin-and-yang complimentary relationship. OOP tends to fight over territory with relational tables. For example, table schemas are often duplicated in OOP code. This unnecessarily violates Meyer's Single Choice principle.

      (* The instrument control system in my example is not full of separately configurable parts, it's full of things that are clearly and necessarily dependent. *)

      Huh? I think you left "relational" out of RDBMS.

      (* It is simply the wrong tool for the job, while OO is a suitable one, in this particular case. *)

      Perhaps. Just don't let your colleagues extrapolate what works in your area into everything else and practically kill off all alternatives leaving nothing but a choice between Java or Java or "fries with that".

  318. Decorator pattern by Anonymous+Brave+Guy · · Score: 2
    (* Decorator is no more bloated than having a list of functions to call and iterating through it in a procedural language. *)

    Most of the time the information is factorable into attributes.

    Then you shouldn't be using decorator. That pattern is most useful when you want to add things at will and the order is significant. Attributes cannot cope with such a situation. You would need some sort of ordered list(s) of functions to iterate to get a straightforward procedural equivalent to decorator, but that equivalent then must have some centralised controlling logic to co-ordinate traversing the list(s) and acting on the contents. That can be a nasty limitation, introducing unwanted dependences on some artificial "central control", which is why we opted to use decorator in the first place on our project.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    1. Re:Decorator pattern by Tablizer · · Score: 1

      (* That pattern is most useful when you want to add things at will and the order is significant. Attributes cannot cope with such a situation. *)

      We would probably have to look at specific cases in detail to settle this, but attributes are more adaptable than algorithms. Any place you can put an algorithm you can also put an attribute.

      (* You would need some sort of ordered list(s) of functions to iterate to get a straightforward procedural equivalent to decorator, *)

      Or a relational table(s). You can then sort, filter, cross-reference, etc. them anyway you please.

      (* but that equivalent then must have some centralised controlling logic to co-ordinate traversing the list(s) and acting on the contents. *)

      I am not sure what you mean. The RDBMS generally hides away those details from table users/developers.

  319. OK, so why not mix and match? by Anonymous+Brave+Guy · · Score: 2
    [Yourdon's survey] is cited in the book Rebirth of the American Programmer.

    Unfortunately, being neither American nor in search of rebirth, I've never read that one. Can you provide a citation here? It sounds like it would make interesting reading.

    I consider procedural and relational a yin-and-yang complimentary relationship. OOP tends to fight over territory with relational tables. For example, table schemas are often duplicated in OOP code.

    OK, but since surely the way forward is to allow judicious combination of useful techniques, why must they always be mutually exclusive? I can (and often do) use simple table-based techniques in my application at work, precisely because of the benefits you cite in terms of independent variation of features.

    The overall design is broken into hierarchies related by containment, inheritance, etc., but this does not preclude the use of table-based techniques as well for the "little details" where extra classes or method overrides are overkill. In fact, they go together quite nicely, since you can incorporate a suitable table or two into your top level base class, and provide a nice controlled interface to access and update the table should any derived classes need to do so.

    We don't, on the current project, use a full-scale relational table system, because that, too, would be overkill for our purposes. I see no reason that it couldn't be incorporated, and just as complementary to the OOP main design, if it were needed, though.

    (* The instrument control system in my example is not full of separately configurable parts, it's full of things that are clearly and necessarily dependent. *)

    Huh? I think you left "relational" out of RDBMS.

    Well, if you're going to have multiple, related tables to model something like this, then you're going to have to impose certain restrictions yourself. Just as with OOP, if the model later changes and moves outside of your initial constraints, you need to do a little reorganising. I really don't see much difference between OOP or a table-based approach here; either is more helpful than a simple procedural approach, and obviously neither is guaranteed to give you the perfect design that never changes. In neither case is it particularly difficult to modify the design when new requirements come in, so I don't see the problem.

    Just don't let your colleagues extrapolate what works in your area into everything else and practically kill off all alternatives leaving nothing but a choice between Java or Java or "fries with that".

    I wouldn't dream of it. For a start, Java has an underpowered OO model. It trades off simplicity against power in favour of simplicity. Usually, that works, and the simplicity is probably one reason for Java's popularity. But for serious OO modelling, I find things like the lack of a value/reference distinction and crippled MI mechanism to be very limiting.

    My argument is not, and never has been, that OO is universally superior. As I said at the start, I use a mix of paradigms, and draw on them as appropriate. I simply contend that under the right circumstances, OO can and does provide a better basis for a model than procedural, or indeed purely table-driven, programming techniques. Under those circumstances, many of the claims you reject on your web site are actually justified.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    1. Re:OK, so why not mix and match? by Tablizer · · Score: 1

      (* Can you provide a citation here? It sounds like it would make interesting reading. *)

      I don't have the book with me now. I paraphrased some on my anti-OO webpage. Note that the book itself does not present the full details of the study, only paraphrases and cites results from it. If you are interested, you will probably have to do the "library shuffle". (Note that the book was a follow-on to "Death of the American Programmer".)

      (* OK, but since surely the way forward is to allow judicious combination of useful techniques, why must they always be mutually exclusive? *)

      I believe the mix issue already came up around here somewhere. In summary, the benefits of mixing must be minor compared to training, coordination, and consistency costs because even alleged OO experts cannot agree on which parts to use OO and which parts not. If one says make part A p/r and part B oo, and the other says the opposite, then OO is not likely significantly benefiting A nor B.

      (* In fact, they go together quite nicely, since you can incorporate a suitable table or two into your top level base class, and provide a nice controlled interface to access and update the table should any derived classes need to do so. *)

      Sounds great as text, but I would like to see such as code. If you over-wrap something, then you may have to unwrap it, or add yet-another corrector interface if it turned out not to flex as needed. I tend to "ride" on tables instead of try to hide from them. The tables become the information/control management paradigm themselves rather than just another persistence interface.

      (* We don't, on the current project, use a full-scale relational table system, because that, too, would be overkill for our purposes. *)

      I honed most of my table skills on "lite" table systems like XBase. XBase has a lot of (mostly correctable) software engineering faults, but it taught how tables can be easy and nimble. The latest crop of RDBMS focus too much on the formal high-end transaction market, where the fat bucks are.

      (* I wouldn't dream of it. For a start, Java has an underpowered OO model. *)

      And under-powered procedural system. It ain't shine nowhere :-)

      However, the debate over M.I. rages on among OO proponents. I suggest you take it up with them.

      (* I simply contend that under the right circumstances, OO can and does provide a better basis for a model than procedural, .... *)

      Well, I have not seen nearly enough to justify it in my domain. If you pour every blue-moon feature into a language or tool, then you get a pack-rat mess that is abused by bored newbies.

    2. Re:OK, so why not mix and match? by Anonymous+Brave+Guy · · Score: 2
      Note that the book itself does not present the full details of the study, only paraphrases and cites results from it.

      So, not only can you not show me any evidence, you now tell me that your position is based only on selective parts of the evidence you do have? That's not very scientific!

      Sounds great as text, but I would like to see such as code. If you over-wrap something, then you may have to unwrap it, or add yet-another corrector interface if it turned out not to flex as needed.

      The interfaces concerned are completely generic as far as the table's contents go. They simply provide the basic concept of a "table", since the application is written in C++, which has no built-in support for same.

      (* I wouldn't dream of it. For a start, Java has an underpowered OO model. *)

      And under-powered procedural system. It ain't shine nowhere :-)

      Java shines in its simplicity. By eliminating many complicated features, they sacrifice some power, but gain a lot of ease of use. Java does a lot of simple things well, and that is why it has such a large following. It doesn't do the really clever modelling well, and isn't even comparable to a language like C++ in overall facilities, so it's the wrong tool if your requirements go that far. Most people's don't.

      However, the debate over M.I. rages on among OO proponents. I suggest you take it up with them.

      I don't have to; I personally need no convincing about the worth of MI, or its openness to abuse. My feeling, based on several years of OO use in development, is that it is a rarely justified feature, but working around its absence when you want it is nasty.

      If you pour every blue-moon feature into a language or tool, then you get a pack-rat mess that is abused by bored newbies.

      But if you do it carefully, you get a language like C++, which as well as being abused by newbies, is used by strong programmers to build many of the most powerful systems on the planet in any major field.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    3. Re:OK, so why not mix and match? by Tablizer · · Score: 1

      (* So, not only can you not show me any evidence, you now tell me that your position is based only on selective parts of the evidence you do have? That's not very scientific! *)

      Like I said earlier, it is only meant to be slightly better evidence than your personal anecdote. IOW, I am fighting matches with matches. (That is all there is in comparative paradigm science.) I am not sure though what you mean by "selective". Yourdon (allegedly) surveys companies about their IT progress and tools. His surveys showed an initial hump in OO kudos, but it dropped off to at or slightly below average. His speculation is that it may be enthusiasm or mind-fit that makes a difference. As OO becomes mainstream, the personal factors like that get lost. It suggests that the way to go may be Zealot Oriented Programming.

      (* The interfaces concerned are completely generic as far as the table's contents go. *)

      So is SQL and ODBC. If you want to reinvent the collection interface wheel, then go ahead. (SQL does have flaws IMO, but I am not sure they are strong enuf to justify an overthrow.)

      (* My feeling, based on several years of OO use in development, is that it is a rarely justified feature, but working around its absence when you want it is nasty. *)

      But does that make up for the time that MI is mis-used to make horrible messes? It seems a close weigh-in.

      (* Java shines in its simplicity. *)

      Maybe syntax-wise, but it's API's suck eggs IMO. I seem to be spoiled by VB components. They were relatively easy to figure out and use. I won't vouch for their quality and reliability, but as interfaces go they generally provided much more instant gratification and instant grokability than Java's API's. Some say that Java API's assume a life-long commitment to see their benefits. However, the industry changes too fast (often for no reason) to marry one language. Perhaps it is Sun's way to vendor lock-in.

      (* But if you do it carefully, you get a language like C++, which as well as being abused by newbies, is used by strong programmers to build many of the most powerful systems on the planet in any major field. *)

      IMO the C family is meant to be more machine-friendly than programmer-friendly. It's commonality may be due to the machine factor, not software-engineering factors.

    4. Re:OK, so why not mix and match? by Anonymous+Brave+Guy · · Score: 2
      If you want to reinvent the collection interface wheel, then go ahead. (SQL does have flaws IMO, but I am not sure they are strong enuf to justify an overthrow.)

      We didn't have to reinvent anything; we already had generalised classes up to the job. OTOH, using a full-scale solution with ODBC and/or SQL would have been totally unacceptable because of the performance hit. These capabilities aren't checked a couple of times a second, they're checked a couple of thousand. In the time it takes to set up an API call to ODBC, we've already processed dozens of requests.

      (* Java shines in its simplicity. *)

      Maybe syntax-wise, but it's API's suck eggs IMO.

      No argument there; many were added far too hastily, and the need to understand half the known universe before writing your first line of Java GUI code is a major barrier to entry for the language.

      IMO the C family is meant to be more machine-friendly than programmer-friendly. It's commonality may be due to the machine factor, not software-engineering factors.

      On the contrary, C++ is designed very much with the programmer in mind. The problem is, as ever, due to bad management somehow feeling that a background in C qualified its programmer to use C++ without further training. As a result, you have numerous examples of bad OO design, total failure to understand generic programming, and low level features used far too high up the code in many projects. That's not C++'s fault; it was always advertised as a tool for the programmer who was prepared to program properly, and to that programmer, most of the usual criticisms are irrelevant. He can hide all the problems away with low level encapsulation, and effectively write in his own custom-designed high-level language thereafter.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    5. Re:OK, so why not mix and match? by Tablizer · · Score: 1

      (* ....would have been totally unacceptable because of the performance hit. *)

      Perhaps those tools/protocols are optimized for business applications. I don't know what a good collection engine optimized for engineering applications would need.

      (* and the need to understand half the known universe before writing your first line of Java GUI code is a major barrier to entry for the language. *)

      I call this phenomena "protocol coupling". To grok protocol A, you have to grok protocol B, and to grok B, you need to grok C, etc. Hiding implementation is not sufficient. You also have to work on hiding certain nitty protocol issues also if you want a programmer-friendly system.

      (* On the contrary, C++ is designed very much with the programmer in mind. *)

      Which programmer?

      (* That's not C++'s fault; it was always advertised as a tool for the programmer who was prepared to program properly, and to that programmer, most of the usual criticisms are irrelevant. He can hide all the problems away with low level encapsulation, and effectively write in his own custom-designed high-level language thereafter. *)

      Perhaps a different language should be used for the high-level stuff versus the low-level stuff. It might take a different mindset and personality for good low-level code and good high-level code. Some like to focus on the ultimate goal, and some like talking to hardware and bits. Although such approach may not work in a small shop, larger shops may want to consider such division of specialties.

      Similarly, the language and skills needed to *make* a database engine and to *make* a GUI engine are likely not the same as those needed to use those tools when building a custom biz application.

    6. Re:OK, so why not mix and match? by Anonymous+Brave+Guy · · Score: 2
      (* On the contrary, C++ is designed very much with the programmer in mind. *)

      Which programmer?

      Real ones, who appreciate that getting good results requires skill in using your tools. (Compare and contrast McProgrammers, who think it's clever to connect a couple of McComponents using their McRAD environment.) There's nothing wrong with high level languages or RAD tools, quite the contrary. But a language like C++ lets people who love to code get very, very good results. No high level language or RAD tool I've ever seen could rival it for potential.

      Perhaps a different language should be used for the high-level stuff versus the low-level stuff. It might take a different mindset and personality for good low-level code and good high-level code.

      Possibly. Of course, if you use the same language to do both, as you can do with C++, you get all the usual benefits of sticking to a single, mainstream tool. People don't need to have two sets of skills running through their head as they program, you don't have any interoperability problems, and there's no tough decision to make about which language a particular part of the application should be written in. My experience of combining multiple languages has not impressed me.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    7. Re:OK, so why not mix and match? by Tablizer · · Score: 1

      You know, I could replace "C++" with "Smalltalk", and you would sound like just a Smalltalk fan. Or "Perl" fan, Or Python........etc.

      Their argument is often that they finish faster because their language is more expressive (says more per line), and thus have more time left over to spend on speed optimization at the bottleneck points.

      IOW, you sound like Yet Another lang/tool/paradigm Zealot. That is okay, because I am one too.

  320. Concrete example by Anonymous+Brave+Guy · · Score: 2

    OK, let's look at a concrete example. Suppose I have a model where I need to know some value that is identified by a location in space. I want to establish that value by taking the input co-ordinates and applying various transforms on them to get a new position. I then use a "master function" of some sort to calculate an output value. I may then also want to apply further variations to that, before returning the final value to the caller.

    In the decorator pattern, I model this using an interface that takes the co-ordinates as parameters and returns a value. I then provide three classes implementing that interface, one of which does co-ordinate transforms, one of which represents a "master function", and one of which represents the further variations on the value. I also add a second part to the first and last cases, allowing me to chain them on to any other object implementing the main calculation interface, so I can use the decorator pattern. The individual calculation effects are now derived from one of the three specific types, and any data necessary to perform the calculation can be introduced on a case-by-case basis. The result is a simple class hierarchy representing the various transformations to be applied on a one transformation, one class basis, and with any extra data required to define a particular transformation wrapped up with the transformation algorithm in its class.

    I can now build a chain of the co-ordinate transforms and variations, ending with a master function to do the main calculation. The only place that knows or cares how to combine the effects is the place that sets up the chain in the first place. There is no connection at all between the three different types of calculation (other than implementing that main interface) and they can be freely interchanged. New calculation classes can be added without any impact on existing code, and just slotted into the chain creation process.

    The nearest procedural equivalent without jumping through hoops is to have a list of functions, and to provide both some function to set up the list (which is directly equivalent to setting up the chain in the decorator case), and another master evaluation function to iterate through the functions, calling them in the right order. Life gets more complicated when you then have to provide arbitrarily varying parameters to the different functions, of course. A suitable mechanism for this is not trivial.

    OK, that's my problem. It's a real example, the major part of a key subsystem in our current application. The above is the OO model I used to model it, using the decorator pattern. I claim that this use of decorator is a good example, and has proved its worth in a real program. I invite you to suggest a plain procedural and/or relational/table-based solution that is as elegant and adaptable in the face of arbitrary change. I also invite you to point out any weaknesses in the decorator model that make it susceptible to changes in requirements.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    1. Re:Concrete example by Tablizer · · Score: 1

      What about this setup:

      Table: Functions
      --------------------
      FunctionID..... // autogen
      Function..... // name, reference, or code
      FuncDescr.... // description of function
      Ordering.....

      Table: Params
      -----------------
      FunctionRef..... // foreign key to Functions table
      ParamName..... // name or position of parameter
      ParamValue.....

      (Other specific fields may be needed for your particular usage, such as group, maintainer, etc.)

      If you had *thousands* of these, would you rather manage then in code or in tables? I cannot imagine managing such in code. With tables you can sort, search, filter, cross-reference, etc. just about any way that any particular app management task or inspection need warrants. If your language makes tables hard to use, that is the fault of the language, not the table paradigm.

      Plus, you can have non-programmers manage much of them. Make a quicky app interface for them in Access, your fav OSS equiv, or whatever.

    2. Re:Concrete example by Anonymous+Brave+Guy · · Score: 2

      OK, that set-up's fair enough as a starting point. Just a few questions come to mind immediately, though.

      First of all, where's the type- or error-checking on the function parameters configured when the list/table is initially set up? You seem to have missed out any kind of constraints on this, leaving the parameters required for each function totally unrestricted in both type and number.

      Secondly, what's the performance like? This process is going to run many times a second, so how efficient is the look-up of, say, parameters that were fixed earlier, each time a function needs them? Based purely on the nature of your model's indirection, and being generous in allowing an optimally efficient cache once results have been looked up once, I still don't see how it can be even close to the decorator version; your whole data structure's wrongly organised for fast look-up in the context given.

      If you had *thousands* of these, would you rather manage then in code or in tables?

      I don't have a problem doing that with code. Each goes in a separate class. The name of the actual calculation function is standard, and any configurable information is readily available in the same place. The classes can be grouped both physically and logically in any way that seems appropriate. Using any of the IDEs available to me, the same sorts of searching and navigation tools are available that you describe for the table version.

      On the other hand, your table-driven approach seems to be the one that does not scale well. The cost of a look-up in your parameters table is going to increase the more parameters and/or functions there are in the model, while in the decorator model using OO it is a constant (and almost non-existent) overhead.

      Plus, you can have non-programmers manage much of them. Make a quicky app interface for them in Access, your fav OSS equiv, or whatever.

      Erm... right. Given that your "function description" field must contain the same logic as the calculation function in my OO model, you need the same level of programming expertise in either case. Given that you allow for a "quicky app interface" to help, I'm going to allow for a quicky wizard to auto-generate the class files with just placeholders left to be filled in. And now I have the same advantages as you again, and again it's cost me no more.

      And finally, while I did not specifically require it in my original specification, your model seems to make no provision for the three different types of calculation to be performed. If there were a significant amount of work to be done in, say the co-ordinate transforms case but not the others, I can just change the base class to provide for that. If I need to add another stage, or to enforce the fact that first stage functions must be followed by second stage functions always, I can easily change my code to do that in a robust way. You have no way to introduce common functionality or enforce constraints on the order of calling without either changing your model or adjusting every function description, as far as I can see.

      In summary, while I see where you're coming from with the table model, it seems to have gained nothing over the OO model. At the same time, you have lost a significant amount of the robustness of the latter, and probably created a dramatic reduction in performance because of all the indirections needed every time the code is run. Did I miss anything? :-)

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    3. Re:Concrete example by Tablizer · · Score: 1

      (* First of all, where's the type- or error-checking on the function parameters configured when the list/table is initially set up? *)

      I don't know enough about your requirements to really answer that. I would note that I tend to gravitate toward dynamic typing (or non-typed) solutions. I would more likely gravitate toward Smalltalk than say Eiffel if forced into OOP (and market for each being equal). You may have to find a strong-type-loving T.O.P. fan to get a better answer. However.....

      (* Secondly, what's the performance like? This process is going to run many times a second, so how efficient is the look-up of, say, parameters that were fixed earlier, each time a function needs them? *)

      If efficiency is needed, then perhaps use the tables to *generate* the final static code needed. The tables then becomes a code management system more than the final product used by the machine. It might also get you your type-checking (above). I won't claim that TOP is faster than OOP, since I have not done the research.

      (* [If you had *thousands* of these, would you rather manage then in code or in tables?]
      I don't have a problem doing that with code. Each goes in a separate class. *)

      But "class" is only one of many possible indexes or search criteria. It would be like only being allowed to lookup employees by last name.

      (* The classes can be grouped both physically and logically in any way that seems appropriate. Using any of the IDEs available to me, the same sorts of searching and navigation tools are available that you describe for the table version. *)

      True, but then your IDE is reinventing table/collection operations. Why not consolidate table and data browsers? I see no reason why they have to be different. Such a discontinuity can be problematic. Plus, info in tables can be read by other languages. It is not tied to any one IDE nor language (except where you put actual code in tables).

      Further, the (alleged) power of your management of the code is in the IDE and not OOP.

      (* Erm... right. Given that your "function description" field must contain the same logic as .... *)

      The Function Description field was only meant to be a title or comment in my setup.

      (* I'm going to allow for a quicky wizard to auto-generate the class files with just placeholders left to be filled in. *)

      Sounds like our solutions are starting to converge.

      (* And finally, while I did not specifically require it in my original specification, your model seems to make no provision for the three different types of calculation to be performed. If there were a significant amount of work to be done in, say the co-ordinate transforms case but not the others, I can just change the base class to provide for that..... *)

      You can use any criteria you want for the lookup and filtering of functions. Just add the columns that contain the grouping info or flags you want, and use something akin to an SQL "Where" clause to select what you need and only what you need for any given run/operation. Set-based selection is more general-purpose than tree-based selection (because graphs are more general-purpose than trees.)

      As far as having variable orderings (execution sequence) of the functions, I would have to see the specifics. You can have multiple Ordering columns, and some criteria to select which ordering column you want. The sky is the limit. And, you don't have to re-arrange the organization of your code (refactoring) to get different views: just change a relational and/or Boolean formula. That decouples the structure of your code from the particular relationships and criteria that you happen to be using. I don't know about your domain, but in mine such non-intrusiveness of relationship changes is nice to have.

      (* At the same time, you have lost a significant amount of the robustness of the latter *)

      By "robustness", do you mean error checking? That depends whether you use the run-time approach or the code-generation approach.

      I am not sure how such a "contraption" would go over in the engineering community. My limited encounters with physical engineers suggests that they are somewhat aversive to tables and databases. Perhaps for speed needs, or culture. I don't know.

    4. Re:Concrete example by Anonymous+Brave+Guy · · Score: 2
      I would note that I tend to gravitate toward dynamic typing (or non-typed) solutions.

      That's a significant drawback if you're working with others in this sort of field. Strong typing is widely regarded as a positive feature for a reason.

      (* [If you had *thousands* of these, would you rather manage then in code or in tables?]

      I don't have a problem doing that with code. Each goes in a separate class. *)

      But "class" is only one of many possible indexes or search criteria. It would be like only being allowed to lookup employees by last name.

      No, it's like pointing out that all of your database tables are ultimately stuck in a linear sequence of bits on mass storage. It's the functionality you build on them that makes it clever. And so it is with OO.

      True, but then your IDE is reinventing table/collection operations. Why not consolidate table and data browsers? I see no reason why they have to be different. Such a discontinuity can be problematic.

      Or your IDE is just modelling the same basic features of searching in a different way, depending on your point of view. I fail to see the problems you are alluding to.

      Further, the (alleged) power of your management of the code is in the IDE and not OOP.

      Not at all. The IDE is providing features for examining the code, and I have them just as readily as you do in your table-based environment. Managing the code, in the sense of modifying it to achieve a new result, is an entirely different matter, and I still feel that OO makes this significantly easier than a procedural approach under the right circumstances.

      I'll stop there. I think the point has been made. As far as I can see, you have offered no liabilities in my concrete example. Your own solution, using table-driven methods, has shown no benefits in terms of ability to meet requirements or in terms of organisation of the code, even in your suggested case of 1000+ calculations. However, the table-driven solution is essentially tied to a particular kind of data structure, and as such, the performance is going to be crippled compared to the OO approach.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    5. Re:Concrete example by Tablizer · · Score: 1

      (* That's a significant drawback if you're working with others in this sort of field. Strong typing is widely regarded as a positive feature for a reason. *)

      The strong vs. dynamic (or non-typing) debate rages on for months at a time among even OO fans. I won't take it up here. Smalltalkers have more energy for that sort of debate.

      (* No, it's like pointing out that all of your database tables are ultimately stuck in a linear sequence of bits *)

      Much of the time I don't even know *how* it is internally stored. That issues is more and more abstracted away from the app developer, as it should be.

      (* and I still feel that OO makes this significantly easier than a procedural approach under the right circumstances. *)

      Speed aside, you have not shown that. And, I still beleive in the data and code management convergence principle. They tend to morph into each other in practice. I can use the same principles on data as on controlling info, even code.

      (* Your own solution, using table-driven methods, has shown no benefits in terms of ability to meet requirements or in terms of organisation of the code *)

      You have *not* shown it inferior from a human interaction point of view. Plus, it does not rely on a fancy IDE. Multiple langs can access the same table.

      If you are bound that close to hardware speed, then perhaps you have less choices than I do. I thank my lucky tables that my choices are not that tightly married to the silicone. Code is okay for representing algorithms, but as a bulk item management tool I find it lacking, at least to my neurons (and the other table fans I get email from). Database systems have already learned the lessons of mass organization for me.

      And, you did not really evaluate the code-generation options WRT speed.

      (* However, the table-driven solution is essentially tied to a particular kind of data structure *)

      Like I said before, tabling is about using a consistent interface to collections of ANYTHING. The bits are rarely seen in their native form.

  321. Layers! by 4of12 · · Score: 2

    My experience with scientific programming has been that while it is quite possible to code in a procedural language (I've done F77 and C), it will eventually start to give out.

    That is, there's no question that the inner core algorithms are nicely written in FORTRAN or C or assembler if you please, and these are probably best written in those languages.

    It's all the other overlying code that starts to get really ponderous in a procedural language. Things like parsers and managing I/O.

    If your underlying code is useful, then you'll inevitably want one more feature to make it easier to use in a slightly different way. This happens constantly. In the end, managing that complexity is more convenient using an OO language.

    My own inclination (having wallowed in C++ syntax for a few years) would be to follow an approach like having efficient numerical algorithms in FORTRAN or C and a higher level code in Python, using things like SWIG to connect them together.

    Don't dismiss OO programming because of the history of over hype. It really does offer something. It can be misused. But if you take as much care with it as you do with your procedural programming you'll appreciate the dividends it returns.

    --
    "Provided by the management for your protection."