dimanche 28 avril 2019

Huge structured data classes

Good evening,

I am writing an application, which has to handle a relatively big set of structured data. My current approach is to write classes for different abstract components of the data structure and have it all connected via member instances, similar like this:

class A {
  class B {
    class D {
      /* definition of class D */
      public:
        int some_menthod();
    };

    public:
      D d;

    /* definition of class B */
  };
  class C {
    /* definition of class C */
  };
public:
  B b;
  C c;

};

Now my question is, if this is considered bad design, if there are too many nested layers. Also, would you just access some_method by traversing the class hierarchy like this:

A a;
a.b.d.some_method();

or would you write "cover functions" in class A, that access methods in the lower levels? With these cover functions, you would have to touch less code, if some of the structure changes, but on the other hand, those cover functions do not really belong to class A.

What is your opinion on this matter?

Aucun commentaire:

Enregistrer un commentaire