Tag Archives: solid

An Interface Segregation Principle (ISP) example

#include <iostream>
#include <memory>
#include <string>
#include <vector>

struct IObject {
    virtual ~IObject() = default;

    /// Returns the name of the object.
    virtual std::string getName() const = 0;

    /// Prints a textual description of the object.
    virtual void describe() const = 0;

    /// Eats another object.
    virtual bool eat(IObject* other) = 0;
};
(more…)

An investigation of why dynamic_cast violates LSP

Signal sender cast in QT

QT implies that the client code will do qobject_cast that is actually dynamic_cast:

awl::ProcessTask<void> MarketModel::coPlaceOrder(OrderPtr p)
{
    // Update SQLite databse...
    // ...
    // QT signals are used in both C++ and QML.
    // They works with QObject*, and they are not aware of concrete types.
    QObject::connect(p.get(), &OrderModel::statusChanged, this, &MarketModel::onOrderStatusChanged);
}
(more…)