Re: static or not?



iamfractal@xxxxxxxxxxx wrote:
Hi, Ed!

....
> Thus, for example, controller.Driver will register its Controller
> interface in the Registry by calling:
> Registry.getInstance().register(this).

package controller;
package-private class Driver extends controller.Controller{
void register() {
Registry.getInstance().register(this);
}
}
is the register method correct as far as it goes?


"If I use a singleton, then I can strip away an interface from this
singleton, and have it register that interface in the Registry.

If I use static methods, I cannot do this: static methods are not
allowed to hide the instance methods of the interface.

This is the major reason I use a singleton, instead of a class of
static methods. " -Ed

this is where you're stripping away an interface?

> Next, a user will make some input; we needn't specify how, here, but
> suffice it to say that when that input is made, an object will need to
> get that input into the system. It will do this by doing something
> like:
> Controller controller = Registry.getRegistry().getController();
> controller.process(input);

if this is done from class foo, what's foo's package? of MVC
I think view, but view presents data to the user, so I'm not sure.

> The Driver object will have its process() method called, and will kick
> the database into life, by something like:
> Registry registry = Registry.getInstance();
> Model model = registry.getModel();
> model.doThis();
> model.doThat();
> Result result = model.getResult();
>
> (OK, here's an interface I'd forgotten; any guesses where we'd declare
> it?)

heh, ir1 of course.

> The Driver object would then output the result to the use by:
> int viewID = registry.getCurrentViewID();
> View view = registry.getView(viewID);
> view.show(result);

where did result come from, please?
view.show() might trigger a SQL query and would show the outcome of
that query?

you said "...portray Driver as a Controller," so it's:

package controller;
package-private class Driver implements SomeInterface {...


> Thus we have a system in which there are only two types of
> inter-package, concrete class dependencies:
>
> 1) From Start to XStart - and these XStart classes only contain enough
> logic to kick start the business logic, in other words, these
> dependencies do not change as business logic changes.

if everything in the start package is business logic, might that
logic consist of static methods, like Math.sin(x), or is that a bit
extreme?

> 2) Dependencies on the Registry concrete class - but this class simply
> stores and erturns interfaces, and has no dependencies on the
> methods of those interfaces, and thus is immune to changes of the
> interface methods (although of course will change as whole
> interfaces change, and new ones are added).



> And *all* other inter-package dependencies are on interfaces
> only. Thus, you can switch in any database you like, as long as it
> conforms to the Model interface (this will, in reality, probably be
> JDBC, or a wrapper thereof). The same goes for the Views and even the
> Controller itself.
>
> Hence, "Program to an interface repository, not an implementation
> repository."
>
> Note that model package, view package, and controller packages do not
> depend on one another (you can Google for the heated discussions on
> which of these packages should depend on one another, and which must
> not), and that the system is guaranteed to be free from inter-package
> circular dependencies.

err, next time ;)

> Of course a full system will have hundreds of packages, and there will
> be hierarchical start/implementation repository/irX packages, but the
> design is - and particularly the benefits listed above are -
> wonderfully extensible.
>
> .ed
>
> www.EdmundKirwan.com - Home of The Fractal Class Composition.



this helps to justify MVC for me, thanks.



-Thufir

.



Relevant Pages

  • Re: static or not?
    ... >> Thus, for example, controller.Driver will register its Controller ... > "If I use a singleton, then I can strip away an interface from this ... > if this is done from class foo, what's foo's package? ...
    (comp.lang.java.help)
  • Re: static or not?
    ... > There'd be package "driverAndViews," or something, with the various ... > How does the communication between Database and Registry work? ... View interface, but I will correct this in this example, and portray ... containing more than one concrete class. ...
    (comp.lang.java.help)
  • Re: Nslookup problem
    ... The A record that has the DC's host name is controlled by the "Listen on" ... Or you can add this registry value for the IP addres to publish the record ... internal interface that has file sharing enabled on it. ... shares and one must exist for each domain controller and have the IP address ...
    (microsoft.public.windows.server.dns)
  • Re: Separate Compilation in Programming Languages
    ... within one package body. ... all, separate or otherwise. ... OK, so you like having textually separate spec and body, ... Clients of an interface do not depend ...
    (comp.lang.ada)
  • Re: Global variables
    ... I have a litte OT question: how do you initialize the Repository? ... first class triggered the Starter class. ... principle of object orientation is to design towards an interface, ... Starter class must not reside in the interface respository package. ...
    (comp.object)