CodeBlanks Logo Icon CodeBlanks

Project design

Design the skeleton of the advanced final mini app.

Project: Mini framework

In this 5-lesson project you will build a layered mini framework. Each lesson adds one layer, and by the final lesson you will have an integrated application.

The layers are: Project skeleton (Framework class), Modern C++ (data processing with concepts + ranges), Concurrency (parallel sum with std::thread + atomic), Design patterns (Singleton Logger + Factory) and Putting it together. Each lesson's starting code will contain the previous lesson's solution. This way the code accumulates across lessons.

Framework class skeleton

First we define a Framework class. This class is the scaffold on which all layers stand. The run method is the entry point of the application.

Example: class Framework { public: int run(); };. In main you start it with Framework fw; fw.run();. The run method prints std::cout << "Project ready"; to confirm the skeleton works. In the next lessons we will add new methods on top of this skeleton, and each lesson's starting code will contain the previous lesson's solution.

Practice Define the Framework skeleton

Define the Framework class: in the public section declare int run();. The Framework::run body should print std::cout << "Project ready";. In main call it with Framework fw; fw.run();.

Starter code

main.cpp
#include <iostream>
#include <string>

// Define the Framework class with a run method

int main() {
    // Create a Framework and call run
    return 0;
}

Sample solution

main.cpp
#include <iostream>
#include <string>

class Framework {
public:
    int run();
};

int Framework::run() {
    std::cout << "Project ready";
    return 0;
}

int main() {
    Framework fw;
    fw.run();
    return 0;
}

Expected output

Project ready

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Why is the mini framework designed in layers?

  • To write everything in a single function
  • To write less code
  • So each layer has a single responsibility and change is isolated Correct answer
  • To speed up the compiler

Explanation: Layered design gives single responsibility and isolated change.

2 Complete the class name

Question
class ____ { public: int run(); };
Answer
class Framework { public: int run(); };

Explanation: Class names use PascalCase: Framework.

3 Match each piece to its role

Term Meaning
class Framework Scaffold class
run() Entry point
main() Program start
std::cout Output

All lessons in Advanced