Project

General

Profile

Actions

Feature #2818

closed

[DBO] Provide the advertised "DRY" concept.

Added by I. Lazaridis about 10 years ago. Updated about 10 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
Target version:
-
Start date:
03/14/2014
Due date:
% Done:

0%

Estimated time:

Description

DBO is advertised as "DRY":

Uses a templated visitor pattern which requires a single template method to provide the mapping: DRY and as efficient as conceivable!

http://www.webtoolkit.eu/wt/features

but in the examples code, one can found exessive repetition:

class User {
public:

    std::string name;
    std::string password;
    Role        role;
    int         karma;

    template<class Action>
    void persist(Action& a)
    {
        dbo::field(a, name,     "name");
        dbo::field(a, password, "password");
        dbo::field(a, role,     "role");
        dbo::field(a, karma,    "karma");
    }
};

http://www.webtoolkit.eu/wt/doc/tutorial/dbo.html

-

In order to support reall "DRY" (Don't Repeat Yourself), some functionality should be provided by the library, to avoid the need to repeat every persistent member-variable 3 times.

Or is there something available already?

Actions #1

Updated by Koen Deforche about 10 years ago

  • Status changed from New to Rejected
  • Assignee set to Koen Deforche

We do not consider this repetition: there is no reason why the mapped field name would be the same as the member name (and often it is different), and there may be more elaborate logic in persist() in general.

For Wt::Dbo, DRY relates to:

  • DDL: schema creation (tables, constraints) and dropping
  • insert statements
  • update statements
  • select statements
  • queries with joins for relational collections
  • conversion from and to table models (boost::any)
  • serialization to JSON and other formats with custom action implementations
Actions #2

Updated by I. Lazaridis about 10 years ago

Koen Deforche wrote:

We do not consider this repetition:

[...]

For Wt::Dbo, DRY relates to:

I understand your viewpoint, but DRY has a concrete meaning, which is not about consideration.

The (forced) repetition on class definition level is simply annoying. There are other solutions which are really DRY.

This here is an issue with Dbo, possibly not a priority one for you, but it is one. And it should remain open, thus anyone interested can try to find a solution to at least reduce the annoying repetitions within the class definition.

Actions

Also available in: Atom PDF