Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5979869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:43:14+00:00 2026-05-22T21:43:14+00:00

I grew up learning to set up data structures using OOP. But now as

  • 0

I “grew up” learning to set up data structures using OOP. But now as I learn more about C++, STL, and Boost, I find that many of my data structure needs can be met by combining STL classes into more complex composites like:

typedef std::map<std::string, std::map<std::string, int> > CSVData;

Obviously there are limits to this when I need to mix data types, but generally I find myself avoiding OOP when I can in favor of these STL composites for their simplicity. Is this a common progression? Are there best-practice rules-of-thumb for when it’s better to define your own class? Are there common pitfalls to this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:43:15+00:00Added an answer on May 22, 2026 at 9:43 pm

    If this is for some one-off code: sure, use typedefs, why not?

    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.

    Code should be easy to use, and hard to misuse. Among other things this means: have one 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.

    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.

    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.

    This is one of the most important concepts of large architectures: information hiding.

    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 implemented in terms of a map of maps. This is a fundamental difference.

    That said, C++ does teach that object orientation isn’t needed for large object hierarchies: essentially the whole standard library (except for the IO stream library) isn’t object oriented: it’s algorithm oriented instead. But that doesn’t mean that you don’t have to write your own classes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since I have started learning about rendering to a texture I grew to understand
Don't need to do this right now but thinking about the future... What would
While I grew up using MSWindows, I transitioned to my much-loved Mac years ago.
I'm currently typing about 90 wpm (from http://speedtest.10-fast-fingers.com/ 90 correct 0 missed) using two
My ibdata1 file for MySQL database grew to about 32GB over time. Recently I
When learning C# for the first time, I was astonished that they had no
This question grew out of SQLServer: Why avoid Table-Valued User Defined Functions? . I
The last few months my application grew bigger and bigger. It's runnable as Wpf
I think I divide it because css grew big, and to do import. @import
I am developing a small application using EF 4.0 and POCO. While testing my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.