2,427 karma · joined Jun 15, 2023 (3y ago) · 1,641 submissions
comment 3y ago · link · parent
For example, we wanted to create a Query DTO for our API. It would be a generic class that allowed you to specify the fields you wanted to return in a query, like:
{
include: ["Field", "Foo", "Bar"]
}
You can construct this in typescript like: class Foo {
bar: number | undefined;
foo: string | undefined;
};
class Query<T> {
includes: Array<keyof T> | undefined;
};
And use the query like: let q = new Query<Foo>;
q.includes = ["foo", "baz"]; // fail: "baz" isn't in `keyof Foo`;
But since types are erased at runtime, and typescript classes don't work like ES6 classes (which would actually make a hack to support this kind of runtime validation available), you can't validate through an enum on the field, like: class Query<T> {
@ApiProperty({
enum: keyof T // meaningless at runtime, won't compile
});
includes: Array<keyof T> | undefined;
}
And since Object.keys doesn't work, you can't validate the keys for the object at runtime unless you ditch the generic and just write out the same boilerplate code over and over again with different values for every type you want to be able to query.Typescript was obviously designed to run in a browser, where it originates data, and not on the backend where it receives data, since input validation is such a chore on the backend.
I don't even want a runtime call for `keyof T` like `typeof`; I just want typescript to compile `keyof T` into an expanded array of strings. I would even settle for a C/C++ style preprocessor macro support. There have been times when I wish I could just log the filename of a function in an error using a preprocessor like in C/C++:
cout << "Error in file: " << __FILE__ << endl;comment 3y ago · link · parent
My company issues everyone a macbook, but we're not required to use them. I don't like Apple or its products, so I choose to use a Windows laptop. I have a coworker who uses Ubuntu. IDEs are up to the user, but we have a jetbrains subscription to use all of their IDEs. Only a few of us do Java on the team, but I use VSCode instead of IntelliJ because I don't like Jetbrains UI design. Other people on the team do javascript/node in VSCode, and SQL stuff in datagrip, while I use dbeaver for database stuff.
> How does your tech stack influence how you manage your dev environments
I try to make everything we do runnable locally. We also host almost everything ourselves rather than paying for managed services. Our data collection pipeline can be run in docker so I created a docker compose file which runs all of our microservices together on a network for testing. Since we do Java and Node, the only real consideration about how to make things cross-platform on our different machines is path separators, which I sometimes run into and always patch when I see non-portable paths (/ characters) being used.
None of what we do relies on shell scripts, so we're free to write whatever we want. I use powershell for some helper stuff and other devs use bash, but not much.
> Do you run all production services or a subset?
The only thing we don't run locally is our logging services, since we just print those to the console. Other than that, any service we need to debug can be run locally (though not always all at once)
> Do you have different dev environments for different kinds of work in the same team? E.g., frontend devs don't need breakpoints in the backend but backend devs do.
Frontend devs need breakpoints as much as backend devs do. But again, we keep our dev environments agnostic of everything except for the build tools. Many of my junior engineer coworkers don't even know how to use breakpoints without me holding their hand. I've written launch.json files for my coworkers so they can attach vscode to chrome to debug react, but I've yet to see any of them use them
> Do you use cloud dev environments are have you stuck with local?
Our local machines are far more powerful than the instances we pay for in the cloud, so we prefer to do development locally. It's also easier to test changes real time with hot reloading than it is to re-deploy over and over again, though my boss tends to do just that.
> What is the size of your team / company
50 employees, 8 engineers
comment 3y ago · link · parent
I know the reasons that they don't do this, but I think without that kind of metaprogramming, typescript and node remain poor choices for backend development
comment 3y ago · link · parent
But I go to the comments and there's 150 people who all know every intimate detail of this technology already. Experts in the subject.
I think most of you all are faking it
comment 3y ago · link · parent
comment 3y ago · link · parent
Smaller companies and startups tend to have much faster hiring processes
comment 3y ago · link · parent
There are SO MANY environmental and physiological factors which go into your state of mind. Some variables that I try to control for:
1. What (if anything) did you eat today
2. How much water did you drink
3. Did you shower today
4. How much sleep did you get, or how long have you been awake (probably the most important one right here)
5. What is the warmth of the light where you are working (is it cloudy and rainy outside?)
6. What is the temperature of the room
7. Is anything else going on in your life occupying your mind right now? If you take medication: did you take your medications?
8. Did you exercise today? Do you exercise at all? Are you healthy?
9. How is your posture?
10. Is your work environment clean? Is it noisy?
11. Do you work better with music on, or in silence?
12. Did you drink so much caffeine that you are now manic and can't focus?
13. Are you happy?
The brain is a part of the body
comment 3y ago · link · parent