8
$\begingroup$

So I noticed, that a lot of students taking OR-classes come from non-computer science backgrounds (e.g. buissiness administration). They typically had only one other class in their first semester where they had to write (typically java) code, and therefore their code is very "hacky". It works, but I wouldn't want to hire them as software devellopers, or have them write code that actually is used anywhere and needs to be maintained.

So my questions would be:

a) Is the expectation for entry level positions, that the applicant is able to produce high quality code, or is that something that would be learned on the job?

b) What are some good self-study resources to improve the quality of code I can recommend to my students?

c) Are there some reference codes, that would be good examples for high quality code?

$\endgroup$
  • 2
    $\begingroup$ The thing is that you cannot learn to write good codes unless you know how to. You can improve your own style of writing code with the knowledge that you have but in general the quality of code improves with the knowledge of coding. For this, reading a good amount of code is quite necessary. Specifically, sit and ask yourself how would you be doing it and how its done by someone else. By comparing you inculcate what you do not know. Apart from that, the generic advice are: write structural code, modular code, nicely document it, leave proper comments, make it simpler. Google Zen of Python $\endgroup$ – your_boy_gorja Jun 30 at 10:04
  • 1
    $\begingroup$ There's a new MIT course which reminded me of this question and Nikos' answer. Course material is available online The Missing Semester of Your CS Education. They cover shell tools and scripting, data wrangling, command line environment, version control (Git), debugging and profiling among other topics. $\endgroup$ – dhasson Jul 21 at 16:45
8
$\begingroup$

Disclaimer: I have worked for 3 years as an optimization software developer at a utility company and now work for Gurobi.

Is the expectation for entry level positions, that the applicant is able to produce high quality code, or is that something that would be learned on the job?

There is no expectation because it is often not the case (as Nikos said). However, a candidate who is capable of decent coding is going to have much better chances, as very advanced theoretical knowledge is often not the most important hiring decision. Please encourage your students to have a github profile and post some stuff there; I always looked at that when we got applications in.

What are some good self-study resources to improve the quality of code I can recommend to my students?

There is a distinction to make here: for general coding the best book in my opinion is "Design Patterns" by the Gang of Four. Beyond that, code review is your biggest resource (you can even hire people online for $5), because that way you get feedback from someone else about your code.

As for OR-specific code: there are unfortunately no guidelines on this whatsoever. I wrote up some on LinkedIn a year or so ago (and writing this up in a book is still on my to-do), but I don't know of anything else. If you come across something, let me know.

Are there some reference codes, that would be good examples for high quality code?

For general software, just check out GitHub and off you go. You will recognize good code pretty quickly.

For OR-specific things, I did not find much (as Nikos said). For fun I implemented the rules I set out publicly in this repo about optimizing which drinks to buy for your bar. But it is far from perfect. It should though give an idea of how one can do it.

| improve this answer | |
$\endgroup$
9
$\begingroup$

Unfortunately writing high quality OR code is beyond the reach of most academic settings. This is mainly because:

  • Writing high quality code is very time consuming.
  • The scope of OR code is much better suited to teams of people rather than a lone wolf trying to do everything alone.
  • Because it's time consuming, there's never enough time in academia to do this properly, as priorities are different (publish or perish).
  • Academia is a place to learn by doing things wrong. Industry is the place we go to after we've learned stuff.
  • Production code is the domain of professional developers. I thought I was pretty good at coding after my PhD, and all my developers put me to shame. Most of them are 10 years younger than me.
  • In most academic groups, even if a person who does things properly shows up from time to time their know-how leaves the group when they do.

Academia really needs to move away from the notion that a talented student can just "do things" alone. This is simply not true in software in any production setting. People need teams, support, infrastructure, and senior leads to guide development.

The remedy would be for academic groups to start employing professional developers full-time to support the researchers. This would have the nice side effect of training them to do things properly while they do research.

All this means that requirements are not really high from a coding point of view. This is dangerous because supervisors tend to accept candidates who simply don't have the background to do the work necessary. My advice for entry-level applicants is to really look into who is in the group, and how long the people who know what they're doing are going to be there after you join. If they don't have a computer science background they should be prepared to do a lot of work to catch up if you want to write good code.

A red flag is if the group doesn't have a repository to inherit code between students. If they have code, people should read that code before they join. Does the group have continuous integration? Does the code have unit tests? Are there 15 forks or does everything eventually get merged into the master branch? Is there a person responsible for maintaining the codebase? Who is that person? If they leave, are there plans to replace them?

My experience is that unless new applicants can get good answers to such questions the group is unlikely to have the culture to provide the support people need to write high-quality code.

For industrial entry-level positions it depends on the company - for instance at Octeract we have very high standards for C++, but we also don't have entry-level positions. We still do a lot of training, but mostly on advanced things.

Commercial solvers are of course not the only applications of OR, in other settings standards are lower and entry-level jobs are available.

The best open source OR code I've seen is MINOTAUR, but even that is a far cry from production-level OR code.

Good resources for students are predominantly to start using the tooling we use in the industry. They should learn how to use Git, Jenkins, and the Clang tools. They should read the Google style guide on how to format code properly. The should learn how to use static analysis tools, profilers, and Valgrind to diagnose the state of their code. They should get into the habit of writing unit tests for their code (Catch! is a good testing framework for C++). They should use Doxygen to automatically map and document the codebase.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Agree with your diagnosis and most - if not all - of the points mentioned. However, I'm not sure academia should invest many resources training people on software development or related topics, because 1) many people go on a highly theoretical path and 2) the majority of companies in industry don't contribute data or pay for their research. Unless going to industry is part of the scope for the graduate program/research group, why should they spend valuable time preparing people for skills needed mostly in industry? Apparently this question is no man's land and people tend to learn on their own $\endgroup$ – dhasson Jun 30 at 16:09
  • 2
    $\begingroup$ @dhasson Problem is, this is not optional. Doing research properly requires good tools. In OR all the basics have been explored which means that the tools available have to keep evolving, and that is now beyond what a couple of bright students can do in a few years. We really see that with the SCIP team, who are the only group in the world capable of publishing the things they do, precisely because they have built a great codebase for research. $\endgroup$ – Nikos Kazazakis Jun 30 at 18:20
  • $\begingroup$ I agree with you on that matter. Even good publications must be reproducible, maybe peer review require detailed explanation of the computational aspects (code or at least pseudocode). For example, I've seen papers where the authors comment a referenced paper wasn't generating the kinds of instances its authors suggested, etc. These phenomena and bad practices introduce lots of noise into research as a whole. Again, the high pressures of academic life (publish or perish) get in the way. $\endgroup$ – dhasson Jun 30 at 18:50
  • $\begingroup$ @dhasson Yeah, and even worse, publishing stuff that requires commercial software to reproduce..! $\endgroup$ – Nikos Kazazakis Jul 1 at 10:45
5
$\begingroup$

I can really only answer one point:

b) Clean Code: A Handbook of Agile Software Craftsmanship I think the examples in the book are even for Java, but it is applicable for other languages as well. (This is the entry book, there are follow up books in this series)

What helped me a lot is taking a piece of code i have written and then taking one concept of the book like "a function should only have one purpose" and then refactoring this code and then comparing the two versions. With time you do more of the stuff immediately.

What i think is important is that you do not only read books or other code, but you need to do this for you own code.

It is also important to tell the students, that you often first write code that works, but is not really of good maintainble quality and then you do a refactoring to make it more maintainable/better readable. This second step is something that requires discipline, because the code already works and there are only immediate costs involved in refactoring, but it bites back in the long run if you don't do it.

| improve this answer | |
$\endgroup$

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.