When we specify "simple" algorithms (short excerpts from a system) for other programmers to develop, we can come up with some tips on how we would deploy, place or take details that might help or hinder the modularization or generalization of the solution, etc. >
I know that there are techniques, tools, language and methodologies ... But I know that most require culture, standardization, and above all a certain familiarity with Mathematics by the whole team, something almost impossible to imagine no Brasil (!). The question is "Which technique / methodology / framework is most used today to specify critical algorithms?"
NOTES
The bureaucracy (of a somewhat more formal specification) comes at a price, but I'm assuming that I want to pay this price for demanding high reliability (eg banking or hospital applications) and / or performance (eg mobile or real-time devices) of the result.
Naturally, there will be sub-questions (examples),
- "At what level of detail should I stop?";
- "Should I use a second, higher-level language to specify?";
There is a whole branch of Software Engineering to suggest appropriate methods to "express what we want for other programmers" ... And a part of this branch is called theory of formal specifications . There are methods that start from UML diagrams until you reach a stub of the class, method, or function. But the focus on this question is really the algorithm, the tips on how it works or how it should respond to inputs.
All these considerations are theoretical and vague, I think we all need more practical and objective answers to day-to-day decisions with a medium-sized team of developers (without mathematics training).
Context
This jsFiddle shows my experiments with jQuery.makeArray()
, the native functions map()
and reduce()
, and when they are more elegant than a each()
loop or for
common ... It has an HTML context, etc. and even one ( actual question ), so we can use case examples.
Grants for responses and discussions
To more objectively use the jsFiddle quoted , let's say I want to specify the average of the text items in an HTML page.
The specification can be multi-level, from free text to mathematical models ...
- Level-1 (free text): Show in bold the average of red items.
- Level-2 (technical text focused on HTML): Show the average of items
class="m"
in a paragraph below in bold. - Level-3 (technical text assuming jQuery team and prefixed layout): averaging items
$('.m')
assuming integers, putting the result in$('#r1').html()
. > - Level -... : Create routine to average values of
$.makeArray($('.m')).map(function(a){return parseInt(a.innerHTML)})
... - Level-N : create simple routine (light), highly reliable and maximum performance; to make the average of
A=$.makeArray($('.m')).map(function(a){return parseInt(a.innerHTML)})
, that is,A.reduce(function(a, b){return a+b;})/A.length
. Put the result in$('#r1').html()
.