Skip to main content
Filter by
Sorted by
Tagged with
1 vote
2 answers
50 views

Basically, I'm asking for a way to optimize this code. I'd like to cut it down to a few lines because it does the same thing for every click bind. $("#arch-of-triumph-button").click(function(){ ...
Vlad Solomon's user avatar
5 votes
1 answer
5k views

I'm new in DDD and I am getting an issue while writing a new project using DDD principles and it's about creating domain services. I always named my services with the corresponding domain object name ...
Matheus Andrade's user avatar
2 votes
2 answers
4k views

I'm writing my homework and I found piece of code I don't think is elegant enought.. Exactly : if n >= min && n <= max then ... else ... I want to ask if there is any more ...
Patrik Bašo's user avatar
-2 votes
2 answers
52 views

What is more important readability or speed? Example: Say you create a lot of resources in one method and if some operation fails you have to free the ones which were successfully created. Would you ...
J. Doe's user avatar
  • 17
0 votes
3 answers
1k views

I'm familiar with the patterns that are used to clean up subscriptions on observables as outlined here: Angular/RxJs When should I unsubscribe from Subscription But is there a similar pattern for ...
Jeff Mercado's user avatar
1 vote
0 answers
58 views

In this example, I will be using 2 files ( LogService and LoggedConflictException ). I would like to inject LogService into LoggedConflictException class, instead of passing it via the constructor or ...
Omega's user avatar
  • 75
1 vote
3 answers
511 views

I came across a question on StackOverflow: Swift - Convert Array to Dictionary where the user wants to take the elements of an array and wants to put them in a dictionary and assign 0 to each of them. ...
tiw's user avatar
  • 575
4 votes
0 answers
849 views

We are using SonarQube Server for a big java application. (IDE = Eclipse + SonarLint plugin). Rule Private fields only used as local variables in methods should become local variables is violated in ...
actunderdc's user avatar
  • 1,478
0 votes
0 answers
291 views

We have used few global variables which are not camel case. Ex. lang_code. We can not make this variable camel case. I know there are ways to avoid checking camel case at file level and function ...
Yuvraj Patil's user avatar
  • 8,860
0 votes
2 answers
142 views

I'm opening a file to read your data, but I think the code is too big, would you have it smaller or cleaner? Private Function HeaderValidation(workbook As Workbook, nameInstitution As ...
Gustavo Moraes's user avatar
0 votes
2 answers
133 views

If I call method makeDinner(), and this method has submethods prepareTomatoes() and prepareMeat(), should I a) call them both from makeDinner() or b) call prepareTomatoes() and at the end of that ...
user avatar
2 votes
0 answers
75 views

I have about 20 lists that I'm appending to in each iteration of a loop if some checks are passed. The appended values come from a nested dictionary and as you can imagine, writing these one by one ...
C.Acarbay's user avatar
  • 444
1 vote
0 answers
1k views

We have this service that needs some special file permissions and we are therefor running the service within his own virtual service account: The service exe is installed using installutil.exe c:\...
Tiele Declercq's user avatar
0 votes
1 answer
55 views

I am learning Vue.js and I am setting up a website where I am using LocalStorage to store data. I wrote some code, which is a little clunky and very repetitive: <script> const app = new Vue({ ...
Mxkert's user avatar
  • 356
-1 votes
2 answers
44 views

I want to learn how to clean my code up and I feel like the reverse string function can be turned into a variable. Is this possible? function reverseString(str) { return str.split('').reduce((...
Nellz's user avatar
  • 29
1 vote
1 answer
854 views

I want to use multiprocessing to run simultaneously several processes of a series of lengthy actions (e.g. clicking through programs simultaneously using computer vision). I want to implement a stop ...
Jason Tan's user avatar
1 vote
2 answers
1k views

I am trying to clean up a static function. Let me provide a template of this function here. It is a static function and is used only in two places in the code base one where the isClient is true and ...
Riyafa Abdul Hameed's user avatar
1 vote
1 answer
686 views

i am trying to cleanup the file with phpcs --standard=Wordpress ../filename.php . But it seems phpcbf is unable to perform the action. So, can anyone share some help as how can i manually fix these ...
dignustech's user avatar
-1 votes
2 answers
1k views

Software Environment Details: Visual Studio 2017 .NET Framework 4.5 We have a WCF Service and WCF Client Library C# library. In order to adhere to proper coding practices, I want the WCFService that ...
crazyTech's user avatar
  • 1,517
0 votes
2 answers
543 views

I made this Basic C# Calculator to reflect on what I've learned these past few days. I'm an absolute beginner and I wanted to get suggestions on improving and shortening it. I've tried to add switch ...
AhmadDaPenguinz's user avatar
0 votes
4 answers
88 views

I want to check whether some strings and their lowercase variants can be found inside another,but my code seems pointlessly complex. this works, but I want to know whether a cleaner variant exists: ...
rhetoricalRTRT's user avatar
0 votes
1 answer
110 views

In my Python Code, I would also like Dakota with Hurricane, display appearances to show, in the Data Table, when run in Jupyter Notebook. I typed the following modification to the Code, aiming to ...
Edward Winch's user avatar
0 votes
2 answers
2k views

I am working with Unity Engine where there is a base class Component and multiple classes deriving from it, including Transform, MeshRenderer and many classes created by me. I want to execute an ...
Rasmond's user avatar
  • 512
1 vote
2 answers
855 views

I try to be careful about SOLID and clean code principles. I think I fall into side effect error. When I trigger a method it must get data from another service and insert to database: //when I call ...
Mustafa Çağatay Kızıltan's user avatar
0 votes
0 answers
35 views

First question here (I mean like ever), so sorry if I posted at the wrong section or haven't found an already given answer. I have 2 arrays of objects. The first one, lets call it oldArray has 1000 ...
ArchAnarchist's user avatar
2 votes
5 answers
255 views

I am trying to make my code "cleaner". I have many functions with a lot of if-statements. How can I replace them? I'm using 4 differents Hashtables that's why I have those ifs. The only thing ...
Kazh's user avatar
  • 35
0 votes
2 answers
797 views

I have a script that I have almost 100% complete however there is just one more step that I can not figure out. My script currently checks the destination to see if the file already exists and if it ...
TheMuellTrain's user avatar
3 votes
1 answer
2k views

When I open Configure Code Cleanup in VS 2019, there are entries like "Apply expression/block body preferences". Where are those "preferences"? How can I configure this tool?
Spook's user avatar
  • 26.2k
0 votes
1 answer
183 views

So I have this long stretch of c# code (forgive me im a beginner and its messy) but I basically want to repeat all the steps but also output the text to result to a file if "-o" & a filename (...
Benjamin Rogers's user avatar
-1 votes
1 answer
904 views

Suffering insomnia at 5am & so reading Clean Code (by Robert Martin). This book is often seen as a Bible for coding structure and so I was interested to see he suggests the 'Newspaper' analogy ...
Charlie S's user avatar
  • 4,671
2 votes
0 answers
101 views

I am using a function with multiple return paths. But on every one of them I need to clean the memory,release some objects,etc. I have seen on the internet some methods but I don't think they are "...
sergiu reznicencu's user avatar
4 votes
2 answers
820 views

I have the below code to write. It is taking one kind of enum type and return other enum value. How to remove the too much if else condition in the code and make it clean? private static QuestionType ...
Ishant Gaurav's user avatar
4 votes
2 answers
5k views

I'm looking for a cleaner way on how to create a conditional flatMap(), I've read this but I'm having trouble applying it on my code: // given variables for the sake of simplicity val stringSingle = ...
Tenten Ponce's user avatar
  • 2,526
2 votes
1 answer
94 views

I'm not too sure one correct terms for using TypeScript. But I feel like I'm repeating myself and would like to template my interface better so be less confusing. I've got a type which is basically a ...
Barry Michael Doyle's user avatar
0 votes
2 answers
2k views

I'm trying to convert my nested for loop to asSequence in Kotlin. Here, my goal is to get and update the value of all my object array from another object array with the same key. nested for loop: ...
Tenten Ponce's user avatar
  • 2,526
2 votes
1 answer
326 views

I want to save some files of an article which are posted to an ASP.NET MVC Core action. Then i have them as IFormFile in HttpContext. These files can be image, video, and document. Each of these file ...
Boolood's user avatar
  • 89
19 votes
2 answers
7k views

Our team want to enforce styling rules in our C# project. I read somewhere some time that Microsoft said that ".editorconfig is the future" so we want to use this. NOTE: We don't want to use ReSharper....
Totty's user avatar
  • 277
0 votes
1 answer
248 views

Most of the place I found use polymorphism instead of Switch case statement. I know it is better to use polymorphism if all the case are different in switch case. what happen if few cases have same ...
Yash's user avatar
  • 9
1 vote
0 answers
84 views

For example, the following code gets very lengthy. I then have to pass these each into their relevant functions. The benefit here is that I can easily specify defaults all in one place (for me the ...
kmfsousa's user avatar
  • 233
1 vote
2 answers
1k views

From PHP 7.0 it is possible to set the return type in the functions. But you cannot force it as the void return type is not supported by the language and it would be difficult by the static analysis ...
Xavi Montero's user avatar
  • 11.1k
3 votes
1 answer
4k views

I have read about transform method on Try and compare this method with other methods to figure out which one will be more clear for coding. I show you the code below val value: Try[Int] = Try("1"....
Wilson Ho's user avatar
  • 372
0 votes
1 answer
218 views

I've got a lot of code that is segmented into separate lines in netbeans. I believe it's auto formatting it and when I change any formatting in the editor options it seems to not like it. An example ...
DotSlashShell's user avatar
0 votes
0 answers
87 views

I've just read the book called clean code. The author Uncle Bob talks about a single responsibility that a function should have in a program. It should only do one thing. Now, I would like to ...
Azuk's user avatar
  • 11
-1 votes
1 answer
186 views

I think I might answer my own question here but lets say I understand the SRP on the method level to mean that a method serves one role. If I have methods that each individually cover one specific ...
Anden's user avatar
  • 43
0 votes
1 answer
34 views

I'm looking for a tool that helps me to identify CSS color properties (color, background-color, border-color etc.) and combined the selectors instead of repeating the color property over and over. so ...
Gabriela's user avatar
2 votes
3 answers
134 views

Let's suppose we have an if statement like this: public A save(A a) { if (isValid.test(a)) { return aRepository.save(a); } throw new ANotValidException("A is not valid"); } ...
lyancsie's user avatar
  • 678
-2 votes
3 answers
64 views

How to improve the following if conditional in Python 3.6 to one line. def run_cmd(beta: bool): { cmd = "cloud create {}".format(self.name) if beta: cmd = "cloud beta create {}".format(self....
gogasca's user avatar
  • 10.1k
2 votes
0 answers
45 views

I have an interface with its implementation. The public interface methods are using many private methods for doing calculations: public class FooServiceImpl implements FooService { @Override ...
olivergregorius's user avatar
0 votes
1 answer
259 views

There is a system composed of an ASP.NET web application, .NET windows services and shared .NET libraries. It has large number of classes, each containing multiple methods. How to conveniently ...
PanLukasz's user avatar
0 votes
2 answers
4k views

I am setting up some values in a nested JSON. In the JSON, it is not necessary that the keys would always be present. My sample code looks like below. if 'key' not in data: data['key'] = {} if '...
Manthan Jamdagni's user avatar

1
3 4
5
6 7
13