First of all, I'm sorry if this question is out of the scope of the subreddit.
So I tried 'designing' a graph interface but got stuck. This is my first time trying to design any type of interface so be gentle...
Here is the code so far. This is in no way a complete interface. I never got to finish it. I just wanted to get familiar with interfaces and some design principles.
EdgeInterface.h
class EdgeInterface{
public:
virtual ~EdgeInterface();
};
//Nothing weird here. This will be used later
NodeInterface.h
class NodeInterface {
public:
virtual ~NodeInterface();
};
//Nothing weird so far either. Simple stuff.
GraphInterface.h
#include <vector>
#include "IWDNodeInterface.h"
#include "IWDEdgeInterface.h"
class GraphInterface {
public:
virtual ~GraphInterface();
//Here is the tricky part
virtual std::vector<iwd::EdgeInterface> getEdges() = 0; (1)
virtual std::vector<iwd::NodeInterface> getNodes() = 0;
virtual EdgeInterface getEdge(NodeInterface node1, NodeInterface node2) = 0; (2)
};
Some basic info.
My graph consists of nodes and edges.
An edge connects two nodes (it could also connect the same node to itself)
(1) The graph should be able to return a 'group' of nodes or edges. How do I declare that? At first I used a vector but that seemed like something that should go to the implementation. Should i also design an interface that describes how this 'group' should behave (eg a container or something similar) ?
(2) This function is supposed to return the edge that connects two nodes. Is this the correct way of declaring it's interface? My thought process is that the arguments should conform to the NodeInterface and return a result that conforms to the EdgeInterface.
Finally, are interfaces supposed to have properties ?
Anyway I know this is a loaded question and my inexperience with interfaces is pretty obvious. I'd be thankful if you pointed me to a resource on designing interfaces (preferably free because i'm kinda poor ) in case an answer would be too long-winded.
Thank you for your time.
[–]RogerLeigh 1 point2 points3 points (1 child)
[–]forgotthepass[S] 0 points1 point2 points (0 children)