Note that there are some explanatory texts on larger screens.

plurals
  1. POMy design is practically screaming for OOP. Should I change my design or change my programming language?
    text
    copied!<p>I'm writing a hobby project wherein I write to .wav files. I decided that the best way to do this is to create a single C file with a bunch of routines to initialize and manipulate a struct with metadata about the wave file that the user should never manually manipulate, but should instead pass a pointer to routines. An example of how using this interface would look like is the following:</p> <pre><code>/* wave_new_file() implicitly allocates memory for the struct */ Wavefile *outputWave = wave_new_file("out.wav", WAVE_mono); int i; for (i = 0; i &lt; MAX_RANDOM_SAMPLES; i++) wave_write(outputWave, rand()); wave_close(outputWave); </code></pre> <p>I realize that the rest of my design could potentially be simplified in the long-run by using an OOP approach, such as in the following pseudo-C++ (since I'm not actually familiar with C++; more on that later):</p> <pre><code>Wavefile *outputWave = new Wavefile("out.wav", WAVE_mono); for (int i = 0; i &lt; MAX_RANDOM_SAMPLES; i++) outputWave-&gt;write(rand()); outputWave-&gt;close(); /* Or delete perhaps? */ </code></pre> <p>The problem with this is that: the rest of my project is written in C99; and I don't actually know C++ (I learned OOP from Python, but am now concentrating on programming in C). </p> <p>Should I: refactor my design to not rely heavily on OOP principals or should I take the time and learn C++ and migrate my entire program to C++? It's not a large program and it <em>is</em> just a hobby project (which explains my reinventing the wheel by making my own .wav writing module). Or should I continue with my pseudo-object-oriented design I currently find myself writing?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload