
Introducing Go: Build Reliable, Scalable Programs

Do Things that Don't Scale
paulgraham.com
Internal to a car object, though, much more would need to be going on; other things a car would need are a velocity, an orientation, and a position. These attributes would be modified by pressing on the gas or brake pedals and turning the wheel, of course, but the user wouldn’t be able to set the position directly (which would be like warping). You
... See moreChris Pine • Learn to Program
Use nested objects for future extensibility
A follow on from the previous tip: try to logically group fields together. The following:
customer.address = {
line1: "Main Street 123",
city: "San Francisco",
postal_code: "12345"
};
Enter fullscreen mode
Exit fullscreen mode
is much cleaner than:
customer.address_line1 = "Main street 123";
customer.address_city... See more
A follow on from the previous tip: try to logically group fields together. The following:
customer.address = {
line1: "Main Street 123",
city: "San Francisco",
postal_code: "12345"
};
Enter fullscreen mode
Exit fullscreen mode
is much cleaner than:
customer.address_line1 = "Main street 123";
customer.address_city... See more
Common Design Patterns at Stripe
Sometimes these special variables that methods have, like number_of_moos, are called parameters: parameters are the variables that point to arguments. But they aren’t the only kind of variables your methods can have. To help you write clean, encapsulated code, you can also create local variables.