Re: Relational-to-OOP Tax
- From: "frebe" <frebe73@xxxxxxxxx>
- Date: 19 Feb 2007 22:37:59 -0800
Decoupling SQL statements may or may not increase the total
number of lines of code, depending on the size of the SQL statements
and the number of times they are reused.
Forcing all SQL statements into functions instead of only putting them
into functions when suitable, will always increase LOC.
As discussed elsewhere in the thread, even the hard of learning
Mr. Jacobs admits that lines of code is not a sufficient measure.
More lines of code takes longer time to write. More lines of code
makes the code harder to read.
This is not always, or even often, the case. Highly coupled big
balls of mud that mix different concerns are more difficult to
understand than well-factored, clean code.
But nobody have proved why separating all SQL statements would create
cleaner or more well-factored code.
You keep asking for proof without specifying the burden of proof. What
burden of proof would require for structured programming to prove it is
better to call functions than not to (as used to be the case)
Regardless if your code contains SQL statements or not: Functions
should be used to avoid having repeated fragments of code that are
more complex than the function call itself. If the function is only
called once or is as simple as the call to it, a function has no
purpose. Function may also be used to enable recursion.
or that it
is better to let a filesystem handle file-io than an application to
manipulate disk structures directly (as also used to be the case)?
A relational database already offer separation between logical and
physical data structures. SQL already offer independence between
database vendors.
Maintainability and extensibility are two NFRs that come
immediately to mind. Clean code is easier to maintain and extend.
In what what way is
createEmployee(x,y,z)
function createEmployee(x,y,z) {
insert into employee values (x,y,z)
}
cleaner than
insert into employee values (x,y,z)
It is cleaner when createEmployee(x,y,z) is more realistically imagined:
insert into employee...
insert into address ...
insert into employeeAddress ...
insert into employeeEmployee ...
insert into calendarResource ...
insert into payroll ...
insert into planParticipant ...
insert into benefitParticipant ...
insert into dependents ...
How would the argument list to createEmployee look like?
createEmployee(x1, x2, ....., x200)
If you show the complete implementation of createEmployee, I can
promise you that it is everything but clean.
and when another table is created that must know about new employees the
procedure can be updated without modifying application code.
Sorry, I don't follow you here.
Or if
employees can be added from multiple applications it is better to have
isolated the code for adding them than to duplicate it.
If the same fragment of code should be called from multiple points, a
function is suitable.
Are you arguing that clean, well-designed code does not have
quality benefits?
No, but creating new functions with only one statement or functions
that are only called only once, doesn't create cleaner or more well-
designed code.
Practically speaking that is rarely the case.
My experience is exactly the opposite. Using view would also make the
scenario more common.
And even if it occurred
more often than rarely, it is a better design that allows one
module/function/method to change independently of others that rely on it.
If a SQL statement is simple, there are not many possibities to change
it, without changing the semantics.
/Fredrik
.
- Follow-Ups:
- Re: Relational-to-OOP Tax
- From: Jerry Coffin
- Re: Relational-to-OOP Tax
- References:
- Re: Critique of Robert C. Martin's "Agile Principles, Patterns, and Practices"
- From: topmind
- Re: Critique of Robert C. Martin's "Agile Principles, Patterns, and Practices"
- From: Patrick May
- Re: Critique of Robert C. Martin's "Agile Principles, Patterns, and Practices"
- From: topmind
- Re: Critique of Robert C. Martin's "Agile Principles, Patterns, and Practices"
- From: Patrick May
- Relational-to-OOP Tax (was: Critique of Robert C. Martin's...)
- From: topmind
- Re: Relational-to-OOP Tax (was: Critique of Robert C. Martin's...)
- From: Patrick May
- Re: Relational-to-OOP Tax (was: Critique of Robert C. Martin's...)
- From: topmind
- Re: Relational-to-OOP Tax
- From: Patrick May
- Re: Relational-to-OOP Tax
- From: topmind
- Re: Relational-to-OOP Tax
- From: Patrick May
- Re: Relational-to-OOP Tax
- From: topmind
- Re: Relational-to-OOP Tax
- From: Patrick May
- Re: Relational-to-OOP Tax
- From: topmind
- Re: Relational-to-OOP Tax
- From: Patrick May
- Re: Relational-to-OOP Tax
- From: frebe
- Re: Relational-to-OOP Tax
- From: Patrick May
- Re: Relational-to-OOP Tax
- From: frebe
- Re: Relational-to-OOP Tax
- From: Patrick May
- Re: Relational-to-OOP Tax
- From: frebe
- Re: Relational-to-OOP Tax
- From: Thomas Gagne
- Re: Critique of Robert C. Martin's "Agile Principles, Patterns, and Practices"
- Prev by Date: Re: warning: ignoring induction and analogy may be harmful to your code
- Next by Date: can i learn OOD without any procedural 1st
- Previous by thread: Re: Relational-to-OOP Tax
- Next by thread: Re: Relational-to-OOP Tax
- Index(es):
Relevant Pages
|