Deutsch

Правильно программировать

315  1 2 все
Simple Nothing is f*cked29.11.05 14:36
Simple
NEW 29.11.05 14:36 
в ответ Tomasson 28.11.05 22:25
Согласен с Вадимом. Если писать код, который сам себя комментирует, проблем не будет. В отличие от этого:
<---
;-)
#21 
Murr коренной житель29.11.05 15:07
Murr
NEW 29.11.05 15:07 
в ответ Simple 29.11.05 14:36
Some time ago I look for code which was a winner of "Creazy Code" world championship.
A code print out an Article (or Poem)... xmmm... several pages...
But(!) nobody can understand - how. Programm code was 25-30 times shortest that poem.
#22 
scorpi_ скептик29.11.05 15:07
NEW 29.11.05 15:07 
в ответ Simple 29.11.05 14:36
Fowler, "Refactoring"
В ответ на:

Don't worry, we aren't saying that people shouldn't write comments. In our olfactory analogy, comments aren't a bad smell; indeed they are a sweet smell. The reason we mention comments here is that comments often are used as a deodorant. It's surprising how often you look at thickly commented code and notice that the comments are there because the code is bad. Comments lead us to bad code that has all the rotten whiffs we've discussed in the rest of this chapter. Our first action is to remove the bad smells by refactoring. When we're finished, we often find that the comments are superfluous.
If you need a comment to explain what a block of code does, try Extract Method. If the method is already extracted but you still need a comment to explain what it does, use Rename Method. If you need to state some rules about the required state of the system, use Introduce Assertion.
When you feel the need to write a comment, first try to refactor the code so that any comment becomes superfluous. A good time to use a comment is when you don't know what to do. In addition to describing what is going on, comments can indicate areas in which you aren't sure. A comment is a good place to say why you did something. This kind of information helps future modifiers, especially forgetful ones.

I did it my way.
#23 
scorpi_ скептик29.11.05 15:12
29.11.05 15:12 
в ответ Murr 29.11.05 15:07
We are speaking about production code, aren't we?
#24 
Simple Nothing is f*cked29.11.05 15:31
Simple
NEW 29.11.05 15:31 
в ответ scorpi_ 29.11.05 15:12
Yeah, and we speak albanian here ;-)
#25 
Simple Nothing is f*cked29.11.05 15:34
Simple
NEW 29.11.05 15:34 
в ответ Murr 29.11.05 15:07
Ты мне лучше растолкуй, о чем тут поется: http://www.seeklyrics.com/lyrics/David-Bowie/The-Bewlay-Brothers.html ;-)
#26 
Murr коренной житель29.11.05 15:48
Murr
NEW 29.11.05 15:48 
в ответ scorpi_ 29.11.05 15:12
Yes, about code production and code quality.
I give a sample of code, which do somthing and do very good, but which is completely nonunderstandible.
Of course such type of code cann't be maded with another way, but this sample show that Comment for a code is a god option and have to be added to code.
#27 
Murr коренной житель29.11.05 15:51
Murr
NEW 29.11.05 15:51 
в ответ Simple 29.11.05 15:31
Yepp... You may ask Official's about permitions to translit. I asked and have NO from them.
#28 
Murr коренной житель29.11.05 15:55
Murr
NEW 29.11.05 15:55 
в ответ Simple 29.11.05 15:34
Late.
#29 
  Quo Vadis коренной житель29.11.05 22:46
NEW 29.11.05 22:46 
в ответ Simple 29.11.05 14:36
гы...код почти как у меня...
так ради интереса, а что он делает??
поменял в проге то что просили...захотелось ещё кое-чё улучшить..но запутался в конец..
болъше так не буду писать...каждая строчка..отдельный комент..
#30 
Simple Nothing is f*cked29.11.05 22:59
Simple
NEW 29.11.05 22:59 
в ответ Quo Vadis 29.11.05 22:46
А это загадка! ;)
Читай то, что scorpi_ писал - это работает.
#31 
Murr коренной житель29.11.05 23:42
Murr
NEW 29.11.05 23:42 
в ответ Quo Vadis 29.11.05 22:46
Построчный комент - писать почти без толку.
Бо, максимум, что ты там напишешь - тоже самое что и в операторе.
Писать надо большую шапку для каждого модуля/класса и каждой функции/метода.
Описывать настолько полно, чтобы писать код мог другой человек. Тогда - есть
смысл все это делать. А коммент типа - здесь мы к А прибавим Б чтобы получить Ц
Нафиг никому не нужен. Через неделю он не нужен будет и тебе...
#32 
1 2 все