18

Generally speaking, what type of optimizations do you typically slant yourself towards when designing software?

Are you the type that prefers to optimize your design for

  • Development time (i.e., quick to write and/or easier to maintain)?
  • Processing time
  • Storage (either RAM, DB, Disc, etc) space

Of course this is highly subjective to the type of problems being solved, and the deadlines involved, so I'd like to hear about the reasons that would make you choose one form of optimization over another.

18 Answers18

40

Maintenance

Then profiling if necessary and optimize for speed. Rarely have I ever had a need for storage - at least not in the past 10 years. Prior to that I did.

Tim
  • 956
27

Development Time

Processing and storage is cheap. Your time is not.

Just to note:

This doesn't mean do a bad job of writing code just to finish it quickly. It means write the code in a fashion that facilitates quick development. It also depends entirely on your use cases. If this is a simple, two or three page web site with a contact form you probably don't need to use a PHP framework. A couple of includes and a mailer script will speed development. If the plan is instead to create a flexible platform on which to grow and add new features it's worth taking the time to lay it out properly and code accordingly because it will speed future development.

In the direct comparison to processing time and storage, I lean towards a faster development time. Is using the collectionutils subtract function the fastest and most memory efficient method of subtracting collections? No! But it's faster development time. If you run into performance or memory bottlenecks you can resolve those later. Optimizing before you know what needs to be optimized is a waste of your time and that is what I'm advocating against.

Josh K
  • 23,029
  • 10
  • 67
  • 100
13

User experience.

This is the only value that matters to your customer.

Development Time is less important. I can write a fully featured command line application a lot faster than a GUI, but if Mrs. Jane can't figure out how to make it spit out reports she wants, it's useless.

Maintenance is less important. I can repair a a seesaw really quickly, but if it's in the middle of a forest, users can't find it.

Processing Time is less important. If I make a car that goes 0 to light speed in 60 seconds, users can't steer.

Aesthetics is less important. I can paint a Mona Lisa, but if she's hidden behind a wall no one gets to see her.

User Experience is the only value that matters. Making an application that does exactly what the user wants in the way the user expects is the ultimate achievement.

Malfist
  • 3,661
8

There is only one thing to optimize for and it is:

What your customers want

Do your customers need the fastest program possible? Optimize for speed.

Do your customers need absolute reliability? Optimize for that.

Do they need it delivered tomorrow or it will be useless? Optimize for speed of development.

Running on an incredibly tiny resource-constrained device? Optimize for those resources.

5

Processing Time

My user's time is not cheap. What comes around goes around.


I just upgraded an application I use this last year. They had completely rewritten the app, and boy was it slow. I finally had to buy a new computer to run it quickly. I guarantee you that wasn't cheap, but my time is more valuable.

4

I tend to slant towards limiting memory consumption and allocations. I know it's old school, but:

  • Most of the non-throwaway code I write is heavily parallel. This means that excessive memory allocation and garbage collection activity will serialize a lot of otherwise parallelizable code. It also means there will be a lot of contention for a shared memory bus.
  • My primary language is D, which doesn't have good 64-bit support yet (though this is being remedied).
  • I work with fairly large datasets on a regular basis.
dsimcha
  • 17,284
2

Whatever virtualization technology I'm using

Remember the days when systems with more than 512 MB of RAM were considered bleeding edge? I spend my days writing code for the prior.

I work mostly on low level programs that run on the privileged domain in a Xen environment. Our ceiling for the privileged domain is 512 MB, leaving the rest of the RAM free for our customers to use. It is also typical for us to limit the privileged domain to just one CPU core.

So here I am, writing code that will run on a brand new $6k server, and each program has to work (ideally) within a 100kb allocated ceiling, or eschew dynamic memory allocation completely.

Concisely, I optimize for:

  • Memory footprint
  • Sorts (where most of my code spends most of its time)

I also have to be extremely diligent when it comes to time spent waiting for locks, waiting for I/O or just waiting in general. A substantial amount of my time goes into improving existing non blocking socket libraries and looking into more practical methods of lock free programming.

Every day I find it a little ironic that I'm writing code just like I did 15 years ago, on systems that were bought last month, due to advancements in technology.

This is typical for anyone working on embedded platforms as well, though even many of those have at least 1GB at their disposal. As Jason points out, it is also typical when writing programs to be run on mobile devices. The list goes on, Kiosks, thin clients, picture frames, etc ..

I'm beginning to think that hardware restrictions really separate programmers from people who can make something work without caring what it actually consumes. I worry (down vote me if you must) what languages that completely abstract type and memory checking to the collective pool of common sense that (used to be) shared amongst programmers of various disciplines.

2

I would say I optimise toward efficiency, with efficiency being defined as a compromise between development time, future maintainability, user-experience and resources consumed. As a developer you need to juggle all of these to maintain some kind of balance.

How do you achieve that balance? Well, first you need to establish a few constants, such as what the deadline is, what hardware your application will be running on and what type of person will be using it. Without knowing these you cannot establish the correct balance and prioritise where it is needed.

For instance, if you are developing a server application on a powerful machine you might want to trade-off performance efficiency to ensure you hit an immoveable deadline. However, if your developer an application that needs to respond quickly to user input (think a video game) then you need to prioritise your input routine to ensure it is not laggy.

Dan Diplo
  • 3,920
2

Research Results

As an academic, I figured I should share what I optimize for. Note that this isn't quite the same as optimizing for a shorter development time. Often it means that the work might support some research question, but not be a deliverable, polished product. This might be viewed as an issue with quality, and it could explain why many say that (academic) computer scientists don't have any "real world" experience. (E.g., "Wouldn't they know how to develop a deliverable product otherwise?")

It's a fine line. In terms of impact, you want your work to be used and cited by others, and Joel's Iceberg Effect comes into play: a little polish and shine can go a long way. But if you aren't making a foundation for other projects to be built on, you just might not be able to justify the time spent making a deliverable product.

Macneil
  • 8,243
1
  1. Design
    • low coupling, modular
    • concise, well defined, functional areas
    • well documented
    • continuously refactor for cruft
  2. Maintenence
    • reproducible build and debug
    • unit tests
    • regression tests
    • source control

... after that everything else

... finally, optimise for performance ;-)

cmcginty
  • 729
1

Quality/Testing

Optimise towards quality, as in ensuring there is time in the development schedule for testing, both unit testing and testing after features/phases.

1

It depends on the need of your program.

Most of what I do is constrained heavily by processing capability and memory, but does not go through very many, if any, significant changes in the average year.

I have in the past worked on projects where the code is changed frequently so the maintainability becomes more important in those cases.

I have also worked on systems in the past where the amount of the data is the most significant issue, even on disk for storage, but more commonly the size becomes an issue when you have to move the data a whole lot, or over a slow link.

Bill
  • 8,380
1

Elegance.

If your code is well designed, it will have several effects:

  1. It will be easier to maintain (cutting costs for the customer)
  2. It will be easier to optimize (for JIT or full compilers)
  3. It will be easier to replace (when you think of a better solution)
0

Expressiveness of my intent.

I want someone reading my code to be able to easily see what operations I was trying to invoke on the domain. Similarly I try to minimize non-semantic junk (braces, 'function' keywords in js, etc) to make scanning easier.

Of course you gotta balance that by maintainability. I love writing functions that return functions and all sorts of advanced techniques and they DO further my goal, but if the benefit is slight I will err on the side of sticking to techniques that solid jr programmers would be familiar with.

George Mauer
  • 2,012
  • 2
  • 16
  • 18
0

Development time, absolutely. I also optimize for bandwidth, but I don't go to binary.

Christopher Mahan
  • 3,414
  • 21
  • 22
0

Since I do installations on multiple types of systems, everything from IBM mainframe to PCs, I first optimize for compatibility, then size, then speed.

Dave
  • 427
0

It Depends

If you are working on a real-time embedded video processing system then you optimize for processing speed. If you are working on a word processor you optimize for development time.

However, in all cases your code must work and it must be maintainable.

Dima
  • 11,852
-6

All of them

Processing time

Today's computers are fast, but far from what's enough. There're many many situations where performance is critical - if you do streaming media servers.

Storage

You customer might have a big disk, let's say, 1Tb. Which can be taken up by 1000 HD movies, if you want to make it a service it's far from enough, isn't it?

Development time

Well I'm not sure if this count as “optimization", what I do is I use Java instead of C++, and the development get 10 times faster. I feel like I'm telling what I think directly to the computer, very straight forward and totally rocks!

BTW I believe to speed up development your development process you should choose java, never try rubbishes like python... which claims they can shorten you DEV time.

tactoth
  • 553