Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #6254
| From | BartC <bc@freeuk.com> |
|---|---|
| Newsgroups | comp.programming |
| Subject | Re: Designing a suite of algorithms in C++ |
| Date | 2016-02-01 23:00 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <n8onsl$mkf$1@dont-email.me> (permalink) |
| References | <2df6fc12-e6c9-4f5b-bdb7-21e35a57edbb@googlegroups.com> |
On 01/02/2016 11:38, Paul wrote: > The post below was also sent to comp.lang.c++ but it's been more than half a day, and I haven't got any responses so I'd like to post it to this group. > > I am trying to present in C++ a set of algorithms for solving a problem. It is intended that the set of algorithms will expand. So far, I have five basic algorithms for solving the same problem. The end goal (so far) is to develop a simple user interface at the console so that the user can provide the parameters, together with a string indicating the name of the algorithm, and my code will provide the solution (and possibly the runtime). > > Four of these algorithms are simple conceptually (although the maths is complicated). However, the fifth algorithm is much more involved because it has four or five features which can be absent or present so the fifth algorithm can really be thought of as 16 or 32 algorithms. (The vagueness is because I haven't decided which features to be settable by the user). > > If I only had the first four to worry about, the design could be very simple. > I would have a pure abstract class as a base of all the algorithms. That's the least of the problems I think. Maybe forget classes to start with. What exactly will the interface look like? Is it a bunch of numbers and stuff all on one line, or will there be some interaction to get the parameters depending on the algorithm chosen? How is the algorithm specified? (It would be simplest if this is done at the start, before any parameters rather than after.) Maybe then as well as 'handlers' for dealing algorithm N, or finding solution N (what's the difference between those?), you can have another handler GetParameters N, a dedicated routine for each kind of algorithm. Then it doesn't matter if algorithm 3 is very different from 5, as it has its own user interface. (This is feasible for 5 algorithms; if the number grows significantly, then you can think about making it table-based, or class-based if you must, but then it will be clearer how to approach the problem. I would also suggest, unless it must be 100% C++ or it has to run within an existing application, to use a scripting solution for grabbing the input. Then the different algorithms don't even need to be part of the same program.) -- Bartc
Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Designing a suite of algorithms in C++ Paul <pepstein5@gmail.com> - 2016-02-01 03:38 -0800
Re: Designing a suite of algorithms in C++ Mark Carroll <mtbc@bcs.org> - 2016-02-01 12:04 +0000
Re: Designing a suite of algorithms in C++ Paul <pepstein5@gmail.com> - 2016-02-01 05:52 -0800
Re: Designing a suite of algorithms in C++ Mark Carroll <mtbc@bcs.org> - 2016-02-01 15:10 +0000
Re: Designing a suite of algorithms in C++ Paul N <gw7rib@aol.com> - 2016-02-01 14:15 -0800
Re: Designing a suite of algorithms in C++ BartC <bc@freeuk.com> - 2016-02-01 23:00 +0000
Re: Designing a suite of algorithms in C++ Kaz Kylheku <330-706-9395@kylheku.com> - 2016-02-01 23:24 +0000
csiph-web