Urgent.News

What's breaking now, across thousands of outlets.

Tech

Strategy in Java to decouple freight calculation

Autor: Emanuel Antônio Lima Rocha 1 Base fundamental Introdução O Strategy é um padrão comportamental que reúne maneiras alternativas de executar uma operação sob um contrato comum, permitindo escolher a implementação usada pelo contexto. No catálogo de Gamma e colaboradores, ele pertence à categoria dos padrões comportamentais [1]. A separação entre contexto, interface e estratégias concretas…

Translated from Portuguese Read in Portuguese

The article discusses the application of the Strategy design pattern in a Java-based e-commerce system. The pattern allows for the selection of different calculation strategies for shipping costs, such as economic and express shipping. The example code provided demonstrates how the pattern can be implemented, with the `FreteEconomico` and `FreteExpresso` classes implementing the `FreteStrategy` interface.

The `CalculadoraFrete` class acts as the context, delegating the calculation to the chosen strategy. The article also presents a UML diagram and a high-level architecture of the system.

Written by urgent.news from Dev.to's report — not a translation of it. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

I Drew My Worst Work Habit as a Flowchart. It Was a Loop.

Last week I wrote that when a project gets hard and progress feels slow, I take on more work instead of asking for help. I put that in public on a Friday.

  • Reporter's habit of taking on additional work worsened project challenges.
  • Reporter began teaching teammates instead of handling tasks alone.
  • Reporter committed to seeking first to understand before being understood.

Why DNS Had to Exist: The Directory Problem Explained From First Principles

The Directory Problem: Why DNS Was Inevitable Software Laws from First Principles — Investigation 009. This picks up directly from Identity ≠ Location — read that first if you haven't.

  • DNS is the internet's directory to map stable domain names to IP addresses
  • User don't need to remember IP changes, DNS maintains current mappings
  • DNS pattern found in computing for stable identities with changing locations

Linux Mint Keyboard Shortcuts Every Beginner Should Know

When I switched to Linux Mint , I quickly realized something. I was using my mouse... a lot. Coming from Windows, I didn't know which keyboard shortcuts worked, which were different, and which could…

  • Press Super (Windows key) to open menu
  • Use Ctrl + Alt + T to open Terminal
  • Switch apps with Alt + Tab

More from Sunday 13 September →