Skip to main content

Questions tagged [language-agnostic]

This tag is for questions that aren't specific to a programming language or environment.

17 votes
8 answers
5k views

When should a function be given an argument vs getting the data itself?

When is it better to pass data to a function in a parameter, and when is it better for the function to just fetch the data itself? Here's some simplified examples in PowerShell: Option 1 (give the ...
Nova's user avatar
  • 181
3 votes
2 answers
484 views

When refactoring many functions that share state in to a single class, how can you avoid writing an "escort" class?

This well-known article criticises Java on the basis that it does not allow you to write functions that do not live in a class. This flaw forces you to write classes with names that look suspiciously ...
J. Mini's user avatar
  • 1,015
4 votes
7 answers
612 views

How can unit tests be atomic in server-dependent CRUD apps?

Suppose that the following are true: You believe that unit tests should be atomic. That is, tests should always test exactly one thing. You have written a CRUD app in a general-purpose language such ...
J. Mini's user avatar
  • 1,015
1 vote
2 answers
1k views

Ordering keyword arguments in a function call

In some languages such as Python, the order of keyword arguments in function calls does not matter. But is there a best practice for it? For instance, suppose that a function's signature is def foo(...
Scarabee's user avatar
  • 121
2 votes
0 answers
119 views

Should the usage of an needlessly mutable type by pointed out in code reviews, even when multi-threading is not a concern? [closed]

None of my team's programs care about multithreading, parallelisation, async, or anything else that benefit from immutability. However, immutability is clearly in fashion at the moment and I'm ...
J. Mini's user avatar
  • 1,015
0 votes
3 answers
2k views

Is it code smell to make an abstract child class override a parent method which only calls its own abstract method

Is it code smell to make an abstract child class implement a method, which overrides a parent method, whose only purpose is to call another abstract method? I want to make sure that anyone who ...
Cave Johnson's user avatar
0 votes
1 answer
201 views

Does a monolithic "main" class make sense?

I'm working on an application that contains a central class, called Engine, made of different sub-modules (classes), where each module is responsible for a specific functionality. Those modules are ...
Ignorant's user avatar
  • 357
38 votes
10 answers
10k views

Why do heavily object-oriented languages avoid having functions as a primitive type?

As has been covered to the point of parody, heavily object-oriented languages, such as C# or Java, tend to lack the feature of having functions as a primitive type. You can argue about whether or not ...
J. Mini's user avatar
  • 1,015
-2 votes
1 answer
2k views

What difference is there, if any, between a KPI and an SLI? [closed]

We are revisiting how we do observability at my organisation, and I'm reading about Service Level Indicators (SLIs) as a way of measuring how our systems are performing. But what I'm struggling to ...
Joe C's user avatar
  • 115
31 votes
9 answers
8k views

Is extracting an interface just for testing purposes a code smell?

I will explain with an hypothetical example. Suppose that my domain is Cars. Everyone around the software, talks about cars. Car is the aggregate root of aggregate roots. For example, CAR table has ...
George Z.'s user avatar
  • 705
4 votes
2 answers
1k views

When modeling requirements, how can I depict class diagram attributes whose allowed values are custom defined and in finite number?

I'm drawing the class diagram that depicts the domain model of a system. This diagram is for requirements analysis purposes so it is completely implementation-agnostic. I want to communicate the ...
cidra's user avatar
  • 363
9 votes
5 answers
1k views

Today I wrote "tests" for the testing code. Was it the right thing? Is it a smell?

My application has big integration with the database. Classes that use the database are very crucial for the system, so I write small unit tests for classes that I call Repository. The reason behind ...
George Z.'s user avatar
  • 705
0 votes
1 answer
163 views

Decoupling data validation from data processing

I'm trying to implement a web service API client using the guidlines i've found in this article: https://www.oreilly.com/library/view/designing-evolvable-web/9781449337919/ch09.html As it comes to my ...
hardhypochondria's user avatar
2 votes
4 answers
980 views

Using a switch statement in place of multiple ORs in an if statement

I was doing a code review today and came across a change that, while it works, "smells" to me. Original code: if(itemStatus.equals(ItemStatus.Preparing)){ orderStatus = OrderStatus....
Kevin's user avatar
  • 374
1 vote
2 answers
219 views

Should selected person be part of my application layer? (MVP pattern)

Consider the following GUI screen: When user selects a person from PersonListView, EditPersonView should show person's first name and last name and allow the user edit. So, I end up with the ...
George Z.'s user avatar
  • 705

15 30 50 per page
1
2 3 4 5
37