wiki:CodingPatterns

GEOS Coding Patterns

This page documents coding patterns followed in the GEOS codebase.

The patterns are intended to improve: understandability, consistency, performance, and memory safety.

Code should follow the patterns given here, unless this is not possible for compatibility reasons. Older GEOS code may not adhere to all patterns, but the goal is to update it when possible.

Patterns

Object References

  • Return created objects using std::unique_ptr<Object>
  • To take ownership of a returned object use std::unique_ptr<Object>

To Be Investigated

Geometry Factory improvements

  • Add createXX methods returning std::unique_ptr<XX>
  • Remove old create methods once all code is switched to using std::unique_ptr

Unique_ptr typedefs?

  • To reduce boilerplate perhaps define typedefs for common types: UP_Geometry, UP_CoordinateSequence, etc

Coordinate Sequence improvements

Goals:

  • Improve performance by avoiding virtual function calls
  • Support immutable use of external coordinate sequence formats

Issues

  • Virtual functions
    • Are they really a performance hit?
    • Use templates?

Tasks

  • Remove mutating methods where not strictly needed
  • Mark non-mutating methods as const to allow immutable use of external coordinate sequence formats
    • Will this work?
Last modified 3 months ago Last modified on May 15, 2019 12:29:08 PM