Skip to main content

Questions tagged [clean-code]

The term "clean code" is used to describe computer programming code that is concise, easy to understand, and expresses the programmer's intent clearly. Questions with this tag relate to the process of writing clean code, or refactoring old "dirty" code to be clean code.

5votes
7answers
597views

Why do "protected variables" tend to violate open closed principle?

According to Why is Clean Code suggesting avoiding protected variables?, I know there are tons of reasons to avoid protected variables. However, there is a reason at the currently highest voted answer ...
wcminipgasker2023's user avatar
0votes
2answers
325views

Which is better: a chain of OR statements or IF in a loop? (Java)

Which code style is preferred in Java? final boolean result = isCausedBy(e, ExceptionType1.class) || isCausedBy(e, ExceptionType2.class) || isCausedBy(e, ExceptionType3.class) |...
Andriy Makukha's user avatar
0votes
0answers
63views

Where should validation be placed? [duplicate]

Recently I asked the following question regarding Clean Architecture with some things that were unclear to me: Clean Architecture using interfaces or Mediator approach? I think I have a better ...
developer82's user avatar
2votes
1answer
209views

checkNotNull vs. JEP 358: Helpful NullPointerExceptions: Should we remove existing null checks?

With the introduction of JEP 358 in Java 14, which provides more informative NullPointerException (NPE) messages, is it advisable to remove existing explicit null checks in cases where the null-check ...
ftb457932's user avatar
0votes
1answer
89views

Orchestrating Events & Third Party Services

I am developing a hobby project utilizing an event sourced + event based architecture. In this application, I can allow my users to schedule automated calls in the system. Once the call has been done ...
alaboudi's user avatar
2votes
4answers
172views

Where are random numbers generated in Clean/CQRS architected application

Assume I have a value object in my application with random numbers for underlying values. These value objects will serve as attributes to my entity (aggregate root). In my specific case (just for ...
alaboudi's user avatar
6votes
6answers
768views

doSomethingIfCondition(). Is it good naming? [closed]

Suppose, I have some method that performs some job. In this example, it's going to be void, but it doesn't matter public void doSomething() { // doing something } But then, let's imagine, I got ...
Sergey Zolotarev's user avatar
2votes
1answer
149views

Should I create another API to “move” content or modify my existing API that already does something similar?

I have a Spring Boot REST API that will copy content from one Amazon S3 bucket to another. The source and destination buckets are specified in the body of a POST request sent to the API. This works ...
Space Cadet's user avatar
35votes
10answers
12kviews

Why don't programming languages or IDEs support attaching descriptive metadata to variables?

As developers, we often face the challenge of balancing meaningful variable names with code readability. Long, descriptive names can make code harder to read, while short names may lack context. For ...
Shardul Vikram Singh's user avatar
0votes
0answers
71views

Is it a good idea to have multiple derivations of Presenter (MVP) / View Model (MVVM) of a certain view and supply them externally?

So, I've an iOS project that needed to be revamped and added with a routing / navigation logic between views. We have 3 ways as the entry point of the routing: manually, push notification, and ...
Bawenang Rukmoko Pardian Putra's user avatar
0votes
0answers
90views

Is it really difficult to test these “Service” methods in this Rust Clean Architecture proposal? Is there some other catch I'm not considering?

I reproduced a small example of kerkour's Rust Clean Architecture on the Rust Playground. The code is just an example and the methods code makes no sense at all. This architecture leaks DB information ...
Fred Hors's user avatar
2votes
3answers
199views

Is it still "feature envy" if the state to make decision or the action to take after asking the state involves other classes to participate?

According to https://softwareengineering.stackexchange.com/a/212130/432039, if a class asks another class for the state, and then call methods of that class, it is called "feature envy", eg: ...
wcminipgasker2023's user avatar
5votes
1answer
553views

Confused on how abstraction and encapsulation is helpful

Using assimp I've created a function to load 3D models and it does everything I need and I don't plan to use another library or write something custom, however, I am curious how techniques such as ...
Konjointed's user avatar
3votes
3answers
142views

Is Each Table Columns on Separate Pages Considered Duplication in code?

Each table is on separate pages. Is it considered duplication (written in Angular)? The DevOps team ran SonarQube and detected the th tags as code duplication. How can I explain to them that it's not ...
Shlomi Levi's user avatar
-2votes
1answer
291views

Defining functions inside vs outside a class

Say I have a class with a function do_thing that is comprised of multiple steps, which themselves segregate into functions (first_process and second_process). At what point would this be considered ...
Tim Kirkwood's user avatar

153050per page
close