Re: Critique of Robert C. Martin's "Agile Principles, Patterns, and Practices"



On 2007-01-23 13:25:22 -0600, frebe73@xxxxxxxxx said:

The payroll system in the book is partitioned into code that knows
about the DB schema, and code that does not. The dividing line is a
set of interfaces that translate high level concepts like "GetEmployee"
into appropriate SQL. To the left of the interfaces the code deals
with Employees. To the right the code deals with SQL, tables, rows,
and columns.

How many getEmployeeBySomeCriteria methods do you think you will end up
with in a normal payroll application?

I imagine it will be quite a few, though fewer than the number of embedded SQL statements that would exist if I did not put them behind an interface.

Why do you want to hide predicate
logic and set operations behind a procedural interface?

I don't. I want to give the operations meaningful names. For example:

findEmployeesEligibleForRetirement()

is more evocative than a long SQL statement that doesn't mention retirement at all. Think of the functions as compilable comments that describe what the SQL beneath them is intended to do.

This has the additional benefit that when the eligibility rules change, the callers of findEmployeeEligibleForRetirement() will be unaffected.


In any application, OO or not, this translation must take place.

Absolutely not.

The data is on the disk. It must be translated into some kind of TableRow structure or similar. Then it must be unpacked from that structure into something convenient for the application to use.

Now it is entirely possible that the application will simply index into the TableRow structure every time it wants to access the data; but even that is an *implicit* translation into a more convenient form.

There is no duplication. There is no waste.

If you have a table employee and a class employee, you obviously have
duplication.

You have the same "duplication" if you have a table "employee", and a set of convenient variables used to hold parts of one of the rows from time to time. You even have it if you have a TableRow structure that holds the employee row.

If you have five variants of getEmployeeBySomeCriteria,
you obviously have duplication.

I don't see that at all. The five functions may simply call a more general function passing in specific parameters.

--
Robert C. Martin (Uncle Bob)  | email: unclebob@xxxxxxxxxxxxxxxx
Object Mentor Inc.            | blog:  www.butunclebob.com
The Agile Transition Experts  | web:   www.objectmentor.com
800-338-6716                  |



.



Relevant Pages

  • Re: SQL
    ... SQL is a specific language with certain ... relational nor query languages. ... which don't fully implement ADT. ... interfaces to such are often not as flexible as query-based interfaces. ...
    (comp.object)
  • Re: Reusing SQL data-related logic, replacing weird modules and improving Class::DBI
    ... granular control to SQL. ... Their products are inflexible and too often improperly built. ... has strctured interfaces to it, so why wouldn't it make sense to create ... underlying structures for manipulating data - in the case of SQL, ...
    (comp.lang.perl.modules)
  • Re: Architecture guidelines
    ... > I use the interfaces like this (this code is just an example and isn't ... > that the syntax of the SQL stmt themselves varies slightly. ... > i add the semicolon to all sql statements). ... Got it, Scott, thanks for the explanation. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Architecture guidelines
    ... I use the interfaces like this (this code is just an example and isn't ... I defined a class with static members "DbUtilties" which handles the actual ... that the syntax of the SQL stmt themselves varies slightly. ... i add the semicolon to all sql statements). ...
    (microsoft.public.dotnet.languages.csharp)
  • need help with query
    ... Oracle and then sent me the SQL it used to do it. ... that represents and Outer Join in Oracle. ... Can anybody tell me how I can translate the into something Access will ...
    (microsoft.public.access.queries)