Last active
November 15, 2025 22:44
-
-
Save mcsee/e8e9c14ecc8a9782c9af326f30cbdd61 to your computer and use it in GitHub Desktop.
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class QueryBuilder { | |
| public String buildEmployeeQuery() { | |
| String sql = "SELECT emp.employee_id, " + | |
| "emp.first_name, emp.last_name, " + | |
| " dept.department_name, " + | |
| "emp.salary " + | |
| "FROM employees emp " + | |
| "JOIN departments dept ON " + | |
| "emp.department_id = " + | |
| "dept.department_id " + | |
| "WHERE emp.salary > ? " + | |
| " AND dept.location = ? " + | |
| "ORDER BY emp.salary DESC"; | |
| return sql; | |
| } | |
| public String buildJsonPayload(String name, int age) { | |
| String json = "{\n" + | |
| " \"name\": \"" + name + "\",\n" + | |
| " \"age\": " + age + ",\n" + | |
| " \"address\": {\n" + | |
| " \"street\": " + | |
| "\"123 Main St\",\n" + | |
| " \"city\": \"New York\"\n" + | |
| " }\n" + | |
| "}"; | |
| return json; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment