AsiaCel
shalom goyim
★★★★★
- Joined
- Nov 24, 2017
- Posts
- 29,587
Yes, I'm a slopcoder, yes I use AI code. Yes I used to value consistent code styling.
For non-codecels, a listener is a piece of code that fires when something changes. For example: a doorbell code that fires every time the door opens.
On one Android app involving drones, I handle more than 30+ listeners for logging and other purposes, some listeners have very similar purposes but subtle differences, while others are only needed for niche situations.
I will you one concise example; to be honest this isn't the best example, because speed is a variable I need 90% of the times; there are variables I only need for specific scenarios, like monitoring the temperature/camera status.
(this is AI generated code so I don't share my IRL work code)
I found out that one-time get values work horribly especially in looping functions (the delay of result of callback may be slower than loop itself)
(I manage unreal 5, 2x drone apps, command line apps, auth app, and more other apps that I get tasked to work on)
incels.is
Especially when I have heard of a developer colleague telling that he had been cursed at and screamed at by a customer, in person, when the server went down which was nobody's fault (Pretty nice when you have psycho customers, no wonder some colleagues get so upset at fuckups when they have to answer the phone)
I in fact, got pushed to make a feature to "fly around buildings" in ALL BUILDINGS (actually requested; no joke) in the world safety by the customers! I shut him up by referencing Africa's lack of quality building data (lol). Have bro heard of radar clutters? Yeah you're not doing it safety with cameras in urban environment.
More if you're interested :
The "ideal" design pattern is one time get i.e. when you actually need it.
My flight logger logs at about 0.1s; due to the huge amount of listeners I have, I actually find that I'm running the callbacks after the loop is completed and the function runs again.
Perhaps the correct course of action is to just update regardlessly.
The thing is, there are variables like isTakingPic that I don't really need to know whether the value has been changed until I'm on an autopilot (this is useful so if a pic is currently being taken, I don't risk double taking photo which doesn't work)
Instead of adding the isTakingPic listener during a mission, I add it at the beginning when you launch the app; I can just pack all these listeners into the "real time listeners" in the same place, instead of adding and removing them depending on mission status.
The ease of read and maintainability makes this worth it. I'm the sole person working on the two drone apps and I get called every time something goes wrong.
For non-codecels, a listener is a piece of code that fires when something changes. For example: a doorbell code that fires every time the door opens.
On one Android app involving drones, I handle more than 30+ listeners for logging and other purposes, some listeners have very similar purposes but subtle differences, while others are only needed for niche situations.
I will you one concise example; to be honest this isn't the best example, because speed is a variable I need 90% of the times; there are variables I only need for specific scenarios, like monitoring the temperature/camera status.
(this is AI generated code so I don't share my IRL work code)
I found out that one-time get values work horribly especially in looping functions (the delay of result of callback may be slower than loop itself)
There is another way: listen for the speed continiously (the optimal way is to add this code only when you need it and remove it when you don't)public void getDroneSpeed() {
// Create a key for velocity
DJIKey velocityKey = FlightControllerKey.create(FlightControllerKey.VELOCITY);
KeyManager.getInstance().getValue(velocityKey, new GetCallback() {
@Override
public void onSuccess(Object value) {
if (value instanceof Velocity3D) {
Velocity3D velocity = (Velocity3D) value;
double vx = velocity.getX(); // forward/backward speed (m/s)
double vy = velocity.getY(); // left/right speed (m/s)
double vz = velocity.getZ(); // up/down speed (m/s)
double horizontalSpeed = Math.sqrt(vx * vx + vy * vy);
double totalSpeed = Math.sqrt(vx * vx + vy * vy + vz * vz);
System.out.println("Drone Speed: " + totalSpeed + " m/s");
}
}
@Override
public void onFailure(DJIError error) {
System.out.println("Failed to get velocity: " + error.getDescription());
}
});
But because the complicatedness gets on my nerves, I just rig the listeners to constantly update the variables in all situations. I hook these listeners to my Application layer, so no need for cleansing them between activities (think them in pages). Not neat, and probably inefficient, but I don't care. Just download more RAM.KeyManager.getInstance().listen(velocityKey, new KeyListener() {
@Override
public void onValueChange(Object oldValue, Object newValue) {
if (newValue instanceof Velocity3D) {
Velocity3D velocity = (Velocity3D) newValue;
double vx = velocity.getX();
double vy = velocity.getY();
double vz = velocity.getZ();
double totalSpeed = Math.sqrt(vx * vx + vy * vy + vz * vz);
System.out.println("Updated Drone Speed: " + totalSpeed + " m/s");
}
}
});
Managing all this shit is impossible, optimizations make it 80% harder to read for 5% performance gain (in the era of modern CPUs). I don't care anymore; management is throwing me around different apps/domains while being overly ambitious with the features/deadlines. If code quality suffers, so be it.private double vx;
private double vy;
private double vz;
KeyManager.getInstance().listen(velocityKey, new KeyListener() {
@Override
public void onValueChange(Object oldValue, Object newValue) {
if (newValue instanceof Velocity3D) {
Velocity3D velocity = (Velocity3D) newValue;
vx = velocity.getX();
vy = velocity.getY();
vz = velocity.getZ();
}
}
});
(I manage unreal 5, 2x drone apps, command line apps, auth app, and more other apps that I get tasked to work on)
Just realized I have so many apps to maintain
In my company, I created some apps for it specifically, some are meh, some are critical, some can downright kill a person. I maintain all sorts of apps, and add features if I'm asked to. It's fatiguing. I personally wish I could return to the day of specializing in Java spring. I'm only in my...
Especially when I have heard of a developer colleague telling that he had been cursed at and screamed at by a customer, in person, when the server went down which was nobody's fault (Pretty nice when you have psycho customers, no wonder some colleagues get so upset at fuckups when they have to answer the phone)
I in fact, got pushed to make a feature to "fly around buildings" in ALL BUILDINGS (actually requested; no joke) in the world safety by the customers! I shut him up by referencing Africa's lack of quality building data (lol). Have bro heard of radar clutters? Yeah you're not doing it safety with cameras in urban environment.
More if you're interested :
The "ideal" design pattern is one time get i.e. when you actually need it.
My flight logger logs at about 0.1s; due to the huge amount of listeners I have, I actually find that I'm running the callbacks after the loop is completed and the function runs again.
Perhaps the correct course of action is to just update regardlessly.
The thing is, there are variables like isTakingPic that I don't really need to know whether the value has been changed until I'm on an autopilot (this is useful so if a pic is currently being taken, I don't risk double taking photo which doesn't work)
Instead of adding the isTakingPic listener during a mission, I add it at the beginning when you launch the app; I can just pack all these listeners into the "real time listeners" in the same place, instead of adding and removing them depending on mission status.
The ease of read and maintainability makes this worth it. I'm the sole person working on the two drone apps and I get called every time something goes wrong.
Last edited: