DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
What's in store for DevOps in 2023? Hear from the experts in our "DZone 2023 Preview: DevOps Edition" on Fri, Jan 27!
Save your seat

Surface-area Over Volume Ratio – a Metaphor for Software Design

Cyrille Martraire user avatar by
Cyrille Martraire
·
Nov. 23, 12 · Interview
Like (0)
Save
Tweet
Share
3.70K Views

Join the DZone community and get the full member experience.

Join For Free

there’s a metaphor i had in mind for a long time when thinking about software design: because i’m proudly lazy, in order to make the code smaller and easier to learn, i must do my best to reduce the « surface-area over volume ratio » of the software.

surface-area over volume ratio?

i like the surface-area over volume ratio as a metaphor to express how to make software cheaper to discover and learn, and smaller to maintain as well.

for a given object, the surface-area over volume ratio is the amount of surface area per unit volume. for buildings and for animals, the smaller this ratio, the less the heat loss during the winter, hence a better thermal efficiency.

have you ever noticed that huge warehouses were always cool even during the summer when it’s hot? this is just because in our real 3d world the surface-area over volume ratio is much smaller when the absolute size of the building increases.

the theory also mentions that the sphere is the optimal shape with respect to this ratio. in fact, the more « compact » the less the ratio, or the other way round we could define compactness of an object directly by its surface-area-over-volume ratio.

a dodecahedron, a volume that approximates a sphere with just 2d facets (wikipedia picture)

what about software design?

let’s consider that each method signature of each interface is part of the surface-area of the software, because this is what i have to learn primarily when i join the project. the larger the surface-area, the more time i’ll need to learn, provided i can even remember all of it.

larger surface is not good for the developers.

on the  other hand, the implementation is part of what i would call the volume of the software, i.e. this is where the code is really doing its stuff. the more volume, the more powerful and richer the software. and of course the point of object orientation is that you don’t have to learn all the implementation in order to work on the project, as opposed to the interfaces and their method signatures.

larger volume is good for the users (or the value brought by the software in general)

as a consequence we should try to minimize the surface-area over volume ratio , just like we’re trying to reduce it when designing a green building.

can we extrapolate that we should design software to be more « compact » and more « sphere »-like?

facets-like interfaces

reusing the same interface as much as possible is obviously a way to reduce the surface-area of the software. adhering to interfaces from the jdk or google guava, interfaces that are already well-known, helps even better: in our metaphor, an interface that we don’t have to learn comes for free, like a perfectly isolated wall in a building. we can almost omit it in our ratio.

to further reduce the ratio, we can find out every opportunity to use as much as possible the minimum set of common interfaces, even over unrelated concepts. at the extreme of this approach we get duck typing in dynamic languages. in our usual languages like java or c# we must introduce additional small interfaces, usually with one single method.

for example in a trading system, every class with a isincurrency(currency) method can implement a common interface currencyspecific . as a result, a lot of processing (filtering etc.) on stuff that is related to currencies in some way can be done on all these classes without any knowledge about them, except their currency-specificity.

in this example, the currency-specificity we extracted into one interface is like a single facet over a larger volume made of several implementation. it makes our design more compact, it will be easier to learn, while offering a rich set of behaviors.

the limit for this approach of putting a lot of implementation code under the same interface is that sometimes it really makes no domain sense. since code is primarily meant to describe the domain, without causing confusion we must be careful not to go too far. we must also take great care when sharing interfaces between bounded contexts, there’s a high risk of excessive coupling.

faceted artwork (picture from http://reinierdejong.wordpress.com)

yet another metric?

this metric could be measured by a tool, however the primary value is not in checking the figures, but in the thinking and taking care of making the design easy to learn (less surface-area), while delivering a lot of valuable behaviors (more volume).

Software design Interface (computing)

Published at DZone with permission of Cyrille Martraire, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • How Observability Is Redefining Developer Roles
  • Architecture and Code Design, Pt. 2: Polyglot Persistence Insights To Use Today and in the Upcoming Years
  • Efficiently Computing Permissions at Scale: Our Engineering Approach
  • Handling Virtual Threads

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: