Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Common C++ Architecture [closed]

I've been programming C++ and Java for quite a while now and have some questions about common C++ architecure.

When I program in Java I try to mimic the standard library, that is using interfaces such as Iterable and Serializable and having similar naming conventions and functionality. With C++ however, I hesitate when trying to mimic the STL conventions (with the exception of iterators).

I've boiled it down to the following questions (are the following common convention to implement):

  • Allocators
  • Interfaces (classes with only pure virtual methods)
  • Templates instead of abstract base classes
  • Restricting exception throwing...
  • ... or having a class optionally throw exceptions (such as in std streams)
  • Using typedefs for, more or less, obvious types (reference_type, pointer_type, value_type, ...)

Or is the std of C++ not worth mimicing at all?

Thank you for your opinions / answeres!

like image 652
Jens Åkerblom Avatar asked Mar 07 '12 14:03

Jens Åkerblom


Video Answer


1 Answers

The more I've used C++, the less fond I am of mimicking the best of libraries I find. The problem comes in when we get a junior developer on the team. They'll understand the basics, but not the subtleties of the language. They may know how to create a map or list using the template syntax, but be unable to understand it when it's applied to another object. The added complexities of debugging and doing code read-throughs also take valuable time away from solving problems or advancing your product.

I have grown to lean towards using the most basic features of the language, which typically leaves the code in a more naturally readable state. I've regretted deviations from this path when I go back 8-12 months later to hunt down an obscure bug with the code.

Java, on the other hand, has more simplistic library implementations that is very well understood by more junior Java developers. I do find that junior Java developers tend to have a greater understanding of the language then junior C++ developers. The being said, C++ developers have more opportunity to become truly competent owing to the lower level of thought needed to become an intermediate C++ programmer.

like image 89
Kieveli Avatar answered Oct 26 '22 23:10

Kieveli