vendredi 27 mars 2015

Aggregating-based architecture issues

i'm need your help again.


I have an document viewer application what can read two different kinds of documents:



  1. Special one (based on PDF, with custom header)

  2. Standart one ("raw" PDF).


With raw PDF viewer should acts like any other one.

With custom - execute some additional actions during it's opening,

which are not available to raw PDF.

These actions should be available later in the application's menu only. And only for custom document.



Project OOP architecture (designed by other man) looks like this:



class GenericDocument
class PdfLibDocument
class CustomDocumentHighLevel
class CustomDocumentLowLevel


I.e.



class GenericDocument
{
SmartPointer< PdfLibDocument > m_document;
...
};


and so on.


Custom document has much specific functionaly:



class CustomDocumentLowLevel
{
public:
void DoSomeBlackMagic();
...
// Another black magic
};


The problem occurs then i need to "pull" some low-level method from CustomDocumentLowLevel to GenericDocument (to show in app menu) - because i need to add this method to ALL FOUR classes!

And probably in the future i need to "pull" more methods from custom document.

Looks like this software architecture is bad choice in such case, isn't it?


So i need find a way to refactor this code. Should i replace aggregating with inheritance? Introduce interfaces?


Aucun commentaire:

Enregistrer un commentaire