Tag Info

Hot answers tagged

130

"Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live." (Took it from here) That said: there is no level of »excessive« for code reviews. I'm a newbie programmer working internships and learning a lot from experienced programmers What is more important than writing code is reading code ; read ...


70

Let me quote from Page xxii (Foreword) of "Clean Code" by Robert C. Martin from Prentice Hall. Back in my days working in the Bell Labs Software Production Research organization (Production, indeed!) we had some back-of-the-envelope findings that suggested that consistent indentation style was one of the most statistically significant indicators ...


27

I am very much like your mentor. I treat all code reviews for developers of any experience the same way, even if I wrote the unchanged code I'm complaining about myself. It's no reflection on you or your abilities. Often, the problems with a design are not apparent until you try to modify it. Alternately, a design might have been perfect before the ...


24

The short answer is that the page's client-side Javascript code detects when you get "too close" to the bottom of the page, and asks the server for more data when that happens. Without getting too technical, they are not reloading the entire web page. Instead the Javascript code on that page is requesting more data from the server, then when it receives the ...


21

To tell you a little about myself, I'm a newbie programmer working internships and learning a lot from experienced programmers [...] This sentence it seems to me is the key to the answer. I manage teams of programmers. When I do code review with programmers in general (of good and not so good levels of skill) I will get them to write code to meet or ...


20

One big key to understanding what is happening: It is possible, via Javascript, to set the URL in the addressbar without actually redirecting the user. To see this in action, paste the below code into a supported browser's console. Notice that it changes your address bar to http://programmers.stackexchange.com/yay.html. ...


14

First things first - there is very rarely a single "correct" way to do something in code. So your creativity always matters. That said, there are a whole lot of bad ways to do something in code. Ways that will cause you (or others on your team) issues in the future. Sometimes immediately. So code quality is very important, since poor code quality tends to ...


11

The problem is that a password should appear in plain text as rarely as possible. In your case, the password appears in plain text in an e-mail. This has several drawbacks: If the account of the person is compromised, the hacker gets access to your website as well. If there is a malicious man in the middle, he can access the password with ease. ...


9

Your mentor may be an excellent coder, but... Does he have the authority to review and change all the code? Is he potentially imposing stylistic changes on functional code rather than fixing bugs/preventing dangerous behavior? Are the changes being made backed up by unit tests and/or functional tests? Was there significant unit test coverage before the ...


8

There are two issues here: The issue of your mentor disliking your solution is hard to qualify without concise examples. Maybe if you posted your code, you would find that everybody agrees with your mentor and that you are using the wrong approach (do not worry about it, the fact that mentors exist is the prove that most people need to get some actual ...


6

for the first time feeling like I get close to being competent. I've been programming for over twenty years, and every year I wind up saying that to myself at least once or twice. anything takes a whole lot of time because I have to find the best way to do it or else its a waste of time, it also feels like my creativity doesnt matter because there ...


6

"Done is better than perfect" I hate to break it to you, but code can always be made better, code is never perfect. If you think your code is perfect, you probably haven't looked at it enough yet, or you're no real engineer, as a real engineer can always make things better than they are. (Or, in the programmers lingo, a real hacker can always make things ...


5

Most languages in common use are more powerful and better designed than JavaScript. All the features you mention are supported by other dynamic languages like Python or Ruby which are overall better designed. And some of the features you mention are not necessarily desirable anyway - many would consider static typing with type inference preferable to dynamic ...


5

Inconsistencies make you stop and think why, which and where: When you read part of the code and see that it uses a different style from the rest of the code, it makes you wonder - why is this particular part different? Does it have a special reason that I need to be aware of? This is dangerous, because if there really is a reason for that part to be ...


4

The problem is the global scope. In other words, every change you make affects the whole code base, and yours may in turn be affected in any location of the code base. Imagine that you want to loop through all elements of an array; imagine that browsers don't support it yet. For that, you create a method forEach which is called this way: [5, 7, 1, 1, ...


4

Honestly, there is not much value to it. 1) Most people use their own password that they remember. If they do, then making them change their password will take longer than filling up an extra field during registration. The benefit of your system may be that by then the user is registered so you'll not lose it. 2) If they use a password manager it is ...


4

In JavaScript, a function's signature is not checked when called, so you can call a function of any arity with any number of arguments. arguments is a reserved variable provided to you by the language that holds all the arguments sent to the closest function, so you can get them even if they do not appear in the function's signature: js> function foo() { ...


4

I have encountered this issue several times and have found what I think is the simplest solution. Since your user can edit (personal/account?) information, I assume you have some kind of authentication system up and running. If you use sessions to keep track of recognized clients you can store the user's ID inside it. Then you can fetch the ID from the ...


4

Code Transfer Advantage Following patterns provided by a library, React in your case, means that the product you deliver will be easily picked up and maintained by other developers who are also familiar with React. Potential Backward Compatibility Issues Some libraries would have a new major version out, and backward compatibility might be compromised if ...


2

In order to make this more on-topic, this is a way to go about determining which one is better for a particular situation. Note: you may find that the best solution could change over time as your application's requirements change. Do Both: Sorry, if you want to really find out the best solution, I recomend doing both and comparing your results. This ...


2

You have a mentor! Wow, great first step. At least somebody cares. The thing about writing code is that any idiot can do it. And a lot of idiots do. The difference between idiot code, and good, clean, maintainable, documented code that works well and is easy to maintain... a bit like the difference between chalk and cheese. Things like coding standards, ...


2

Your confusion around tissue = new Tissue(); tissue1 = tissue.load_tissue(2); // tissue1 = 3; tissue2 = tissue.load_tissue(3); // tissue2 = 6 BUT tissue1 = 6 as well. derives from confusion value and object-oriented semantics in your tissue abstraction. This is called 'aliasing'. To find out which one you should use, ask the following question "If two ...


2

You might want to search for Javascript static program analysis tools (like this question), e.g. Flow. You'll find many research papers on that subject. I've heard several talks on that subject, and IIRC eval is used, sometimes carelessly or needlessly, in many practical Javascript software. Your question can be understood in two different ways: How ...


2

Your mentor is taking his role seriously; you should always appreciate that. By holding you to a high standard, he is helping you develop the practices and proficiencies that will serve you well in your career. By pointing out errors made by others, he is helping you better recognize bad code so that yours will more often be better. To become expert at ...


2

First thing is to know the partitions of the number 5 (the team size you want to assembly). There are algorithms to generate the partitions of a number but since the number is small and fixed you don't need to worry about it. The partitions of 5 are: {5}, {4,1}, {3,2}, {3,1,1}, {2,2,1), {2,1,1,1}, and {1,1,1,1,1}. Make 5 lobby lists (L1,L2,L3,L4,L5). One ...


2

Just use an URL with some query parameters, like <a href="user/5?checksum=12345">Edit</a> Of course the checksum is computed, perhaps using some session cookie, and your server code has something to validate it. So if your user is abusing the system by editing the URL (e.g. replacing user/5 by user/567) the checksum should no more be valid. ...


1

Calculate the total rank of all players in a single lobby. Match with other lobby based on that. (+- 1.5 range pretty much) Isn't it as simple as this?


1

Abhi explained on Stack Overflow why you don't want to do it to common objects, but for your own class, that's the way of doing it. So in short, the answer is DEPENDS. When you extend an object, you change its behaviour. Changing the behaviour of an object that will only be used by your own code is fine. But when you change the behaviour of ...


1

Indeed, such fixtures are not a good way to run unit tests. The goal of unit tests is to test a very specific (and often very small) part of the code in isolation from the remaining code and the environment. By making those tests rely on the particular state of the web page, you lose the “unit” aspect of your tests, meaning that you'll rather have system and ...


1

I write this from the perspective of a long-time .NET developer being pulled inexorably into the client-side JavaScript world, so I assume that I probably share some of the same biases as you. I only bring this up because I think a lot of your bullet points are probably biased by your experience and relative comfort with C# and .NET over JavaScript. For ...



Only top voted, non community-wiki answers of a minimum length are eligible