Linked Questions

176
votes
32answers
30k views

Is micro-optimisation important when coding?

I recently asked a question on Stack Overflow to find out why isset() was faster than strlen() in PHP. This raised questions around the importance of readable code and whether performance improvements ...
186
votes
21answers
23k views

A large part of my code has a major design flaw. Finish it off or fix it now? [closed]

I am a high school student working on a C# project with a friend of mine with about the same skill level as me. So far, we have written roughly 3,000 lines of code and 250 lines of test code in a span ...
75
votes
13answers
4k views

When is optimization not premature and therefore not evil?

"Premature optimization is root of all evil" is something almost all of us have heard/read. What I am curious what kind of optimization not premature, i.e. at every stage of software development (high ...
22
votes
6answers
6k views

How do I document my code for minimum time review? [closed]

I want to document my code such that there is minimum need for reading and browsing the code again months later. I know that there are different types of documentation (in source code and outside, ...
26
votes
9answers
2k views

How to deal with misconceptions about “premature optimization is the root of all evil”?

I've encountered many people who are dogmatically against anything which can be considered "optimization" in the general English-language sense of the word, and they very often quote verbatim the (...
13
votes
3answers
402 views

Using static type checking to protect against business errors

I'm big a fan of static type checking. It prevents you from making stupid mistakes like this: // java code Adult a = new Adult(); a.setAge("Roger"); //static type checker would complain a.setName(42)...
14
votes
1answer
611 views

How to prevent a colleague introducing extreme complexity and abstraction?

I am having a very difficult time because my colleague seems to exhibit Premature/Unnecessary optimization efforts Premature deduplication with questionable abstractions For example, we use a ...
1
vote
5answers
628 views

Avoiding exceptions for performance optimization

In our code base, I see a lot of code like this var error = ValidatePhoneNumber(userId, phoneNumber); //if validation fails, return error if(!string.IsNullOrEmpty(error)) { return error; } If I ...
2
votes
3answers
1k views

Is it bad practice for my backend to call 3rd party API's synchronously when processing a request?

I use a third party API on my webapp that is accessed when the user requests a particular ressource. I'm worried that the successive API calls happening upon user's request might cause the user to ...
1
vote
2answers
187 views

Separate methods or single method with if statement?

I'm working on a .NET application and I'm wondering if I should use separate methods to handle the click events of two different buttons. They essentially do the same thing, just on different objects ...
2
votes
3answers
161 views

When defining constants, which is more important? Easier to find? Or narrower scope?

For example, consider I have constants VOL_MIN and VOL_MAX, which is used inside 1 function only: public void setVolume(int val){ final int VOL_MIN = 1; final int VOL_MAX = 10; val=Math....
3
votes
2answers
306 views

Minimizability or readability?

I am authoring a lot of plugins for the content management system that I am writing. I believe it to be of utmost importance that script files (especially if they're plugins) should load quickly, ...
-3
votes
1answer
92 views

Pythonic way of writing `for my_var in my_iterable` [closed]

A very common pattern in python is: for something in ['an', 'iterable']: func(something) I almost always see the iterable as a list (like in this example), but it could very well be a tuple, set,...
2
votes
1answer
81 views

Making use of constant data

My team is working on an android app. A co-worker and I have different ideas on how to load constant data. To clarify, the data we are going to use are 100 × (n × 〈integer-integer pair〉) where 10 &...
1
vote
2answers
47 views

Preload Lookup Values on Startup of Application, or Fetch Them As Necessary?

We have all kinds of Lookups in our application, stored in a separate table, LOOKUP_T. Should the application load them all on startup, and keep them in a global lifecycle variable -- or is it OK to ...