Sometimes I create a solution to a simple problem. However instead of making use of the solution, I keep extending it unnecessarily. This is why for this kind of project, I want to systematically restrain my future self from adding new features beyond the initial vision e.g. by actively refusing generic and re-usable code.

What is the search engine friendly term for this approach or at least for this situation? “Ad-hoc programming” may be literally what I’m talking about, but in practice it’s associated with unplanned happenings.

  • tatterdemalion@programming.dev
    link
    fedilink
    arrow-up
    2
    ·
    3 days ago

    Organizationally, you don’t want your API handler to care about implementation details like database queries. All DB interaction should be abstracted into a separate layer.

    Generally API handlers only care about injecting any “global” dependencies (like a database object), extracting the request payload, and dispatching into some lower-level method.

    None of this requires generic code. It’s just about having a clear separation of concerns, and this can lead to more reusable and testable code.

    • TheV2@programming.devOP
      link
      fedilink
      arrow-up
      0
      ·
      3 days ago

      But I do choose this approach for these problems to not have reusable code on purpose xD I’m not try-harding to rewrite everything for every feature separately, so most of it would be separated and modular, as long as it’s required by the initial purpose of the software. However I avoid writing generic and reusable code that only gets rewarded with functional scalability in mind.

      And unit testing is honestly not on my list for these kinds of projects. At best I’d write integration tests to challenge the route handlers. But simply using the software is sufficient to cover the predictably unpredictable usage in these cases.