top 75 comments

sorted by: hot top controversial new old
[–] 113 points 9 months ago (6 children)

DEVELOPERS, DEVELOPERS, DEVELOPERS, DEVELOPERS!!!!

  • source
  • hideshow 6 child comments
  • [–] 26 points 9 months ago (2 children)

    you missed the best part

    AAAAHHHHRRRRGGGHHHHHHHAAAAAAAA! sweat pouring off balmer as his body goes into shock from the pain

  • source
  • parent
  • hideshow 2 child comments
  • [–] 76 points 9 months ago (15 children)

    Junior devs not abstracting anything and now the app is unmaintainable

  • source
  • hideshow 15 child comments
  • [–] 28 points 9 months ago (9 children)

    Exactly, have fun trying to get test coverage without dependency injection

  • source
  • parent
  • hideshow 9 child comments
  • [–] 9 points 9 months ago (8 children)
    
    with patch("some_file.requests.get", side_effect=SomeException("oh no")):
      result = func_using_requests()
    

    Though not every language makes mocking as easy, and multiple responsibilities in a single function can quickly get messy.

  • source
  • parent
  • hideshow 8 child comments
  • [–] 6 points 9 months ago (5 children)

    Oh I'm fully aware that python lets you cheat dependency injection with patch, its one of the many things python teaches developers to do wrong, which leads them to be unable to use any other language.

  • source
  • parent
  • hideshow 5 child comments
  • [–] 2 points 9 months ago (4 children)

    I vaguely remember Java also has mocking libraries, as does JavaScript. (Though JavaScript isn't a language I'd hold up as the ideal.)

  • source
  • parent
  • hideshow 4 child comments
  • [–] 1 point 9 months ago (3 children)

    While my experience is mostly C++, I assume these mocking libraries are similar in allowing you to create a class that can report it's own usage, and allow for arbitrary returns values and side effects, which is incredibly useful, especially in conjunction with dependency injection.

    What patch lets you do is directly overwrite the functionality of private member functions on the fly, which if Java/JavaScript can do I'd love to know, I thought this was a uniquely Pythonic magic.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 1 point 9 months ago (1 child)

    Javascript has mocking with jest: https://jestjs.io/docs/mock-functions

    There's an example there of mocking our axios (a common library for network requests, a la python requests)

    It's been a long time since I've used java, but mockito exists: https://site.mockito.org/javadoc/current/org/mockito/Mockito.html#2

    (Usage note for anyone unfamiliar, but despite the name java and JavaScript are radically different languages.)

  • source
  • parent
  • hideshow 1 child comment
  • [–] 1 point 9 months ago*

    I feel like there are two concepts be at confused here. 'Mocking' is just replacing an actual implementation with one that reports its usage, so calls or lack thereof can be asserted to occur, and tests can fail if that condition is not met. They usually allow setting side effects and return values on a per call basis also, to inject different behaviours for covering different code paths easily.

    The question is then how do I get a class like DatabaseWrapper to call into an underlying mockDB instead of the normal realDB? The answer, in static languages is dependency injection: the db object must be constructed externally to the wrapper, and passed in in such a way that any object with the same interface is acceptable.

    This allows the tests to pass in a mock with the same interface, and have the class being tested accept it. The class will then run as usual when its methods are called, but we can make assertions about how it uses its dependency. In some languages, such as python (and it seems JavaScript as well) this can be bypassed by monkey-patching the private member dynamically after the object has been constructed to be the mock instead of the real.

    Personally, I don't think this leads to good design. Dependency injection also allows for a nice port and adapter pattern, were in the future we might replace our SQL database with a MongoDB one, and we have to rip up the application, instead of just implementing a new db class that meets the interface, and injecting that into the wrapper instead.

  • source
  • parent
  • [–] 1 point 9 months ago*

    JS is also just as dynamic in this regard. Both JS and Python create and modify objects at runtime and use object fields instead of static definitions of methods or properties. It's probably inherited from Smalltalk.

  • source
  • parent
  • [–] 2 points 9 months ago* (1 child)

    Quickest way to get a test suite so tightly coupled to structure rather than behavior that even just looking at the tests wrong makes them fail. But technically you do get test coverage I guess. Goodhart's law in action.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 1 point 9 months ago

    It's not really that different from like

    
    my_get_mock = Mock(side_effect=Some exception("oh no"))
    result = some_func(http_getter=my_get_mock)
    

    There's many ways of writing bad code and tests, but mocks and patches aren't always a bad tool. But sure, you can definitely fuck things up with them.

  • source
  • parent
  • [–] 10 points 9 months ago (4 children)

    Is it any more maintainable with four levels of abstraction?

  • source
  • parent
  • hideshow 4 child comments
  • [–] 71 points 9 months ago

    Why should I want simplicity? I want to make unnecessarily complex programs to gatekeep those pesky junior programmers.

  • source
  • [–] 34 points 9 months ago* (3 children)

    I started working as a professional programmer in the mid-90s when three-tiered design was all the rage: a data access layer, a business logic layer, and a presentation layer. It seems that nobody actually knew what "business logic" was even supposed to be, because I kept inheriting projects where all the middle tier did was hand data objects from the data layer to the UI. In theory this prevented the UI from being fundamentally bound to the data access, but all three layers were always written in Visual Basic which got kicked to the curb in a few years anyway.

  • source
  • hideshow 3 child comments
  • [–] 7 points 9 months ago (1 child)

    Business logic would be transformations to the data. Like for a spreadsheet, the data layer would handle the reading/writing of files as well as the storage of each cell's content. The business logic layer would handle evaluating each of the formulas in the cells, and the presentation layer draws it on the screen.

    I think the part where it gets confusing is that each of these layers are pretty tightly coupled. The end destination of the presentation layer might change, one might show it on a GUI, another might print it, and another might convert it to pdf or html, but each of those presentation layers needs to understand the data that it is presenting, so it's tightly coupled to the data layer. Same with the businesses logic layer, though it's tightly coupled on both the input and output sides. The design of the data layer constrains the possibilities of the other two, so it's hard to draw a clear boundary between the layers because they all need to know how to walk the same data.

    My mental flow chart for this is more of a data layer in the middle instead of business logic, where business logic is to the side with arrows going both ways between it and data layer, then the presentation layer also accessing the data layer directly, which I suppose is a different permutation of what you described.

    Though another way to look at it does make sense. For a website, think of the database as the data layer, the server scripts as the business logic layer, and the client side scripts/html/css as the presentation layer. That one also follows the layered approach where the presentation layer is talking with the business logic layer.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 34 points 9 months ago (1 child)

    Just got out of a discussion with a supplier. We can do what we needed by connecting to the database. Instead we have to go through four layers of different tech to arrive at the same point in the database otherwise it's not compliant. That the supplier needs to sell a license for those layers is purely coincidental.

  • source
  • hideshow 1 child comment
  • [–] 16 points 9 months ago

    Obviously don't have the full context, but rarely is it ever advisable to give third parties direct access to a database. There are many reasons for this, like, for example, the fact that doing so makes schema migrations practically impossible.

  • source
  • parent
  • [–] 29 points 9 months ago (2 children)

    Abstraction layers is simplicity given a complex enough bottom.

  • source
  • hideshow 2 child comments
  • [–] 20 points 9 months ago* (last edited 9 months ago) (4 children)
  • [–] 16 points 9 months ago (2 children)

    they really made their domain pee rate dot france huh

  • source
  • parent
  • hideshow 2 child comments
  • load more comments (1 reply)
    [–] 15 points 9 months ago* (last edited 9 months ago)

    Me making my devs create a base exception for handling all exceptions that contain messages for display in the UI. Which has a parent base exception we use for all our exceptions which of course has Exception for it's parent.

    I hate our codebase but I'm so close to killing off 15 year old vb.net code. If the left me alone and I had the time I spent in meetings or 20 mins between meetings everything on our roadmap for the next year would have been done 2 years ago.

  • source
  • [–] 14 points 9 months ago (2 children)

    I recently started a new job. We use Java. There's a class that does a few things based on explicit arguments only to decide whether to use an FTP or file output, and you supply all parameters yourself. A whole ass Rube Goldberg machine that could be replaced by a single line of Files.writeString.

    Also, there's a great video on YT "Stop writing classes" that is incredibly relevant.

  • source
  • hideshow 2 child comments
  • [–] 6 points 9 months ago

    Yeah, Java's enforcement of everything must be a class put me off of the language right from the start. I was already used to C++ at that point and hated that I couldn't just write a quick little test function to check something, it needed a bunch of boilerplate to even get started.

    I still think C++ has a great balance between object oriented and sequential programming. Not sure if it's the best, but I can't think of ways to improve on it, other than built in concurrency object stuff (like monitor classes that have built in locks that prevent more than one thread from accessing any of its functions at the same time, basically guaranteeing any code in it has mutual exclusion).

  • source
  • parent
  • [–] 11 points 9 months ago (4 children)

    They look so painfully awkward, like a parent should be telling them to knock it off or something.

  • source
  • hideshow 4 child comments
  • [–] 9 points 9 months ago (2 children)

    If you haven't seen the vid it's 500 levels of awkward cringe that's hard to watch. Had to do with one of the MS version releases. They're acting so awkward you can't tell if they're yakked out in coke or just that socially awkward. Full disclosure I'd be worse than them in that situation, just calling it like it is.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 4 points 9 months ago

    Sometimes tech presentations make me feel really bad for the person giving it. They are up there trying their best but clearly don't have the skills to do more than just communicate information but still try to make their presentation cool and fun and it just falls flat.

    Anyone can be cool, but not everyone can be cool on demand or on stage.

    Though on the other hand, just because a presenter can pull off the cool factor, it doesn't mean what they are presenting is actually cool. The coolness of a presentation has no correlation with the coolness of what is being presented, unless that coolness is just information about the product (though even then, they are probably skipping over the flaws and enshitification).

  • source
  • parent
  • [–] 18 points 9 months ago (5 children)

    Abstraction is not very compatible with concurrency, so as well as your your beautiful abstract API, you also need some 'cut through the layers' functions to return the underlying classes you need to synchronise on. Now you have a right mess that's incredibly hard to understand, infuriating to debug, and impossible to refactor. Best you can do is put another layer of abstraction on top. Repeat every six months.

  • source
  • hideshow 5 child comments
  • [–] 11 points 9 months ago (1 child)

    That's just bad interface... When you design an API as if operations were independent, but they aren’t, you run into these issues.

    Don't add "cut through the lawyers" functions, fix your interface.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 4 points 9 months ago

    Yeah, well-designed abstraction can help enable more concurrency. That said, concurrency isn't easy at any point once there's shared data that needs to be written to during the process. Maybe it's not so bad if your language has good concurrency support (like monitor classes and such that handle most of the locking behind the scenes), but even then, there's subtle pitfalls that can add rare bugs or crashes to your program.

  • source
  • parent
  • [–] 8 points 9 months ago

    Developers developers developers developers

  • source
  • [–] 8 points 9 months ago

    I used to work those corporate jobs, where I'd have to go to these boring conferences, and executives would come out and dance around and do a little comedy show, just to prove that they were just as normal as all the wage slaves, and we were supposed to get all excited and clap and shit. Fuck those losers (the execs, not the workers).

  • source
  • [–] 7 points 9 months ago

    Not a senior dev thing, just a bad dev thing.

  • source
  • [–] 19 points 9 months ago (4 children)

    that image is from the whitest gif of all time

  • source
  • hideshow 4 child comments
  • [–] 6 points 9 months ago

    Can confirm.

  • source
  • [–] 15 points 9 months ago (4 children)

    Always favor composition over inheritance if you can.

  • source
  • hideshow 4 child comments
  • [–] 7 points 9 months ago (3 children)

    All absolute statements are false.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 5 points 9 months ago

    Where we vibe code, we don’t need abstractions!

    Just an inglorious soup of notches and work arounds.

    It’s the ultimate shitty transpiler —> from shitty requirements to crappy architecture by fibbergibberting!

  • source
  • [–] 7 points 9 months ago (2 children)

    yeah, I remember not understanding domain driven design

  • source
  • hideshow 2 child comments
  • [–] 2 points 9 months ago

    "ANYONE SEE THE PENICILLIN?"

    Bill Gates probably

  • source
  • [+] -1 points 9 months ago* (1 child)
  • [–] 0 points 9 months ago (1 child)
  • [–] [S] 6 points 9 months ago

    Don't link to or participate on Lemmy.ml, join the boycott today!

    Cross-posted as part of ongoing boycotting/protest efforts to reduce the influence of .ml comms and indirectly, the instance as a whole, to help vitilize and drive non-.ml comms and make it an easier decision for other instance admins to defederate because of the behavior and attitudes of the .ml instance admins (see megathread link above)

    Some highlights from the link:

    "If you don't support Russia then you just don't understand geopolitics" ~dessalines, main .ml admin, head dev https://lemmy.world/post/27352415

    "See! nobody died IN Tiananmen Square, just AROUND it, so it doesn't count!!" ~ Davel, .ml admin https://lemmy.world/post/30673342

    "NK is actually good and anything counter to that is Western propaganda!" ~dessalines, main .ml admin, head dev https://lemmy.world/post/31595035

    Showing support for Ukraine on .ml is worthy of a site ban - dessalines, main .ml admin, head dev https://lemmy.world/post/32775563

    Nutomics continued transphobia https://lemmy.world/post/29222558

  • source
  • parent