Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android, object oriented programing vs designing for performance

I am a complete noob to android but I have been programing c# for a long time. I am writing an android application and have gotten to a point where the c# programmer in me wants to start creating a loosely coupled design and and moving code into different layers, using interfaces, etc.

But then I stumble upon the Designing for performance guidelines it is telling me to avoid object creation and then it also is saying to optimize judicially.

Do I just build based on good design and then deal with performance issues as they come up?

The last thing I want to do is go through the work of building a application and have it perform poorly. Can someone point me to some examples of application that are designed well and have good performance or just make some recommendations?

Thanks

like image 813
bytebender Avatar asked Feb 26 '23 08:02

bytebender


1 Answers

I've found AndEngine to be fairly well designed and it has to be concerned with performance since it is a game development library -- so you might pull down a copy of it and read the source.

In the "Designing for performance" document, I would point out this statement:

Note that although this document primarily covers micro-optimizations, these will almost never make or break your software. Choosing the right algorithms and data structures should always be your priority, but is outside the scope of this document.

An example of this would be creating a particle system. A good way to model it is to have a ParticleSystem object that holds a collection of Particle objects...maybe those Particles implement a Particle interface...this is not the place to avoid object creation. However, for performance reasons, you will want to optimize the ParticleSystem to recycle Particle objects rather than creating them from scratch every time you spawn one.

Personally, I haven't found performance to be much of a limiting factor but I suppose that will really depend on what type of app you're building.

My opinion is to build a suitable design first, test the performance, and optimize from there.

like image 105
Timothy Lee Russell Avatar answered May 01 '23 03:05

Timothy Lee Russell