32
Multi View Constructed right Eduardo Madeira Fleury BossaConference 2010 - Manaus

Multi View Constructed Right

Embed Size (px)

DESCRIPTION

Developers have been facing increasingly stronger requirements regarding application interfaces. Current UIs have to support different resolutions, match different devices and be themeable. Besides that, the technology used is ever-changing thus trying to keep such applications with a fresh look may require a lot of rework. Many theories have been proposed for this problem but the actual solutions not always work due to failures in real world implementations.

Citation preview

Page 1: Multi View Constructed Right

Multi View Constructed right

Eduardo M. FleuryBossaConference 2010 - Manaus

Multi View Constructed rightEduardo Madeira FleuryBossaConference 2010 - Manaus

Page 2: Multi View Constructed Right

Agenda

1 Introduction

2 Proposed architecture

3 Example

4 Real world issues

5 Conclusion

Page 3: Multi View Constructed Right

Everybody wants code that is

• Easy to understand and learn• Easy to maintain• Easy to extend or modify• Less prone to bugs

Page 4: Multi View Constructed Right

We need code that

• Can be created in parallel by the team• Assume look and feel of multiple platforms• Is future-proof regarding new GUI technologies

Page 5: Multi View Constructed Right

Need to support new devices

• There is a lot more than re-compiling• Screen size and viewing distance• Environment of use• Looks / Platform integration• Input methods

Page 6: Multi View Constructed Right

Need to support new technologies

• Qt widgets• Qt canvas (Graphics View)• Qt Quick (QML)• Other toolkits

Page 7: Multi View Constructed Right

A good architecture helps

• Reduce the number of code-paths• Define relevant / semantic components• Do not define too many components• Define good component API and keep them independent

Page 8: Multi View Constructed Right

Proposed architecture

Page 9: Multi View Constructed Right

Identify important concepts in your app

• Access data• Use data• Keep application state• User input• User output

Page 10: Multi View Constructed Right

Create component to access data

• Handle DBs• Parse file meta-data (EXIF, ID3, etc)• Access different data sources (network, other apps)• Watch for data modification

Page 11: Multi View Constructed Right

Create component to handle program ’core’

• Use data (play a song, interpolate an image)• Keep application state• Respond to high level user requests• Provide high level user output data

Page 12: Multi View Constructed Right

Create component to handle user interaction

• Listen to low level user input events• mouse click, keyboard pressed, remote control• Output information to user• Draw song title on the screen, beep when newmessage arrives

Page 13: Multi View Constructed Right

Component relationship

Figure: Relationship

Page 14: Multi View Constructed Right

Expected result

• Each component can be created in parallel by different people• Interface component can be modified to support new device• Interface component can use new technologies

Page 15: Multi View Constructed Right

Example

Page 16: Multi View Constructed Right

Component relationship

Figure: Relationship

Page 17: Multi View Constructed Right

Real world issues

Page 18: Multi View Constructed Right

Difficulties arise in practice

• Over-engineering• Excessive complexity• Poorly chosen interfaces / slice points• Promiscuity between components• Too much indirection in data flow

Page 19: Multi View Constructed Right

Over-engineering

• We are brilliant at identifying patterns• We fail miserably when dealing with large number of items• Harder to make mental model of, or harder to understand• Harder to maintain and extend

Page 20: Multi View Constructed Right

Over-engineeringAsk yourself

• What is the use case?• What problem am I trying to solve?• What potential of growth does this application have?• Do I really need that now?

Page 21: Multi View Constructed Right

Excessive complexity

• Default use cases are usually easy to handle• Corner cases together mean lots of code• Are such corner cases worth the extra effort?• Lots of features, lots of bugs too...

Page 22: Multi View Constructed Right

Excessive complexityAsk yourself

• Some people are fetishists about useless features, avoid that!• Avoid bloatness as a whole• Define priorities, use your time wisely• Remember:• What is the use case?• What problem am I trying to solve?• Do I really need that now?

Page 23: Multi View Constructed Right

Poor component interfaces

• Leads to an ’artificial’ division• Require data to be moved around• Poses obstacles to component replacement• Harder to be used and mentally modeled

Page 24: Multi View Constructed Right

Poor component interfacesAsk yourself

• Public API should be thoroughly thought of• Look at the problem from above• Try and make analogies with real world situations• Find a whiteboard, think before you code• Discuss your architecture with your peers

Page 25: Multi View Constructed Right

Components inter-dependency

• Components need to include other components• Components are not replaceable• Programmers cannot look at one class and understand it• Some patterns are well known and easier to recognize

Page 26: Multi View Constructed Right

Bad Component relationship

Figure: Bad Relationship

Page 27: Multi View Constructed Right

Components inter-dependencyAsk yourself

• Is this class a provider or consumer?• Use Qt Signal/Slot do decouple components• Consider an abstract public API

Page 28: Multi View Constructed Right

Data-flow indirection

• Data goes through several classes to reach its destination• One reading the code needs to imagine where does that come from• API gets dirty due to methods that mostly move data around• It can also be inefficient performance-wise

Page 29: Multi View Constructed Right

Data-flow indirectionAsk yourself

• Think about your whole application• Where is data coming from? Where is it going to?• Consider a high throughput link between consumer and producer• Find a good compromise between interdependence and indirection

Page 30: Multi View Constructed Right

Conclusion

• There’s a need for good architectures• Good ideas exist• Many projects suffer from bad implementation of such ideas• Learn from yours and other’s mistakes• Homework: Find an useless feature in your favorite software

Page 31: Multi View Constructed Right

Questions

Questions ?

Page 32: Multi View Constructed Right

Thank [email protected]

blog.eduardofleury.com