« first day (2425 days earlier)      last day (2576 days later) » 

12:43 AM
hello
I have a doubt for which Internet seems to be poor on answers: What do top programmers do to understand someone else's complicated and illegible code?
 
 
7 hours later…
8:11 AM
36
Q: Techniques to re-factor garbage and maintain sanity?

IncognitoSo I'm sitting down to a nice bowl of c# spaghetti, and need to add something or remove something... but I have challenges everywhere from functions passing arguments that doesn't make sense, someone who doesn't understand data structures abusing strings, redundant variables, some comments are re...

 
 
7 hours later…
3:02 PM
I've already read the info @gnat mentioned before and it is one step further, if it is even a step at all. Sometimes you want to fix a small thing, which is not worth a refactoring; or the refactoring may be too risky! I want to know what they do before to understand. I am sure they have some feedback, that not so good programmers (me included) can benefit from hearing their advice.
 
they read the code
 
3:34 PM
One question about code-design in java:
You have a sorting algorithm (it doesn't matter which one) that sorts specific custom Objects upon specific keys they have. To get a practical example: You have a "Record" class that contains the name of a person, their ID number and their age. Now you *can* have in the class a static fourth variable (SortKeyField) that determines which of these 3 is used as "key" to sort the objects with.
Now your job is to sort these objects. The search algorithm only knows that all objects it shall sort have a method called "less" that allows the comparison of 2 ke
 
ditch that horrible sort algorithm and instead use Collections.sort which can take a Comparator object
there is also Collections.binarySearch which can take the same comparator object if you want to search for the location of an object
or where it should be inserted
 
 
5 hours later…
8:40 PM
@ratchetfreak ^^ that's what I did in the past whenever I had to write some actual code. This though actually is an exercise in "Algorithms in java" that demands me to use a provided search algorithm. I'm basically using this exercise additionally to think about coding structuring as well and trying to learn as much in positioning as I can, since that's one of my largest gaps knowledge-wise
 
 
3 hours later…
11:10 PM
@Isofruit "at the search-algorithm can then use with the "retrieve key" method in the object to get a specific key. My stomach-feeling tells me though that this makes the search-algorithm less independent though, since it needs another variable to be passed to it to function." <--- the object could have two 'less' methods. One of the assumes that the column to sort by is 'key'. And that method doesn't need the extra parameter.
The other 'less' method can take the extra parameter.
Or you could have one less method that takes the extra variable, but if you want to go with the default 'less' then pass null value for the extra variable.
And re your 'idea 2'.. The SortKeyVariable should not be an instance variable in every record.
You can have it as a static variable in the class.
so a class has a list of objects, and a static variable that says which field to sort by.
don't under any circumstance/scenario, let every record have a variable saying which key to sort by.. that makes no sense at all
 

« first day (2425 days earlier)      last day (2576 days later) »