SShortSingh.
Back to feed

Strategy Pattern Can Replace Bloated SQL Queries in Role-Based App Search

0
·77 views

A software engineering article on DEV Community argues that complex, role-based SQL search queries should be treated as structured application logic rather than dynamically assembled strings. The piece demonstrates how a legacy approach — appending filters and role conditions to a single StringBuilder method — produces unmaintainable, hard-to-test code that can obscure security boundaries. The author proposes applying the Strategy design pattern twice: one set of strategies governs what data a user is permitted to see based on their role, while another handles the optional search filters a user applies. A companion demo repository illustrates both approaches against the same SQL Server schema, using Spring Boot, Spring JDBC, and Testcontainers for real-database testing. The article covers five distinct user roles with differing visibility rules and ten optional filters, highlighting how the composed approach makes each rule independently addressable and reviewable.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

How to Check Whether a Page's Content Appears in Its Raw HTML for AI Crawlers

A page may look complete in a browser yet deliver little content in its initial HTML, which matters when a crawler does not execute JavaScript the way a browser does. The author advises checking whether the response itself contains the desired content rather than assuming a specific AI system's rendering behavior. Suggested methods include fetching the page with a crawler-style user agent via curl, grepping for known phrases, roughly counting words after stripping tags, and disabling JavaScript in developer tools to compare results. Common patterns that hide content from the first response include client-side fetching, scroll-triggered loading, client-side routing, and JavaScript-injected structured data. The author stresses that these checks are rough diagnostics, that passing them does not guarantee citations or rankings, and that the deployed URL should be re-checked after changes.

0
ProgrammingDEV Community ·

How to Find and Fix the HTTP File Causing WordPress Mixed Content Warnings

WordPress sites served over HTTPS can still lose their padlock or break features when an image, script, or stylesheet loads over plain HTTP, a problem known as mixed content. The guide recommends starting by locating the exact http:// URL in a private browser window, using the developer tools Console and Security panel while checking key pages such as checkout and contact forms. The source of each URL typically falls into one of three groups: the site's own uploads folder, a theme or plugin that builds the address, or a third-party domain pasted into header, footer, or widget code. Owners should confirm that WordPress Address and Site Address both use https:// and can use Site Health to help detect HTTPS support. Built-in link rewriting handles only links to the site's own domain, so third-party resources must be corrected manually at their source.

0
ProgrammingDEV Community ·

Emulation and Reverse Engineering May Be Eroding Gaming's Proprietary Business Model

A DEV Community author argues that barriers protecting proprietary gaming platforms are weakening as emulation improves and reverse engineering becomes cheaper through AI tools. The piece points to the September 2026 Relapse jailbreak, which opens many PlayStation 5 consoles running firmware up to 13.60 to kernel access and custom code. It also cites rapid PS5 emulation progress, with Demon's Souls Remake moving from one or two frames per second to builds exceeding 60 FPS within weeks. The author contends that the traditional model built on expensive hardware, exclusive software, and DRM is nearing a breaking point, though gaming itself will continue. The argument extends an earlier thesis that AI is making much software effectively open source.

0
ProgrammingDEV Community ·

Debugging a Stale noindex Verdict in Google Search Console

A site migration can leave Google Search Console reporting a noindex tag even after the page loads normally. The article advises checking when Google last fetched the URL and comparing that with the response the public server returns today. A noindex directive may appear in either the HTML or the HTTP headers, and an old indexing report can reflect an outdated response. To make the comparison, it provides a Python script, check_noindex.py, which sends a single GET request, stops at redirects, and prints the status, relevant headers, canonical links, and robots meta tags. The author recommends testing the exact URL readers will use, including scheme, host, and trailing slash, and notes that compressed responses must be decoded before the HTML can be inspected.