4 ms·
He is actually correct that in an OOPL data type definitions are spread out all over the place In a typical OO language all the code belongs in classes, and th
by ntoshev 18y ago
He is actually correct that in an OOPL data type definitions are spread out all over the place
In a typical OO language all the code belongs in classes, and there is no way of telling which classes define the essential data types and which are mostly placeholders for code. There is no way to tell at a glance what are the important data structures. Just look at any open source Java project.
I use python and I find myself using more functions and fewer and thinner classes recently. In particular, if some state is transient, I find it is much better to keep it in local variables of the more abstract functions than obscure it as object state.
- visitor4rmindia 18y agoCouldn't you just put the ubiquitous data structures in a "com.proj.basic" package? EDIT: I'm using the word "ubiquitous" because that's what was used in the article.
- ntoshev 18y agoMost people treat packages just like bigger-than-classes chunks of related functionality and state. Typically there is a 'common' package for supporting stuff that is used all over the place, but these are not the data types most important for the project, these are just that project's particular incarnation of datetime utilities. The 'basic' package is certainly not common practice.
- silentbicycle 18y agoYes, but if you're subclassing them at all, then any extensions on the core data structures are very likely to get fragmented and scattered around.
- jwilliams 18y agoFor a clearly delineated API/Module, often the essential data types are the public classes - the code is whatever is behind interfaces.
- ntoshev 18y agoIn my experience most often the public interface is an instance of the Facade pattern and its state is spilled in an object graph behind it.
- sunkencity 18y agoyep and good OO languages like ruby blur the distinction between data and functions.
- bad_user 18y agoActually that's not true. Functions in Ruby aren't first class citizens, and for a given function you can't request / modify it's syntax tree. Otherwise, I consider the blur between code and data a good thing to have.
- sunkencity 18y agoWell, with ruby you can at least pretend they are, but yea.
- andreyf 18y agoFunctions in Ruby aren't first class citizens... You can assign them to a variable, and you can write out a function literal. What more does it take to be a "first-class citizen"? ...for a given function you can't request / modify it's syntax tree And what language does let you do that? Macro systems like let you do it at compile-time, but when you use the phrase "request an AST", it sounds like you're doing it at runtime...
- pygy 18y ago> And what language does let you do that? Io does. http://hackety.org/2008/01/05/ioHasAVeryCleanMirror.html http://hackety.org/2008/01/05/ioHasAVeryCleanMirror.html But functions are first class objects in Ruby (with some quirks regarding the difference between a proc and a bloc).
- bad_user 18y agoWell, Lisp. And even in C# 3.0, when passing lambda expressions you can request a syntax tree instead of a method reference.
- snprbob86 18y ago