• 37 Posts
  • 1.22K Comments
Joined 1 year ago
cake
Cake day: June 14th, 2023

help-circle
  • flashgnash@lemm.eetoProgrammer Humor@lemmy.mlComenting code
    link
    fedilink
    arrow-up
    6
    ·
    edit-2
    58 minutes ago

    “tells the user the current time” would be an excellent comment for a clock

    I’m not the best at commenting my code, but generally I just try to think of what information I’d want to know if looking at this 10 years from now

    Imo comments are best used sparingly, don’t bother commenting something that anyone with a basic understanding of programming would understand straight away by reading the code

    Functions should generally be commented with what parameters are and what they’re for, plus what they output

    use reqwest::Client;
    
    // create a http client class that all other files can import 
    // so as to only create one instance globally 
    
    pub struct HttpClient {
        client: Client,
    
    }
    impl HttpClient {
            pub fn new() -> Self {
                HttpClient {
                    client: Client::new(),
                }
            }
    
            pub fn client(&self) -> &Client {
                &self.client
    
            }
    
    }
    

    Here’s an example where if I were to stumble onto this file 10 years from now, I might think wtf is this looking at it out of context, the comment explains why it exists and what it’s used for

    (we’ll ignore the fact I totally didn’t just add this comment because I suck at commenting personal projects)












  • Not exactly what you’re asking for but you should look into tiling window managers, if I’m understanding correctly they do almost exactly what you want

    For example on my laptop if I open Firefox it opens in full screen, if I open a terminal it resizes Firefox to half the screen and opens the terminal in the other half, a third and it splits whichever window I’m focused on vertically etc etc

    You could achieve what you want by having the VMs in windowed mode and just using a tiling wm

    You get the added bonus of virtual desktops that you can flick through with mouse buttons/keybinds/3 finger swipe if you want multiple layouts of different windows

    Also I’ve not used it but I’m pretty sure hyprland has something called fake full screen where it tricks windows into thinking they’re full screen while actually being windowed