juan_gandhi: (Default)
2011-04-04 05:09 pm
Entry tags:

tell me I'm wrong (or right)

I'm pretty much tired of using so-called "DAO objects", automatically hibernate-generated classes that are dumb and simple; they are being used everywhere throughout the code; I was always willing to fill them with functionality, but, thank god, there was no chance.

Now I think this. Thanks to [livejournal.com profile] mikkim08 ideas for Scala. They should be all wrapped in decorators; and decorators should be returned from DAOs or factories. Performance-wise, it is just one level of indirection, and one more reference per instance. Conceptually, it is an implicit mapping.

E.g. I get "CountryData" from db; it is dumb and know nothing about life, just data. Wrap it in a subclass, and kaboom, an intelligent guy who can tell you this and that... and yes, immutable, since all "setters" are blocked by police.

So there.
juan_gandhi: (Default)
2010-09-18 07:27 pm

implicit: Int -> Category

(that's scala)

  /**
   * Builds a category out of a segment of integers between 0 and n (not included).
   *
   * @param n number of elements
   * @return a new category
   */
  implicit def segment(n:Int) : Category[Int, (Int, Int)] = Category(PoSet.range(0, n, 1))
//...

  def testImplicitSegment {
    def sut: Category[Int, (Int, Int)] = 3
    assertEquals(_3_, sut)
  }