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 3491340
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:37:30+00:00 2026-05-18T11:37:30+00:00

I have several modules (mainly C) that need to be redesigned (using C++). Currently,

  • 0

I have several modules (mainly C) that need to be redesigned (using C++). Currently, the main problems are:

  • many parts of the application rely on the functions of the module
  • some parts of the application might want to overrule the behavior of the module

I was thinking about the following approach:

  • redesign the module so that it has a clear modern class structure (using interfaces, inheritence, STL containers, …)
  • writing a global module interface class that can be used to access any functionality of the module
  • writing an implementation of this interface that simply maps the interface methods to the correct methods of the correct class in the interface

Other modules in the application that currently directly use the C functions of the module, should be passed [an implementation of] this interface. That way, if the application wants to alter the behavior of one of the functions of the module, it simply inherits from this default implementation and overrules any function that it wants.

An example:

  • Suppose I completely redesign my module so that I have classes like: Book, Page, Cover, Author, … All these classes have lots of different methods.
  • I make a global interface, called ILibraryAccessor, with lots of pure virtual methods
  • I make a default implementation, called DefaultLibraryAccessor, than simply forwards all methods to the correct method of the correct class, e.g.
    • DefaultLibraryAccessor::printBook(book) calls book->print()
    • DefaultLibraryAccessor::getPage(book,10) calls book->getPage(10)
    • DefaultLibraryAccessor::printPage(page) calls page->print()
  • Suppose my application has 3 kinds of windows
    • The first one allows all functionality and as an application I want to allow that
    • The second one also allows all functionality (internally), but from the application I want to prevent printing separate pages
    • The third one also allows all functionality (internally), but from the application I want to prevent printing certain kinds of books
  • When constructing the window, the application passes an implementation of ILibraryAccessor to the window
    • The first window will get the DefaultLibraryAccessor, allowing everything
    • I will pass a special MyLibraryAccessor to the second window, and in MyLibraryAccessor, I will overrule the printPage method and let it fail
    • I will pass a special AnotherLibraryAccessor to the third window, and in AnotherLibraryAccessor, I will overrule the printBook method and check the type of book before I will call book->print().

The advantage of this approach is that, as shown in the example, an application can overrule any method it wants to overrule. The disadvantage is that I get a rather big interface, and the class-structure is completely lost for all modules that wants to access this other module.

Good idea or not?

  • 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-18T11:37:31+00:00Added an answer on May 18, 2026 at 11:37 am

    The only thing I’d worry about is a loss of granularity, partly addressed by suszterpatt previously. Your implementations might end up being rather heavyweight and inflexible. If you’re sure that you can predict the future use of the module at this point then the design is probably ok.

    It occurs to me that you might want to keep the interface fine-grained, but find some way of injecting this kind of display-specific behaviour rather than trying to incorporate it at top level.

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

Sidebar

Related Questions

I have a Python program that consists of several modules. The main module creates
I have a project with several modules. When all tests pass, Maven test runs
I have several live Drupal sites running on an Ubuntu server (10.04), Apache 2.2
At work we have several Solaris servers. Each server runs apache which we compiled
I'm working For my company on a .NET N-tier architecture and have several questions.
I have successfully created my first django project. I have two apps in my
Let's say you are building a multilingual web application in which all interface text
I've just started using java.nio and probably used it some wrong way so I
I want to deliver a single .jar file to my clients, but my project

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.