POV-Ray : Newsgroups : povray.off-topic : Java : Re: Java Server Time
29 Jul 2024 18:17:23 EDT (-0400)
  Re: Java  
From: Darren New
Date: 19 Nov 2011 12:20:15
Message: <4ec7e54f@news.povray.org>
On 11/19/2011 1:33, Le_Forgeron wrote:
> Le 19/11/2011 07:07, Darren New nous fit lire :
>> I've been trying to introduce the team to the wonders of actually having
>> the code and the data in the same class. :-)
>
> Well, from the old relational database experience... they shouldn't.
> At least, they shouldn't be too tighly coupled until the code is
> specific to the data and the data are usable only by the code.

Well, the data in the database shouldn't be exposed to the user at all, any 
more than if your web site is stored in a database the browser should need 
to know that.

What I'm saying is that if you have a routine that (for example) marks a 
video as having been watched by the current user, it shouldn't be in some 
third class called "VideoWatcherRecorder" taking an integer video number and 
a long user ID. It should be in the video class and take a reference to a 
user object, or vice versa. Otherwise, you're just writing procedural code 
in Java.

> Data should have their invariants and rules.

Yep. And that's very hard to do without doing OO programming. Or relational 
programming. And if you're using an OO language like Java, it should be 
enforced in the objects that interface to the database (along with the 
database, if possible, which it isn't in this case).

> Code should be in charge of transforming the data with respect to the
> rules and adding new pieces of data which also match the rules.

Sure. But the difference is where that code live. Is it in some other 
package or compilation unit, or is it in the same class that reads and 
writes the database?

-- 
Darren New, San Diego CA, USA (PST)
   People tell me I am the counter-example.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.