20
senzory
7d

i get so frustrated and pissed when i see people declare a bunch of variables with a "var" keyword

fuck you

use the correct goddamn data type and declare it normally mothfucker

"var" should be banned from programming

intellisense doesnt work for "var" bc it doesnt know wht tf is that variable about

same for Object and dynamic

fuck off

Comments
  • 9
    var senzory = "mad";
  • 9
    @Frederick clearly a string
  • 7
    var senzory = "avoid kotlin"
  • 1
    @gruff That was the joke.
  • 9
    Isn't there an advantage in terms of readability when using var rather than explicitly declaring type?

    The compiler doesn't care since it'll still compile into identical intermediate language. It makes more sense to reduce the repeating type declaration and it's easier to read in my opinion:

    var test = new CustomerOrder(test2) than
    CustomerOrder test = new CustomerOrder(test2)

    But I guess in the end it's down to preference and adapting to whatever standards have been set in your workplace since the actual code is identical in functionality.
  • 3
    I think it makes pretty sense to use it when you retrieve an object that has already be declared with a datatype.
    Ex. in pseudo code :

    var myName = me.getName();

    Me {
    private String name = “Lulz”;
    }
  • 7
    I prefer using `let` and `const`
  • 0
    @Root I might try it on a c# project but I’m not sure it’ll work
  • 3
    Then IntelliSense is just fucking bullshit. We had val/var for a long time in Kotlin, and got it in Java too. All of the three big IDEs are able to understand what type a variable is. That's why they're named IDE, not text editor.
  • 0
    I use 'var' when I don't know what the data type is while I'm debugging.

    I then change it to the correct type when I've found out what is returned.

    If you treat 'var' as a tool for when you're glassboxing, it's really useful, but duck typing isn't the best technique to rely on as a go-to approach.
  • 0
    @oudalally im talking about those who name every single variable as VAR and leave it that way
  • 0
    @senzory Yeah, they are wrong and should be stopped!
  • 1
    Where does this happen to you?

    I never faced issues using:

    1. var (Swift, Kotlin, JS)

    2. let (Swift)

    3. val (Kotlin)

    4. const (JS)

    Though I do hate JS because I have not yet found a good editor for it, VS Code does cover a lot of auto complete stuff, but when dealing with multiple files it just doesn't continue :\
  • 1
    @gitpush same with python :(
  • 0
    @senzory I really hate it, sometimes I waste hours when it is a simple typo, mistake ...etc.

    Or I go back and forth between files because I cannot remember the props I used earlier and need to make sure I don't do a mistake
  • 1
    @senzory var is and was fine in C#. Intellisense works fine to..
  • 5
    I think your intellisense might be broken my dude. Var is great, especially for long and complicated type names.
  • 0
    I love var for most things, except when I need to learn a new method and I'm reading about it. Even then, I can just look it up real quick in the ide.

    Go Java 10!
Your Job Suck?
Get a Better Job
Add Comment