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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:19:48+00:00 2026-05-27T13:19:48+00:00

I am trying to setup Agile and TDD environment for MFC applications that require

  • 0

I am trying to setup Agile and TDD environment for MFC applications that require high performance.

Since MFC View/Document are not testable, I am going to make them as dumb as possible and to test the other classes with Boost Test framework. – Please let me know if you know better way or better test framework for this environment.

In order to make TDD work, I think having dependency injection is crucial for loosely coupled structure. How can I achieve this? Any reference or hint will be appreciated.

  • 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-27T13:19:49+00:00Added an answer on May 27, 2026 at 1:19 pm

    Use shared_ptr’s to interfaces representing your classes.

    I am thinking something like

    #ifndef CLOCK_HPP_INCLUDED
    #define CLOCK_HPP_INCLUDED
    
    #include <boost/shared_ptr.hpp>
    
    
    class Clock
    {
    public:
       static boost::shared_ptr<Clock> create();
       virtual void init() = 0;
       virtual double getSeconds() = 0;
       virtual void sleepUntilNext(double howMuch) = 0;
    
    protected:  // No polymorphic deconstruction because of shared_ptr
       ~Clock()
       {}
    
    
    };
    
    #endif
    

    Then you could just take the clock implementation in your constructor, or have another method to set the implementation, like setClock or something.

    Example of this would be

    #include "clock.hpp"
    class MyClass
    {
    public: 
       myClass(boost::shared_ptr<Clock> aClock) : myClock(aClock)
       {
           myClock.init();
       }
    
    private:
       boost::shared_ptr<Clock> myClock;
    }  
    

    Then in your unit testing you could do something like this:

    boost::shared_ptr<Clock> mock = createMockClock();
    MyClass b(mock);
    
    mock.assertThatInitIsCalled();
    

    You can also just ignore resources. The shared_ptr’s will delete themselves.

    The cost to this would be a little performance loss due to dynamic allocation, virtual function calls, and the overhead of shared_ptr.

    The benefits would be increased modularity, lowered compile time, easier use of mocking frameworks like googlemock(they require interfaces anyways), and easier resource management(you will never have a null pointer).

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

Sidebar

Related Questions

After trying to setup my site for Google Webmaster Tools I found that my
I'm trying setup a map that displays different pin colors depending on the type/class
I'm trying to setup a loop in Wordpress that will show all posts from
I am trying to setup drupal to host multiple sites which will not effect
I'm trying to setup a Python application that should automatically start when Linux boots.
Trying to setup a SQL stored procedure that if the variable passed to it
Trying to setup a Cron task that gets a file via FTP however seems
Im trying to setup a simple environment: class Member < ActiveRecord::Base has_many :microposts, :dependent
I am trying to setup an activity in Android that has 50% of the
I'm trying to setup a django app that allows me to store and lookup

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.