Posts

Showing posts from February, 2011

Simple Object Model - Bottom up Cell Life Demo

Image
- The system is slightly interesting. You can monitor the balance with the number of live cells. You may notice a shift in mutations as cells grow away from the center. - With only a few mutations, the color of cells tend to shift in color over time. - It takes many iterations for emergent behavior to emerge. - Code wise not really that interesting but already we can visualize the emergent behavior. - Cheating to make the simulation feasible Code trait LivingEntityCell { def getName : String def getDNA : DNA def alive : Boolean def processDNA() : Unit def produceProteins() : Unit def onStepSimulationProcessCell() : Unit def getMutableSize : Int def setImmutableSystemTraits : Unit def onStepSetSystemTraits : Unit /** * Metabolic reaction and process to convert energy. * In our system, amount of energy for this cell. */ ...

onConfigure for Wicket, use for business logic?

I asked this: here is the best place to put code to initialize the model before a page renders. I know of five options, but where do you normally put this type of initialization. Before a page renders, I want to set the data in my bean/model with certain attributes that may only be specific to that page. I think there are five options. 1. Add initialization logic in the constructor. This may work, but I don't know if the constructor is called for every page call (E.g. when the page is deserialized) 2. Add init logic in onBeforeRender. This works and it called for every request? But is it the best place? 3. Add init logic in a "load" or "getmodel" method in LoadableDetachableModel class? 4. Add init in previous page on onSubmit method or onEvent. (onSubmit() { initBeanInSession(); setResponsePage(); } 5. Pass a model to a panel or page constructor (using pageparameters?) Are any of these best practices or preferred over the other. (a) Page Construct...

Constructors in Scala

class R(n: Int, d: Int) { val (x, y) = { val g = myfunc (n/g, d/g) } } class R private (val x: Int, val y: Int); object R { def apply(n: Int, d: Int): R = { val g = myfunc; new R(n / g, d / g); } }

More on getters and setters - Don't do it

"It's a 25-year-old principle of object-oriented (OO) design that you shouldn't expose an object's implementation to any other classes in the program. The program is unnecessarily difficult to maintain when you expose implementation, primarily because changing an object that exposes its implementation mandates changes to all the classes that use the object." -- By Allen Holub, JavaWorld.com, 01/02/04 To that, don't use setters and getters exclusively for all POJO beans. http://www.javaworld.com/javaworld/jw-01-2004/jw-0102-toolbox.html

Bottom-Up Artificial Life Demo Update

Here are some of the key features of the artificial life demo: 1. Must have a strong focus on environment - E.g. Sun, Food, Smell, Water, Other Cells 2. Cell Functions, responding to the environment - Movement, etc 3. Attributes that affect functions - Size 4. Mutations

JVMNotebook - Javap output in a web environment

Image
Javap - Use custom Javap source to disassemble Java classes. Use this to check the version of running code or other such functions. http://code.google.com/p/jvmnotebook/wiki/JavapDisassembleOnWeb

JVMNotebook on Google Code

The Java Virtual Machine ( Sun's JVM is called HotSpot ) is a java bytecode interpreter which is fast, portable and secure. Jython, JRuby, Scala, ABCL (Common Lisp) are popular language implementations that run on the JVM that allow for the jvmcookbook sugar of their particular languages. keywords: java, general java, j2ee, clojure, scala, abcl, jruby, gwt, apache wicket, spring This project contains multiple sub-projects and code demos related to those jvm language implementations. http://code.google.com/p/jvmnotebook/ -- Berlin Brown