wiki:CodingPatterns

Version 5 (modified by mdavis, 5 years ago) ( diff )

--

GEOS Coding Patterns

This page documents coding patterns followed in the GEOS codebase.

The patterns are intended to improve the following:

  • Understandability
  • Performance
  • Memory safety

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

Patterns

Object References

  • Created objects should be returned as a std::unique_ptr<Object>
  • Taking ownership of a returned object should be done as a 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?
Note: See TracWiki for help on using the wiki.