2
Maybe this question sounds broad but deep down it is not, I am not graduated in anything so I only have bad practices on my back and wanted to learn to program in a way not only "standard" and yes clear and clean.
Programming standards with safety and simplicity
See, when I say programming patterns, I mean how to write code in a healthy and simple way... Reading and researching I found some tips that may help, such are:
- Write variables in a short descriptive manner and following the "camel hump model" Ex:
$userBrowser = $_SERVER...
- Comment on code, but make brief and descriptive comments for future maintenance
- Being simplistic when it comes to making it happen, I mean, making the code the easy way without losing efficiency
I met these three, they must have others.. If you know other cite at most 3 not listed above...
and security, where you enter?
Well, I have little tic with security, fear maybe and as always I am programming on the server side (ex: PHP) and the customer (ex: JS) I am extremely concerned about that. Security is a very broad subject, so let’s summarize in "programming security", I don’t know exactly how to name what I will say but look at this situation:
this example is extremely metaphorical for explanatory purposes.
Suppose 10 different dogs are arranged in an array.
A while will item this array and play each item, dog, in a function to verify the attributes of the animal.
while....
checaAtributos(cachorro)....
....
the function checaAtributos
does that:
function checaAtributos(cachorro) {
if(cachorro.lenght == 0) // verifica se a variável cachorro está vazia...
var corDosOlhos = checaCorDosOlhos(cachorro);
....
in function checaCorDosOlhos
I will need to check again if the variable cachorro
is empty? It is necessary?
In short: once checked certain parameters I will have to check them again if I pass from one function to another?
I think that’s it, if you have anything else to add I’ll be grateful
I didn’t quite understand your question. Is it related to any specific paradigm (object-oriented, procedural)? It got confused also what exactly you refer to safely. I have a very different understanding from the one exposed in the example.
– gmsantos
@gmsantos Hi, it would be in general same, without being specific. I put the word "security" but I’m not sure if that word is the right one to use. That’s why I created that little example. Lay out your understanding for me to explain..
– Elaine
I think that here has a good starting point. Edit: this for example is excellent, maybe even a duplicate of this... But the question is good, I gave +1 and I hope good answers appear (and now I saw that it is specific about javascript, legal)...
– gustavox
@gustavox this "article" is very good, opened my mind.. now it remains for me to wait on the other point of my question.. Thank you!
– Elaine
Look for books, clean code, pragmatic programmer, code complete, how to be a good programmer and the art of writing readable programs they have dozens of these kinds of tips.
– rray
Simply too broad, because talking about good practice is one thing, and security is another, however small approaches they may be, but they are too broad because they have too many points to pay attention to, because sometimes it is difficult to explain one part without having to explain another. I advise you to look for the google, here are also some questions already answered that maybe show you the way to start focusing.
– Edilson
impossible to answer here... An answer would fit in a book and would still have a lot of basis in opinions, specific concepts, etc. Or it would be something vague, superficially addressing several concepts...
– Daniel Omine
all right.. ....
– Elaine