ruby, unittesting and lego

  • Thread starter Simon Strandgaard
  • Start date
S

Simon Strandgaard

Recently I have rediscovered lego. Its very useful to build a model
of that data structure you want. When you have your physical model
then its easy to think out all kinds of senarios that data structure
possible could be used for.

Here is a picture of my lego model:
http://aeditor.rubyforge.org/data/lego_model_of_caching_system.jpg

I wanted to make a new improved syntax coloring system for my
editor, in paticular a robust caching scheme. The old caching mechanism
sometimes didn't render dirty lines, other times it didn't flag lines as
being dirty, ofthen it did too much work by rendering more lines than
necessary.... and yet other times it crashed.

My new data structure is robust and doesn't do more work than absolutely
necesary. I don't believe that I would have gotten this far without lego.
 
B

Brian Schröder

Recently I have rediscovered lego. Its very useful to build a model
of that data structure you want. When you have your physical model
then its easy to think out all kinds of senarios that data structure
possible could be used for.

Here is a picture of my lego model:
http://aeditor.rubyforge.org/data/lego_model_of_caching_system.jpg

I wanted to make a new improved syntax coloring system for my
editor, in paticular a robust caching scheme. The old caching mechanism
sometimes didn't render dirty lines, other times it didn't flag lines as
being dirty, ofthen it did too much work by rendering more lines than
necessary.... and yet other times it crashed.

My new data structure is robust and doesn't do more work than absolutely
necesary. I don't believe that I would have gotten this far without lego.

Hello Simon,

would you mind to elaborate a bit on how this models your caching
system? Even though the model seems quite concise and I understand
danish I just don't get how it works ;)

Regards,

Brian
 
S

Simon Strandgaard

[snip]

would you mind to elaborate a bit on how this models your caching
system? Even though the model seems quite concise and I understand
danish I just don't get how it works ;)

Its heavy to do realtime syntax coloring in an editor, so naturally one wants to
do as little work as possible. Computing syntax coloring for 50 lines takes
about 0.7 seconds on my 700 MHz box.

You can change one letter and then the editor will compute the affected line.
In case the syntax state is different to the previous syntax state then we must
propagate the change to the following line. Imagine inserting a double
quote then
the following lines gets colored differently.
When inserting/removing a few line into the buffer, then we want to
recycle as much
syntax state as possible.

Its difficult to explain. Sorry.

The lego model helped me thinking through all kinds of senarios. If I
had to draw these
senarios on paper than it would have taken forever.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top