I'm building a PHP web application, that should provide to the user a possiblity to order an "installation"/setup of a (ConnectDirect or File Transfer Gateway) connection between him and another person/organization.
(The technical specifica of the connection implementation are not important -- in the application it's only about the connections as product, that can be ordered and managed.)
The classes hierarchy for its model layer should represent following real-world infrastructure:
- There are connections, that can be ordered.
- A connection can be an IBM Connect:Direct connnection or an IBM File Transfer Gateway connection.
- A CD connection is direct from A (source) to B (target).
- A FTGW connection consists physically of two connections: A (source) to the FTGW server and from the FTGW server to B (target) -- but logically (for the ordering user) it's also one connection.
- (There is additionally a case of an FTGW connection, that uses Connect:Direct as protokoll.)
- Every endpoint is either a source or a target.
So I see following logical elements: logical connection, physical connection, role (source and target), connection type, order, endpoint, endpoint type (CD and FTGW).
The structure I currently have looks like this:
But there are some issues with it:
There are two hierarchy trees, where each element of the one consists contains elements of a particular subset of the other (each CD connection consists of CD endpoints; each FTGW connection consists of two FTGW endpoints, or more correctly: each FTGW logical connection consists of two physical FTGW connections -- and each of them consists of an FTGW endpoint and the FTGW server as second endpoint).
An alternative might be to replace the relationship betweet
Endpoint
andPsysicalConnection
by two relationships:EndpointCD-PsysicalConnectionCD
andEndpointFTGW-PsysicalConnectionFTGW
.
Pro: More consistent; eliminates the logical imprecision (or maybe even mistake) of the faked possibility to build every connection (type) from a pair of any endpoints. Contra: Actually the requirement to contain two endpoints is a characteristic of every psysical connection -- from this point of view the right place for this is the very basic PsysicalConnection
class.
Every endpoint can be both source and target and contains not only the common endpoint properties, but also source and target properties. That means, dependent on the currnt role of the endpoint some properties are waste. And this will also be influence the database structure (columns, that sometimes have to be set and sometimes have to bi
NULL
).An alternative is to extend the hierarchy...
a. ...by classes like
EndpointSource
andEndpoitTarget
inheriting directly from theEndpoint
and being inherited by the classesEndpointCD
andEndpointFTGW
(that means: two identical subtrees -- underEndpointSource
and underEndpointTarget
);b. ...by classes like
EndpointCDSource
andEndpointCDTarget
(inheriting from the classEndpointCD
) andEndpointFTGWSource
andEndpointFTGWTarget
(inheriting from the classEndpointFTGW
) being inherited each by the concrete CD or FTGW endpoint classes (that means: twice two identical subtrees);c. ...by classes like
MyConcreteEndpoint***Source
andMyConcreteEndpoint***Target
inheriting from the concrete endpoint classes (that means: everyMyConcreteEndpoint
class becomes abstract and gets two sublesses --MyConcreteEndpoint***Source
andMyConcreteEndpoint***Target
, e.g.EndpointCDLinux
is now abstract and is inherited byEndpointCDLinuxSource
andEndpointCDLinuxTarget
).Pro: eliminates the waste properties. Contra: A (more) complex class hierarchy.
Well, it's about software architecture and should (and of course will) be my design decision. But it would be nice to hear/read some expert (or non-expert) thougts, how to handle such a case. What are proper ways to organize the logical items for an infrastructure like what I described?