Monday, February 21, 2011

XML Browser with Pharo

I've written a little tool to help me browse xml. If you want to try it:
Gofer new
 squeaksource: 'LaurentLSandbox';
 package: 'XML-GUI';
 load.
 
((Smalltalk at:#XMLBrowser) labelled: 'Picasa search')
  browseAtUrl: 
   'http://picasaweb.google.com/data/feed/api/all?q=lighthouse&max-results=10'.



See XMLBrowser comment for examples.

Friday, February 18, 2011

FizzBuzz Kata: minimal solution

Trying to find a minimal solution for the FizzBuzz Kata in Smalltalk:

fb := [:counter| |rules|
       rules := {15->'FizzBuzz'. 5->'Buzz'. 3->'Fizz'. 1->counter}.
       rightRule := rules detect: [:aRule| counter \\ aRule key == 0].
       rightRule value].  

self assert: (fb value: 7) == 7.
self assert: (fb value: 3) == 'Fizz'.
self assert: (fb value: 5) == 'Buzz'.
self assert: (fb value: 15) == 'FizzBuzz'.

1 to: 100 do: [:counter | 
               Transcript 
                 show: (fb value: counter) asString;
                 cr]


Update: Little variant from Alexandre:
rightRule := rules detect: [:aRule| counter isDivisibleBy: aRule key]

Tuesday, February 8, 2011

Smalltalk tiny exercise for TDD newbies

Done in course:

Create the category Exercise in the Browser. All classes you create will be placed in this category.

Implement the class Operation (using Test-Driven Development) which should work like this:
  1. a := Operation new.
    a result.
    
    Should return 0.
  2. b := Operation new.
    b add: 2.
    b add: 3.
    b result.
    
    Should return 5.
  3. Operation new
      add: 2;
      add: 4;
      divideBy: 2;
      result.
    
    Should return 3.

Add the message Operation>>#multiplyBy by yourself.

Sunday, February 6, 2011

new funny ProfStef lesson

Update to last ProfStef (on Pharo 1.2 only):


Gofer it
 squeaksource: 'MetacelloRepository';
 package: 'ConfigurationOfProfStef';
 load.
 
ConfigurationOfProfStef project latestVersion load.

ProfStef 
  go;
  tutorial: SmalltalkSyntaxTutorial lesson: #instanciation.

Wednesday, February 2, 2011

Why technology matters

Life is very short. You have a limited amount of time in which to realize your dreams, in which to do your projects. If you’re like me, you probably have dozens and dozens of ideas for apps, sites, portals, that you want to implement. Most of those ideas will suck. But you don’t know which ones, you won’t know until you try them. Your goal, in this life, is to iterate faster. To fail more, to fail quicker, until you get to the brilliant ideas and brilliant projects that can change the world, or at least make you a dollar or two.

From A Secret: Passion and Your Choice of Web Framework by Dmitri Zagidulin