Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If this is for some one-off code: sure, use typedefs, why not?</p> <p>But code rarely is. And the problem with reusable code (or code that will, potentially, at some future point be reused) is: there are 1000 different ways of using it wrongly. Don’t artificially add reasons 1001–1255.</p> <p><strong>Code should be easy to use, and hard to misuse.</strong> Among other things this means: have <em>one</em> obvious interface and forbid all operations that aren’t supported, meaningful, or that are somehow unnecessary. Providing a typedef fails in this regard: your CSV data type supports all kinds of irrelevant operations.</p> <p>There are multiple other reasons against typedefs: for instance, this makes the interface easy to break when you need to change the underlying implementation of your data structure (change of requirements, performance issues …). Essentially, you cannot do that without breaking all uses of your typedef’d data structure.</p> <p>But a properly designed, well encapsulated data structure can easily change its internal implementation without breaking consumer code, as long as the interface remains identical.</p> <p>This is one of the most important concepts of large architectures: <em>information hiding</em>.</p> <p>Furthermore, it is a logical error (albeit a small one): your typedef models a logical is-a relation. But this isn’t true: CSV data isn’t a map of maps. Rather, it can be <em>implemented in terms of</em> a map of maps. This is a fundamental difference.</p> <p>That said, C++ <em>does</em> teach that object orientation isn’t needed for large object hierarchies: essentially the whole standard library (except for the IO stream library) <em>isn’t</em> object oriented: it’s <em>algorithm oriented</em> instead. But that doesn’t mean that you don’t have to write your own classes.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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