[erlang-questions] Code complexity and encapsulation
Suraj Kumar
suraj.kumar@REDACTED
Mon May 19 10:50:05 CEST 2014
Hi,
I'm attempting to build a system whose engineering challenges will
classically benefit from the so-called Object-Oriented Programming
paradigm: Specifically, that of encapsulation. However, the real complexity
of the problem is that there are going to be millions of objects 'existent
in space and time' simultaneously.
The problem domain is analogous to a drawing system: There is a 2D 'canvas
onto which several different types of 'shape objects' can be fit into. Once
they are all placed on the canvas, it is required that the canvas gets to
know all the shapes which seem to coincide with point P (x, y co-ordinates)
(or must do similar natured querying of all the shapes without being aware
of their details). To find this, the canvas has to ask each shape, in an
agnostic/implementation-independent way, whether the object "is_on_point
(x,y)".
Thus far, I've gone about modeling each 'shape' as one 'record' in Erlang.
I've written some 'utility' functions to determine types of various
records. I've also written boilerplate logic in the 'canvas' class to check
types and then call appropriate functions. I've also introduced a major
convention hell which new programmers will have to understand if they want
to add a new type of shape to the system.
Is there a cleaner way of modeling this? Should I be using OTP instead of
looking for a way to do this in native Erlang? If yes, what would you
suggest is a good supervisor/worker-process model so that such
encapusulation and complexity can be achieved? Any examples I can look at?
Regards,
-Suraj
--
An Onion is the Onion skin and the Onion under the skin until the Onion
Skin without any Onion underneath.
--
_____________________________________________________________
The information contained in this communication is intended solely for the
use of the individual or entity to whom it is addressed and others
authorized to receive it. It may contain confidential or legally privileged
information. If you are not the intended recipient you are hereby notified
that any disclosure, copying, distribution or taking any action in reliance
on the contents of this information is strictly prohibited and may be
unlawful. If you have received this communication in error, please notify
us immediately by responding to this email and then delete it from your
system. The firm is neither liable for the proper and complete transmission
of the information contained in this communication nor for any delay in its
receipt.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140519/a78fdb1f/attachment.htm>
More information about the erlang-questions
mailing list