Complexity is more apparent to readers than writers. If you write a piece of code and it seems simple to you, but other people think it is complex, then it is complex. When you find yourself in situations like this, it’s worth probing the other developers to find out why the code seems complex to them; there are probably some interesting lessons to learn from the disconnect between your opinion and theirs. Your job as a developer is not just to create code that you can work with easily, but to create code that others can also work with easily.
"Obvious" is in the mind of the reader: it’s easier to notice that someone else’s code is nonobvious than to see problems with your own code. Thus, the best way to determine the obviousness of code is through code reviews. If someone reading your code says it’s not obvious, then it’s not obvious, no matter how clear it may seem to you. By trying to understand what made the code nonobvious, you will learn how to write better code in the future.
A Philosophy of Software Design, John Ousterhout
Complexity is more apparent to readers than writers. If you write a piece of code and it seems simple to you, but other people think it is complex, then it is complex. When you find yourself in situations like this, it’s worth probing the other developers to find out why the code seems complex to them; there are probably some interesting lessons to learn from the disconnect between your opinion and theirs. Your job as a developer is not just to create code that you can work with easily, but to create code that others can also work with easily.
"Obvious" is in the mind of the reader: it’s easier to notice that someone else’s code is nonobvious than to see problems with your own code. Thus, the best way to determine the obviousness of code is through code reviews. If someone reading your code says it’s not obvious, then it’s not obvious, no matter how clear it may seem to you. By trying to understand what made the code nonobvious, you will learn how to write better code in the future.
A Philosophy of Software Design, John Ousterhout
Complexity is more apparent to readers than writers. If you write a piece of code and it seems simple to you, but other people think it is complex, then it is complex.
"Obvious" is in the mind of the reader: it’s easier to notice that someone else’s code is nonobvious than to see problems with your own code. If someone reading your code says it’s not obvious, then it’s not obvious, no matter how clear it may seem to you.
A Philosophy of Software Design, John Ousterhout
I read your code. I revised your code to be simpler and more obvious. It provides a simple, obvious replacement for csv.Reader
Read
method.
I read your code. I revised your code to be simpler and more obvious. It provides a simple, obvious replacement for csv.Reader
.
I read your code. I revised your code to be simpler and more obvious. It provides a simple, obvious replacement for csv.Reader
Read
method.
If we want a complete replacement for csv.Reader
then we can add the remaining csv.Reader
methods as pass-through wrappers.
func (hr *HeaderReader) FieldPos(field int) (line, column int) {
return hr.cr.FieldPos(field)
}
func (hr *HeaderReader) InputOffset() int64 {
return hr.cr.InputOffset()
}
func (hr *HeaderReader) ReadAll() (records [][]string, err error) {
return hr.cr.ReadAll()
}
If we want a complete replacement for csv.Reader
then we can add the remaining csv.Reader
methods as pass-through wrappers.
func (hr *HeaderReader) FieldPos(field int) (line, column int) {
return hr.cr.FieldPos(field)
}
func (hr *HeaderReader) InputOffset() int64 {
return hr.cr.InputOffset()
}
func (hr *HeaderReader) ReadAll() (records [][]string, err error) {
return hr.cr.ReadAll()
}