Note that there are some explanatory texts on larger screens.

plurals
  1. USstinky472
    primarykey
    data
    text
    <p>Hi all, I'm a professional C++ developer. I work on a commercial 3D animation package. I also like to code in Python and Lua which we've used in various projects in combination with C++.</p> <p>My original passion before I started working on commercial projects was in studying a wide variety of computer languages (everything from Prolog to LISP to Java) and trying to really get used to idiomatic ways to use the languages. I don't believe in the idea that a generic software engineer can just use any language without taking a great deal of time to study idiomatic use of that particular language. Otherwise we often find lowest common denominator designs which are devoid of all the expressiveness and power of that particular language.</p> <p>I think the bane of all designs in any language is monolithism, whether it's in the form of monolithic hierarchies, classes, or any kind of public interface. Some of the developers I've worked with just have a habit of creating those kinds of designs which tend to grow and grow and grow with no end in sight, accumulating more and more data and functionality while at the same time becoming more restrictive, inefficient, and unsafe rather than more complete, efficient, and safe. Often the best designs come from reductions rather than additions.</p> <p>I like to give indirect answers to questions sometimes. It seems the indirectness might actually more directly help those asking. If someone is having trouble with recursion, for example, I'd recommend they learn a debugger first and foremost.</p> <p>C++ is such a difficult language with so many concepts to learn: everything from RAII to dealing with a mix of value and reference semantics, various memory models to choose from, generic algorithms and iterators, etc. Yet I still think it's a very powerful language since it's one of the few that can allow us to get very abstract without making big sacrifices (if any) in efficiency.</p>
    plurals
    1. This table or related slice is empty.
    1. CO@Alex nice work! That is kind of the route I was suggesting, but I added a extra container kind of class so that the client doesn't have to write new MyCallback(...). You can make a wrapper which stores the base pointer with a constructor template that will instantiate the appropriate callback subclass (MyCallback in this case) and store it in the base pointer based on the arguments passed to the ctor template. It's a little wrapper to kind of hide away the memory management and template stuff, but may not be necessary for your case. It's basically how boost::function works.
      singulars
    2. COSo let's say you define a virtual function like update_geometry for animation purposes in the GeometryInterface. You can override it in Model which inherits that interface. You also override a method to return GeometryInterface* from Model. Thus when clients traverse the scene graph, they can write code like Geometry* geometry = scene_node->geometry(); if (geometry) geometry->update_geometry();
      singulars
    3. COThe Geometry class can provide methods like creating triangles, the Texture can provide methods to access the image data, etc. Basically you just pick and choose among these interfaces when you create a SceneNode like Model, and you override the necessary functions so that clients using the Model node can get a texture interface out of it, a geometry interface, etc. As YeenFei pointed out, it's pretty much just like COM but with slightly different conventions and I omitted reference counting from this example.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload