Changes between Initial Version and Version 1 of soc/2007/UserFriendlyGraphDesignOne


Ignore:
Timestamp:
May 14, 2007, 3:40:07 PM (15 years ago)
Author:
Andrew Sutton
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • soc/2007/UserFriendlyGraphDesignOne

    v1 v1  
     1An early prototype of the design proposed to simply (publicly) inherit the `adjacency_list` class like so:
     2{{{
     3#!cpp
     4namespace boost {
     5  template <class VL, class EL, class OEL, class VP, class EP, class GP>
     6  class undirected_graph : public adjacency_list<OEL, VL, undirectedS, VP, EP, GP, EL>
     7  { };
     8}
     9}}}
     10== Rationale ==
     11The rationale with for this approach to the implementation is simply "minimal work, maximal payoff". Potentially, this would implement half my proposal in a single
     12line of code - or rather 2 lines including the directed graph class.
     13
     14== Remarks ==
     15Obviously, this probably the simplest implementation possible with as much reuse as possible. In this strategy, I wouldn't even have to implement any of the requirement methods since graphs are always passed by reference, we can let the inheritance handle this for us. The problem with this approach is that if we ever decide to put members into this class, we can run the risk of ''object-slicing'' due to blind reuse of methods that I didn't write. While the alure of a one-line implementation is strong, we should probably defer to practical experience and good advice (in the form of ''C++ Coding Standards: 101 Rules Guidelines and Best Practices'' by Sutter and Alexandrescu). I'm not overloading virtual functions, accessing protected members, and I'm pretty sure `adjacency_list<>` wasn't intended for inheritance.