It borrows all the best practices from PostgreSQL the naming of variables and functions are more self-explaining in general.
I also believe that the practices around PRs and code reviews are also good examples.
231–240 of 278 posts
It borrows all the best practices from PostgreSQL the naming of variables and functions are more self-explaining in general.
I also believe that the practices around PRs and code reviews are also good examples.
https://medium.com/@012parth/what-source-code-is-worth-study...
The Windows operating system. Windows is quite an engineering achievement. We didn't prioritize readability or "clean code". All the variables used hungarian notation, so you had horrible names like lpszFileName (lpsz = long pointer to a zero terminated string) or hwndSaveButton (window handle). You also had super long if(SUCCEEDED(hr)) chains that looked like your code was spilling down a staircase. Oh yeah, and pid…
I'm mega curious about this > ...like lpszFileName (lpsz = long pointer to a zero terminated string) I remember those. AIUI hungarian gives you some kind of typing. The typing is done by humans using the names. The humans have to get it right; they are the typecheckers. The first thing I'd do is offload the typechecking onto an automatic framework - the idea of letting people do a computer's job is madness. It would…
[1] https://www.joelonsoftware.com/2005/05/11/making-wrong-code-...
Earlier quoted context omitted.
Second this; Postgres codebase is what got me out of the "good code is self documenting" nonsense. For those of us in the database space it is an incredible resource - and overall a great example of good code. sqlite is much less complex, but similarly approachable. In more recent examples, I think you see a lot of this same reader-centric pragmatic ethos in many Go projects. The Kubernetes codebase comes to mind as…
> Postgres codebase is what got me out of the "good code is self documenting" nonsense. I'm a fervent believer in "good code is self-documenting", so I was curious to be proven wrong, clicked randomly until I found code and I saw this. /* * Round off to MAX_TIMESTAMP_PRECISION decimal places. * Note: this is also used for rounding off intervals. */ #define TS_PREC_INV 1000000.0 #define TSROUND(j) (rint(((double) (j))…
I’m only learning Swift and iOS dev but a fair amount of people recommended me to take a deeper look into Kickstarter for iOS app: https://github.com/kickstarter/ios-oss
Came here to post this. It's got some interesting usage of custom Swift operators to create almost diagrammatic code, like here: https://github.com/kickstarter/ios-oss/blob/master/Kickstart... _ = self.cardholderNameTextField |> formFieldStyle |> cardholderNameTextFieldStyle |> \.accessibilityLabel .~ self.cardholderNameLabel.text And it's the first iOS codebase I've seen that puts test files right next to the files…
Earlier quoted context omitted.
I'm not a PHP dev, but I've dabbled. And I'm not sure I follow. How is it a framework for frameworks sake? I take that to mean it's pointless/not useful. Whereas I'd say Laravel and it's ecosystem are far more productive and time saving than simply using just PHP. It's the opposite of wasting time. From their github repo[0] Laravel has: - Simple, fast routing engine. - Powerful dependency injection container. - Multi…
I'm not fully on board with all of Roberts views but this point about a framework for frameworks sake is one I agree with. https://youtu.be/o_TH-Y78tt4 starting at around 10:30 he gets into what I was getting at. > Whereas I'd say Laravel and it's ecosystem are far more productive and time saving than simply using just PHP. I'm not arguing a time thing. I'm arguing that a framework that forces its architecture onto y…
From the github repo:
“Laravel is a web application framework with expressive, elegant syntax”
Earlier quoted context omitted.
> Postgres codebase is what got me out of the "good code is self documenting" nonsense. I'm a fervent believer in "good code is self-documenting", so I was curious to be proven wrong, clicked randomly until I found code and I saw this. /* * Round off to MAX_TIMESTAMP_PRECISION decimal places. * Note: this is also used for rounding off intervals. */ #define TS_PREC_INV 1000000.0 #define TSROUND(j) (rint(((double) (j))…
I mostly agree with this. Though as I wrote that sentence I realized Go has somewhat softened my position on abbreviations. I think the "note" portion is useful; ultimately a test would stop you breaking that secondary use, but the comment stops you spending time in that direction in the first place. But either way, overall I think you're right this would be fine without a comment. I'm thinking more of examples like…
That does confirm that they are making pretty amazing code. I would have much prefered to get that file instead of the other one :P.
They do have a redundant comment at someplace but it's clearly a tiny minority and they aren't losing any one time.
Suckless tools ( https://suckless.org/ ), clean, efficient, small (easy to know the whole codebase) and very hackable, hackable to the point where even configuration is in code: https://git.suckless.org/dwm/file/config.def.h.html
Earlier quoted context omitted.
> Postgres codebase is what got me out of the "good code is self documenting" nonsense. I'm a fervent believer in "good code is self-documenting", so I was curious to be proven wrong, clicked randomly until I found code and I saw this. /* * Round off to MAX_TIMESTAMP_PRECISION decimal places. * Note: this is also used for rounding off intervals. */ #define TS_PREC_INV 1000000.0 #define TSROUND(j) (rint(((double) (j))…
> If it was named TIMESTAMP_ROUND, I wouldn't need to know "Round off to MAX_TIMESTAMP_PRECISION decimal places." TSROUND is already as obvious as TIMESTAMP_ROUND. TS is a very common abbreviation of timestamp. And you would still need to know the decimal places. The real issue is that it's based on TS_PREC_INV and not MAX_TIMESTAMP_PRECISION as per the comment (though MAX_TIMESTAMP_PRECISION might still agree with t…
Common != universal. It's known up until someone doesn't know it. We have pretty powerful autocompletes, let use them instead, or just lose 3 seconds writing the 10 letters, it won't be so bad.
> And you would still need to know the decimal places.
Sure, by reading the code and understanding what it does and how it does it. You change a constant that will affect that code, it seems fine to see how it's affected either way.
> The real issue is that it's based on TS_PREC_INV and not MAX_TIMESTAMP_PRECISION as per the comment
Which is bound to happen when your documentation isn't the code directly.