Skip to main content

Questions tagged [static-methods]

4 votes
1 answer
1k views

My job uses SonarQube as part of the CI/CD quality gate. One of the "Maintainability" issues (severity: medium) raised is the CA-1822: Mark members as static. The link explains the added ...
Veverke's user avatar
  • 541
2 votes
2 answers
316 views

Apache Commons has StringUtils. It's great, but I wish it had a shuffle() method or similar Is it ok to create my own StringUtils that extends Apache's StringUtils and adds the method (Apache's class ...
Sergey Zolotarev's user avatar
1 vote
4 answers
1k views

I know you can't inherit static methods, and it seems the consensus is that if you feel like you need to, you're doing something wrong. However, I don't know what the alternative is in my case. Please ...
Andrew's user avatar
  • 21
0 votes
6 answers
1k views

I have to create custom buttons but in order to encapsulate the logic of button creation I've this class (VB.net): Public Class ButtonCreator Public Shared Function CreateBaseButton(Optional ...
Mateo Ezequiel Bertogliati's user avatar
0 votes
1 answer
311 views

See "Note" on second page: This convenience gave rise to serious inconsistencies and was removed several years ago The book was authored in 2003. What exactly does it mean by "Serious ...
Anon's user avatar
  • 3,649
0 votes
1 answer
1k views

I've already read this carefully, but still need more clarification. I'm not new to dependency injection, but new to Hilt, and trying to implement Hilt in my multi-module app. The reason? I currently ...
Diego Perez's user avatar
2 votes
1 answer
1k views

I have a value object to hold a user id number as a string. This number has a unique format throughout my domain. So, it's being validated inside the object during instantiation and an exception is ...
Pavi's user avatar
  • 131
1 vote
4 answers
1k views

I have a service class that performs some operations. One of the operations is a piece of code long enough to warrant extracting to a new class and unit test it in isolation: @Service public class ...
KidCrippler's user avatar
1 vote
2 answers
627 views

I am designing a test for an existing static method: public static boolean hasPermissions(String username, int pageid) { PermissionsService s = new PermissionsService(); int[] pages = s....
Zort's user avatar
  • 31
4 votes
1 answer
5k views

A very straightforward question. When I think about many of the member functions I create for my classes, many of them can be made static without affecting any functionality whatsoever. If I do so; ...
Anon's user avatar
  • 3,649
-5 votes
1 answer
117 views

Assume there's some code that's already in production that needs some unit testing. Generally speaking, would you want to refactor this code that's already in production by adding things like adding ...
JobHunter69's user avatar
0 votes
3 answers
258 views

I have a class which has the purpose of providing file operations i.e. providing functionality to create the file, read, write and rewrite to the file. So, the main constituent of the class is ...
Navjot Singh's user avatar
9 votes
4 answers
7k views

Let's assume I wrote an extension method in C# for byte arrays which encodes them into hex strings, as follows: public static class Extensions { public static string ToHex(this byte[] binary) ...
Akira's user avatar
  • 257
2 votes
1 answer
233 views

I had a simple static method which would take a value and a unit type (pounds, gallons, dollars) and would just format a string. A simplified example: public static string Format(decimal value, ...
user1242967's user avatar
-2 votes
1 answer
939 views

Is it a good practice to use the static member methods to check if an object of a class is NULL or not. The object would be sent through the parameters offcourse. Something like, #include <...
Haris's user avatar
  • 105

15 30 50 per page
1
2 3 4 5
7