jitterted,
@jitterted@sfba.social avatar

I think one of the biggest shifts over the past year in how I write server-side generated HTML (Thymeleaf + Spring MVC) is trying to completely avoid any decision-making logic (is there any other kind? 😏) in the template, and push all of the logic into the back-end (Controller or DTO).

This may not always be possible, but it does mean that such logic is much easier to test (and therefore test-drive).

Mike Rizzi and I have been live coding a small app where today, we did exactly that. You can see the whole playlist (we're up to 5 episodes) here: https://www.youtube.com/playlist?list=PLBHctPrH7Z2-nyaHBETfklyqddmEZUp95

Join my Discord community to talk about these episodes, #Java coding, design, architecture, #TDD, #DDD, and more: https://ted.dev/discord

itsjoshbruce,
@itsjoshbruce@phpc.social avatar

@jitterted: Good call. I’m finding myself trying to avoid all logic in general.

One of my new favorite software design games is: How can I avoid having to build custom logic for this thing?

No admin panel. No database. Minimal math. Lean heavy on the standard library.

Good times. Far fewer tests (as I try to avoid testing the compiler and other people’s code).

jitterted,
@jitterted@sfba.social avatar

@itsjoshbruce Yeah, especially if tests are difficult to write or maintain (as is often the case with code in an HTML template).

On the other hand, I also want to reduce dependencies.

An example from this project is: do we write a custom Multi-Map (mapping a key to a list of values), or do we pull in a dependency (like Eclipse Collections).

We decided to write it from scratch and it was just a few lines of code (so far), and only needed a few tests.

But overall, the less code (especially code that needs tests, which is code that has logic), the better.

itsjoshbruce,
@itsjoshbruce@phpc.social avatar

@jitterted: Agreed. Especially if you need to parse HTML-based templates. I wrote a library (fully typed - it’s just strings - and tested). Now that rendering is completely PHP-native, so much easier to test and maintain the boundaries, oddly enough.

Curious about this mapping thing. Does it do something the standard library for Java (?? - Spring) not have something that can do that?

jitterted,
@jitterted@sfba.social avatar

@itsjoshbruce The Multi-map is not a built-in collections data structure in the JDK (it's been suggested and shot down as not being of wide enough interest), so that's why we had to decide whether to implement from scratch just what we needed, or pull in a library (like Eclipse Collections).

"Mapping" is one of those overloaded terms, which can get confusing when you're "mapping a map". 😁

itsjoshbruce,
@itsjoshbruce@phpc.social avatar

@jitterted: How many maps could a mapping map map if a mapping map could map maps?

Integer.sum(
Collection.map(maps)
);

It was there, and probably bad Java pseudo code, but I couldn’t resist. lol

Happy new year!

  • All
  • Subscribed
  • Moderated
  • Favorites
  • Java
  • DreamBathrooms
  • ngwrru68w68
  • cubers
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • InstantRegret
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • mdbf
  • tacticalgear
  • JUstTest
  • osvaldo12
  • normalnudes
  • tester
  • cisconetworking
  • everett
  • GTA5RPClips
  • ethstaker
  • anitta
  • Leos
  • provamag3
  • modclub
  • megavids
  • lostlight
  • All magazines