1. Java / Говнокод #27306

    +1

    1. 1
    Class HasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitor

    https://javadoc.io/doc/org.aspectj/aspectjweaver/1.8.10/org/aspectj/weaver/patterns/HasThisTypePatternTriedToSneakInSomeGene ricOrParameterizedTypePatternMatchingStu ffAnywhereVisitor.html

    6oHo6o, 21 Марта 2021

    Комментарии (23)
  2. Java / Говнокод #27258

    +1

    1. 1
    .

    https://vc.ru/flood/149783-podgotovte-nomer-pablik-steytik-dzhava-tochka-pomoshchnik-oleg-zachital-sboy-vo-vremya-testa-v-koll-centre-tinkoff

    3_dar, 17 Февраля 2021

    Комментарии (4)
  3. Java / Говнокод #27228

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    {
        "error": false,
        "message": "Ok",
        "data": {
            "countries": [
                {
                    "country": {
                        "id": 24,
                        "iso_a2": "CA",
                        "name": "Canada",
                        "prefix": "1",
                        "vendors": [
                            1
                        ]
                    },
                    "city": {
                        "id": 3723,
                        "region_id": 8,
                        "name": "Toronto",
                        "prefix": "416",
                        "icon_url": null,
                        "setup": 0.25,
                        "monthly": 1.88
                    }
                },
                {
                    "country": {
                        "id": 51,
                        "iso_a2": "IL",
                        "name": "Israel",
                        "prefix": "972",
                        "vendors": [
                            1
                        ]
                    },
                    "city": {
                        "id": 122,
                        "region_id": null,
                        "name": "Jerusalem",
                        "prefix": "2",
                        "icon_url": null,
                        "setup": 0.25,
                        "monthly": 1.88
                    }
                },
                {
                    "country": {
                        "id": 94,
                        "iso_a2": "GB",
                        "name": "United Kingdom",
                        "prefix": "44",
                        "vendors": [
                            1
                        ]
                    },
                    "city": {
                        "id": 4701,
                        "region_id": null,
                        "name": "London",
                        "prefix": "207",
                        "icon_url": null,
                        "setup": 0.25,
                        "monthly": 1.88
                    }
                },
                {
                    "country": {
                        "id": 95,
                        "iso_a2": "US",
                        "name": "United States",
                        "prefix": "1",
                        "vendors": [
                            1,
                            2
                        ]
                    },
                    "city": {
                        "id": 6400,
                        "region_id": 44,
                        "name": "New York",
                        "prefix": "332",
                        "icon_url": null,
                        "setup": 0.25,
                        "monthly": 1.88
                    }
                }
            ]
        }
    }

    CTO написал апишечку для возврата доступных локейшнов по странам для покупки телефонных номеров

    изыск 2021 я такого и в 2000ых не встречал !!!

    alexis-ag, 01 Февраля 2021

    Комментарии (20)
  4. Java / Говнокод #27197

    −2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    This would raise the true nightmare. A type variable is a different beast than the actual type of a concrete instance. 
    A type variable could resolve to a, e.g. ? extends Comparator<? super Number> to name one (rather simple) example. 
    Providing the necessary meta information would imply that not only object allocation becomes much more expensive, 
    every single method invocation could impose these additional cost, to an even bigger extend as we are now not only 
    talking about the combination of generic classes with actual classes, but also every possible wildcarded combination, 
    even of nested generic types.

    https://stackoverflow.com/a/38060012

    Джавист-долбоеб с пеной у рта защищает type erasure, задавая вопросы "Does it [c#] have an equivalent of Function.identity()? " в комментариях и собирая плюсы таких же поехавших.
    В качестве аргументов он предлагает:

    1) сложна
    2) хранить информацию о типах в рантайме означает что в рантайме придется хранить информацию о типах!!!
    3) [s]ма-те-ма-ти-ка[/x] реф-лек-си-я

    Причем ведь наверняка знает и про темплейты в крестах, и про то что шарп такой хуйней не страдает.

    Fike, 05 Января 2021

    Комментарии (10)
  5. Java / Говнокод #27101

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    package java.util;
    
    public final class Optional<T> {
        public<U> Optional<U> map(Function<? super T, ? extends U> mapper) {
            Objects.requireNonNull(mapper);
            if (!isPresent())
                return empty();
            else {
                return Optional.ofNullable(mapper.apply(value));
            }
        }
    }

    Они не только не знают, что else после if не нужен и лишь привносит лишний нестинг, они даже единый стиль расставления фигурных скобок выдержать не могут

    Fike, 11 Ноября 2020

    Комментарии (8)
  6. Java / Говнокод #27047

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    package java.nio.file;
    
    public final class Files {
        /**
         * Convert a Closeable to a Runnable by converting checked IOException
         * to UncheckedIOException
         */
        private static Runnable asUncheckedRunnable(Closeable c) {
            return () -> {
                try {
                    c.close();
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            };
        }
    }

    стандартные потрошки джавы это какая-то запредельная протомразь, нарушающая собственные законы физики и запрещающая делать это другим

    Fike, 21 Октября 2020

    Комментарии (29)
  7. Java / Говнокод #27044

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    var io = java.io
    var BufferedReader = io.BufferedReader
    var BufferedWriter = io.BufferedWriter
    var InputStreamReader = io.InputStreamReader
    var OutputStreamWriter = io.OutputStreamWriter
    
    var Socket = java.net.Socket
    var socket = new Socket("localhost", 5050)
    var input = new BufferedReader(new InputStreamReader(socket.getInputStream()))
    var output = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
    
    while(true){
      var data = input.readLine()
      console.log(data)
    }

    Один петух написал мне в три часа ночи с прозьбой помочь с кодом

    digitalEugene, 21 Октября 2020

    Комментарии (85)
  8. Java / Говнокод #27041

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    final class Point {
        public final int x;
        public final int y;
    
        public Point(int x, int y) {
            this.x = x;
            this.y = y;
        }
    
        // state-based implementations of equals, hashCode, toString
        // nothing else
    
    }

    is "just" the data (x, y). Its representation is (x, y), its construction protocol accepts an (x, y) pair and stores it directly into the representation,
    it provides unmediated access to that representation, and derives the core Object methods directly from that representation.
    And in the middle, there are grey areas where we're going to have to draw a line.

    Other OO languages have explored compact syntactic forms for modeling data-oriented classes: case classes in Scala, data classes in Kotlin, and record classes in C#.
    These have in common that some or all of the state of a class can be described directly in the class header -- though they vary in their semantics
    (such as constraints on the mutability or accessibility of fields, extensibility of the class, and other restrictions.)

    Committing in the class declaration to at least part of the relationship between state and interface enables suitable defaults to be derived for many common members.
    All of these mechanisms (let's call them "data classes") seek to bring us closer to the goal of being able to define Point as something like:

    record Point(int x, int y) { }

    [u]https://openjdk.java.net/jeps/359
    https://cr.openjdk.java.net/~briangoetz/amber/datum.html[u]

    3.14159265, 19 Октября 2020

    Комментарии (49)
  9. Java / Говнокод #27011

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    [code]
                lengthMapping.put("pt", Float.valueOf(1f));
                // Not sure about 1.3, determined by experiementation.
                lengthMapping.put("px", Float.valueOf(1.3f));
                lengthMapping.put("mm", Float.valueOf(2.83464f));
                lengthMapping.put("cm", Float.valueOf(28.3464f));
                lengthMapping.put("pc", Float.valueOf(12f));
                lengthMapping.put("in", Float.valueOf(72f));
    [/code]

    MAPTbIwKA, 08 Октября 2020

    Комментарии (103)
  10. Java / Говнокод #26991

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    public static <T> Comparator<T> reverseOrder(Comparator<T> cmp) {
        if (cmp == null)
            return reverseOrder();
    
        if (cmp instanceof ReverseComparator2)
            return ((ReverseComparator2<T>)cmp).cmp;
    
        return new ReverseComparator2<>(cmp);
    }

    кишки стандартной библиотеки йажи продолжают радовать, хорошо хоть нет ReverseComparatorFinal или ReverseComparatorBassBoostedByKirillXXL

    Fike, 30 Сентября 2020

    Комментарии (8)