P
plmuon
Hello,
I would be very interested in your thoughts on the following:
In a large project with lots of own model classes and basetypes we are
debating to stick interfaces in front of any such class. (the
implementation language is Java, but the same could be done with
abstract classes in c++).
The reason for this is that some are using EMF, the eclipse modelling
framework, which could generate code and just demands this from any
code involved.
I would like some advice on whether it is wise to do as described
below.
Suppose we would normally have something like (pseudocode):
class Employee {...}
class Country {...}
class Position{...}
class Client {
private Country domicile;
private Position[] positions;
private Employee custumerResponsible;
public Country getDomicile() {return domicile;}
public Position[] getPositions() {return positions;}
public Employee getCustomerResponsible() {return customerResponsible;}
}
Instead we would have:
interface Employee {...}
class EmployeeImpl implements Employee {...}
interface Country {...}
class CountryImpl implements Country {...}
interface Position {...}
class PositionImpl implements Position {...}
interface Client {
public Country getDomicile() {return domicile;}
public Position[] getPositions() {return positions;}
public Employee getCustomerResponsible() {return customerResponsible;}
}
class ClientImpl extends Client {
// constructor left out
private Country domicile;
private Position[] positions;
private Employee custumerResponsible;
public Country getDomicile() {return domicile;}
public Position[] getPositions() {return positions;}
public Employee getCustomerResponsible() {return customerResponsible;}
}
So note there is no direct conection between ClientImpl and
CountryImpl e.g., everything goes via the interfaces.
Until now I am used to using interfaces on a coarser level, only to
define some kind of API and facade (and some other cases). In this
case we would have a very fine grained "facade": each and every model
class, even including base types such as Country, Currency, are
"wrapped" into interfaces and do not interact directly with each
other. As mentioned, EMF is the reason for doing this, but one might
argue that this is a good thing in itself even if not forced to do so
due to some tool such as EMF.
In my first usage of this mechanism, I found that it is quite
cumbersome. I have the feeling that I'm coming forward only at 1/10th
of my normal speed. Also when class browsing, the indirection through
all of these interfaces kind of generates a fog for me that is very
hard to see through.
I would be very interested to know your thoughts on this approach. Is
it a good thing, even becoming common practice? Is it overdesign?
A popular modelling framework EMF, the Eclipse Modelling Framework,
uses it and relies on it. If we want to allow some people in our team
to use it, we must go this way. The interfaces would have annotations
(such as @model) to pass extra information to the EMF.
I did not post this question to an eclipse (EMF) group because my
impression is that it is being used only by people that are not mainly
developing applications using modelling, but mainly by people that
have the modelling itself (e.g. to develop modelling tools) as their
core business, i.e. I have my doubts on the practicability of EMF in
real world applications.
Peter
I would be very interested in your thoughts on the following:
In a large project with lots of own model classes and basetypes we are
debating to stick interfaces in front of any such class. (the
implementation language is Java, but the same could be done with
abstract classes in c++).
The reason for this is that some are using EMF, the eclipse modelling
framework, which could generate code and just demands this from any
code involved.
I would like some advice on whether it is wise to do as described
below.
Suppose we would normally have something like (pseudocode):
class Employee {...}
class Country {...}
class Position{...}
class Client {
private Country domicile;
private Position[] positions;
private Employee custumerResponsible;
public Country getDomicile() {return domicile;}
public Position[] getPositions() {return positions;}
public Employee getCustomerResponsible() {return customerResponsible;}
}
Instead we would have:
interface Employee {...}
class EmployeeImpl implements Employee {...}
interface Country {...}
class CountryImpl implements Country {...}
interface Position {...}
class PositionImpl implements Position {...}
interface Client {
public Country getDomicile() {return domicile;}
public Position[] getPositions() {return positions;}
public Employee getCustomerResponsible() {return customerResponsible;}
}
class ClientImpl extends Client {
// constructor left out
private Country domicile;
private Position[] positions;
private Employee custumerResponsible;
public Country getDomicile() {return domicile;}
public Position[] getPositions() {return positions;}
public Employee getCustomerResponsible() {return customerResponsible;}
}
So note there is no direct conection between ClientImpl and
CountryImpl e.g., everything goes via the interfaces.
Until now I am used to using interfaces on a coarser level, only to
define some kind of API and facade (and some other cases). In this
case we would have a very fine grained "facade": each and every model
class, even including base types such as Country, Currency, are
"wrapped" into interfaces and do not interact directly with each
other. As mentioned, EMF is the reason for doing this, but one might
argue that this is a good thing in itself even if not forced to do so
due to some tool such as EMF.
In my first usage of this mechanism, I found that it is quite
cumbersome. I have the feeling that I'm coming forward only at 1/10th
of my normal speed. Also when class browsing, the indirection through
all of these interfaces kind of generates a fog for me that is very
hard to see through.
I would be very interested to know your thoughts on this approach. Is
it a good thing, even becoming common practice? Is it overdesign?
A popular modelling framework EMF, the Eclipse Modelling Framework,
uses it and relies on it. If we want to allow some people in our team
to use it, we must go this way. The interfaces would have annotations
(such as @model) to pass extra information to the EMF.
I did not post this question to an eclipse (EMF) group because my
impression is that it is being used only by people that are not mainly
developing applications using modelling, but mainly by people that
have the modelling itself (e.g. to develop modelling tools) as their
core business, i.e. I have my doubts on the practicability of EMF in
real world applications.
Peter