Scott,

the FP fans will hate me for it, but I personally still believe OOD
and FP don't mix well at all. You can easily model something like
objects in a functional programming language, but since they are
always immutables they tend to clash with the design strategies used
in OOD.

My dream language would have two separate type systems: components and
value types. The latter being immutable and with value-identity
(http://blog.peterbecker.de/2008/05/java-should-have-value-types.html),
the former being designed for dynamic, mutable approaches -- which for
me means having properties and events (but the events themselves
should be value types). This way you get the nice world of FP-style
purity for values (and thus calculations) while maintaining a higher
level view that is closer to OOD, which I believe to be closer to the
way domain experts model see their domains. By restricting
communication between components to value types you also solve a lot
of the potential pitfalls involved in threading/parallel computing (I
would even consider to drop the notion of a standard method call in
favour of a pure event-based communication model).

Most FP languages (including the OO ones) don't let you model things
this way. I believe Scala would let you, but it's not enforced, which
I think is a bit of an issue -- it could turn out to be a little bit
like Perl in being a write-only language. But only time will tell.

Just my 2c,
  Peter



On Sat, Aug 30, 2008 at 6:39 AM, Scoot <[EMAIL PROTECTED]> wrote:
>
> Apologies if this is somewhat off topic, but I think (hope) the posse
> audience have some useful insights on this.
>
> I'm trying to get my head into functional thinking.  I'm sold on the
> principles of immutability and all the attendant advantages; I've
> looked at examples in various languages (erlang, haskell, scala) and
> admired the elegant simplicity of recursion.
>
> What I'm struggling with is how to model real-world domains using
> these principles.  Someone (Dijkstra?) once jested stacks were
> invented solely to demonstrate Abstract Data Types; it kind of feels
> like the Fibonacci series is the functional programming equivalent.
>
> What I'm missing are examples from real world domains; like customers
> holding accounts or purchasing products.  I want to think about these
> as stateful entities; e.g. the account moving from in credit to
> overdrawn and back.
>
> So: how does one "think" about these things functionally?
>
> I know in scala I can represent them as stateful objects but that's
> sidestepping the issue; how do I think about state - and persistence -
> functionally?  Any thoughts/pointers gratefully accepted.
>
> tia,
> Scott.
> >
>



-- 
What happened to Schroedinger's cat? My invisible saddled white dragon ate it.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to