13
$\begingroup$

I'm looking for resources on design patterns and principles for numerical software, potentially but not necessarily with a focus on object-oriented approaches to numerical codes.

I am aware of the text, Writing Scientific Software: A Guide for Good Style, but this still deals a lot with things like floating point issues, how and when to optimise, etc.

I'm looking for information on the bigger picture of designing numerical codes, not on anything that deals with algorithms and the like.

I'd hope there are resources for this, and one isn't left to just going through library after library, especially since there's no guide on which do things correctly design wise, apart from my own knowledge of good idioms and practices in C++.

(This is not language specific, but if there is any language specific content, I'd prefer C++.)

$\endgroup$
  • $\begingroup$ I've often thought about writing such a book; but the range of possible approaches is huge (and depends strongly on the primary numerical technique + the problem domain) and what's needed is more like an encyclopedia. Also, no single person can have a grasp of all the possibilities. The best one can do if follow traditional software practice keeping hardware developments in mind. What's your technique and domain of interest? $\endgroup$ – Biswajit Banerjee Dec 15 '17 at 20:06
  • 2
    $\begingroup$ Another useful reference that isn't quite on target is "Effective Computation in Physics" by Anthony Scopatz and Kathryn Huff. $\endgroup$ – Brian Borchers Dec 15 '17 at 20:16
  • $\begingroup$ @BrianBorchers Hm, it seems half of it is in an introduction to Python and then focuses on development tools. $\endgroup$ – user1997744 Dec 16 '17 at 8:12
8
$\begingroup$

Having developed numerical software for 20 years now, I find that we've probably used the majority of the design patterns described in the Book by the Gang of Four (see here). At the end of the day, numerical software is just large-scale, complex software as well, so it is maybe not surprising that the same design considerations apply as in other software.

There are, of course, a number of cases that really are specific to numerical algorithms (see, for example, here) but knowing the "traditional" set of design patterns is really a good start already.

$\endgroup$
  • $\begingroup$ I'd like to add that, for numerical computations on newer hardware, one should strive to minimize pointer chasing (which many of the Gang of Four patterns use). A good starting point for C++ designs is github.com/isocpp/CppCoreGuidelines/blob/master/… $\endgroup$ – Biswajit Banerjee Dec 18 '17 at 20:03
  • $\begingroup$ @BiswajitBanerjee Yes, the C++ core guidelines are basic knowledge for anyone into modern C++ use. Herb Sutter’s one of the editors and you can always trust his advice. $\endgroup$ – user1997744 Dec 19 '17 at 14:13
  • $\begingroup$ @user1997744 Did you mean Bjarne? Herb Sutter is also famous for his "always auto" idea which leads to write-only code (not sure how much I would trust his judgement). Also, the C++ core guidelines are far from basic knowledge. You'll be surprised. $\endgroup$ – Biswajit Banerjee Dec 24 '17 at 3:52
  • $\begingroup$ @BiswajitBanerjee Well, if they’re not, I can say I would never let a developer progress beyond a single interview if they were not familiar with the majority of the guidelines and using them (excluding where legacy code may make that tricky). $\endgroup$ – user1997744 Dec 24 '17 at 8:25
6
$\begingroup$

I recommend this Matthew G Knepley. Programming languages for scientific computing. arXiv preprint arXiv:1209.1711, 2012 (https://arxiv.org/pdf/1209.1711.pdf)

I also advise to look and read other codes, for example, triangle, PETSc, MoAB, deal.II, fenics and many others. Not all solutions will work for you, but at the end, coping and learning from others (experienced developers and successful codes) is the best lesson how to design code.

Moreover, I think is better to join to an existing project and become contributor or developer. Sometimes you like to kick start something new, but you have to have solid arguments to do that.

$\endgroup$
  • $\begingroup$ My argument to kick start something new is the learning experience from it and the sense of accomplishment :) $\endgroup$ – user1997744 Dec 16 '17 at 11:23
  • 1
    $\begingroup$ I understand this argument. I had done the same thing a long time ago. Now I think it was premature. It could be that at the beginning all we have to make the same mistakes. To learn how to walk first, you have to fall. Writing own code, if this is the first time, you will very likely be the only user of your code. Contributing to community developed code, your work will be probably used by others and this will give you sense of achievement and appreciation. You will receive comments/review at pull request, from that you will learn and improve your skills. $\endgroup$ – likask Dec 16 '17 at 11:41
  • $\begingroup$ Well, there’s no library for an ultra specific esoteric computation I need to do, so in the end I actually have to write my own though of course there’s no need to reinvent everything. $\endgroup$ – user1997744 Dec 16 '17 at 12:58
  • $\begingroup$ Great advice to join an open source existing project. I got pulled into a network of programmers way better than me by doing that. $\endgroup$ – user14717 Dec 16 '17 at 23:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.