Should we include reviewing code generating workproducts?

I posted a question that asked for feedback for optimizing a Simulink Model which is used to generate C code. The question was down-voted and put on hold because there was no code provided in the traditional sense. For those who don't know, C code is auto-generated from the Simulink Model and how you build the Model will greatly affect the performance of the C code.

So, is this a case of uneducated community members down-voting what they don't understand? Or is there a better fit in the SE community for these kind of questions?

• Possibly related: Are Scratch questions okay on Code Review? – Mathieu Guindon May 6 '16 at 16:29
• Does the image include all the details of the model? I've used an entity-relationship modeler that produced similar images. But each element in the diagram also had additional state that was stored in their properties. That information wouldn't show in an image. You'd need the original model file to access that information. Does this work similarly? If the image is compilable code, that's one thing. If the image is a representation of the model but the "code" is actually something else, then that's a different thing. – mdfst13 May 7 '16 at 1:51

There is no rule on Code Review that forbids questions in graphical (rather than textual) programming languages. However, your question, as you have framed it, isn't a Code Review question.

Code Review is for open-ended critique of code that accomplishes a task. On the other hand, you're asking an abstract but very specific question about why Simulink generates crappy code from your model, and how you can force it to generate vectorized code. That's what Stack Overflow calls an MCVE.

If you had written a question like…

I have the following MATLAB code. Each vector has 24 elements. How can I rewrite it for better efficiency? Can it be vectorized?

Converted = Convert(SomeVec7);
DotProduct1 = dot(Converted, LngPwr);
DotProduct2 = dot(Converted, ShrtPwr);
DotProduct3 = dot(Converted, SomeVec3);
DotProduct4 = dot(Converted, SomeVec4);
DotProduct5 = dot(Converted, SomeVec5);
DotProduct6 = dot(Converted, SomeVec6);


… I would have downvoted (and probably closed) it too, for lack of context about what you are trying to accomplish.

Note that the fact that Simulink is a graphical language is irrelevant. Though you asked about a Simulink-to-C translation, the situation would be the same had you asked about the quality of assembly code generated by compiling C++ code.

You could show us more of your Simulink model and explain what you are trying to accomplish, so that we can review the code. Alternatively, you could ask the question in its current form (Rev 5) on Stack Overflow.

• I appreciate the feedback but I will have to disagree with your points here. 1) I am not asking why Simulink generates the crappy (your words) code, i know exactly why its doing what it is doing... what I don't know how to do is make my code (Simulink) more efficient. To me, that is an open ended discussion on how to build something that works more efficiently while completing a task... – Michael Coury May 6 '16 at 19:17
• I really don't see how this question is all that different.... The question is asking about improving the performance of a piece of code. Lastly, I provided an extremely narrow view of what I was doing because everything else is, honestly, superfluous to the original question and would potentially be distracting. – Michael Coury May 6 '16 at 19:17
• As a complete newbiew to the CodeReview SE, I find this entire dissection of how I framed the question to be a little disheartening. I think what continues to be lost in this conversation is that Simulink is a tool that generates C-Code and that tool is completely open ended and that's why peer review is both powerful and interesting to me. – Michael Coury May 6 '16 at 19:18
• At the least, retitle the question to state the purpose of the code, as required by the standards in How to Ask. – 200_success May 6 '16 at 19:27
• Nice - thanks for this. – Michael Coury May 6 '16 at 19:30

To me it looks like "code" that falls in the same category as and other "graphical code" - I actually find this thing more "serious" than , and the community feedback for Scratch has been rather overwhelmingly positive (two answers with total positive score of +26 in favor of it being on-topic, and zero downvotes and/or counter-argumenting answers):

There's no rule against code that is not in textual format. The only tricky rule to comply with is the requirement to embed the code directly in the question itself. If you use the image Stack Exchange imgur hosting service, I think that should satisfy the requirement.

200_success on on-topicness of Scratch

Given a new tag, I don't see why such questions would be off-topic, at least as long as questions are accepted as on-topic.

• The Simulink tag wasn't there before... was it? This I think would help greatly... And I agree... we actually do the overwhelming majority of our coding work in Matlab Simulink and Stateflow.... If there is community interest, there may be a need for a stateflow tag if there isn't one already.... – Michael Coury May 6 '16 at 17:50
• Is it Simulink or Stateflow that's the "graphical" part? Whichever, that's the one that would be relevant to create a new tag for. – Mathieu Guindon May 6 '16 at 17:52
• Both... actually... my question refers to is pure Simulink.... Stateflow is separate (State Machine) toolbox that works within the Simulink environment. Matlab m files, Simulink, Stateflow are all inputs into Embedded Coder and the outputs are generated C files. – Michael Coury May 6 '16 at 17:57
• Would a Simulink tag be meaningful without a Stateflow tag, and vice-versa? I'd like to avoid creating two tags that would have to pretty much always be specified together. I'd also like stronger community input on this meta before going forward with anything. – Mathieu Guindon May 6 '16 at 17:59
• I think you could get away with a simulink tag. if you could have an alias... where simulink, stateflow pointed to the same tag.... when you type in tags, will it suggest others that are close? – Michael Coury May 6 '16 at 18:05
• TBH I'd deem "stateflow" ambiguous and easy to misuse. – Mathieu Guindon May 6 '16 at 18:06
• I agree on that score.. – Michael Coury May 6 '16 at 18:07
• I see no problem with creating a simulink tag, but stateflow is too ambiguous IMO. It's close enough to a language to be on-topic. – Mast May 6 '16 at 18:10

It appears that you are asking how to implement functionality to your code when you say

I have a matlab simulink model with a series of DOT Products that could easily be run through a single For Loop but Embedded coder generates a for loop for each DOT Product. Any insight on getting / forcing embedded coder to combine these activities?

you say that you have a model, and that it could be run through a for loop, than it sounds like you are asking us how to do it.

and then when you said

A small example of the code is provided below:

in your question, that raises figurative flags to all of us, that say that this isn't your real code.

We don't review example code and we won't tell you how to write code, only how to write code better.

if the code you want a review on is in the graphic, then I believe that better description, detail, or wording could have explained this.

Code Reviewers see certain buzz words that tell us it is not actual code and then try to find the actual code, so the process that I went through when I saw the this question was that this was a "how do I write x?" type of question, which is off-topic for code review.

I chose not to vote to close or vote to leave open, because I was not familiar with the languages involved and couldn't tell if the code was, in fact, example code.

• This is good feedback. Thank You. I can certainly be more precise and I will modify the original question after I finish here... To answer your question, it is not an example model. The example code is actually a snippet from the generated code. – Michael Coury May 6 '16 at 17:47