Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
S

Sogar Gofin

@Sogar Gofin
About
Posts
1
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Code Neatness
    S Sogar Gofin

    I've been perpetually seeking the "cleanest" way to code. Here are my thoughts: In C, one doesn't need to consider subtle features like constructor/destructor behavior, operator overloading, inheritance, generic programming, C++ exceptions, and the like. In C++, these possibilities may associate extra functionality (e.g resource aquisition is initialization, RAII) with the declaration of an object, and also with the departure from the object's scope. Say you declare an object variable inside a function or method whose usage is sometimes skipped over. Say also that the object's constructors are designed to acquire some system resource (e.g. a lock, not uncommon in multi-threading ). If you've declared the object at the top of your routine, you'd be unnecessarily acquiring that resource (e.g if the shared data the lock protects isn't referenced ). This can manifest as unnecessary delay or resource starvation. This justifies declaring some object-types close to their usage. As for basic types: since it's already justified for some objects, you may as well do it with basic types to keep standards consistent and code modular. This also makes it easier to break a big routine into sub-routines. Not to mention, you never know if a future code refactor may turn a basic type into an object. As I've experienced, you may need to change your doubles into special fixed-point objects to run better on particular machines ... like the UltraSPARC T1000 ... C++ is subtle. IMO, the compiler ought to be explicit about how much of this it automatically handles. See: http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization[^] - Charles Rojo Software Engineer

    Rojo

    modified on Monday, March 10, 2008 11:42 PM

    The Lounge c++ question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups