What are the Barriers to Entry for Smalltalk and Seaside?

It’s been two or three years since I began using Smalltalk and Seaside and I’m so comfortable in the environment I think I’ve forgotten how difficult it was to get going. By the time I started this blog, I was already quite comfortable using both Smalltalk and Seaside that I think a bunch of the little things I could have written about have been overlooked.

I’ve been so busy with work lately that I haven’t felt much like writing but I think it’s about time I give the blog a little more love. So those of you looking to get into Smalltalk, or Seaside, where’s your pain? What things are tripping you up that you can’t find answers to? What things are getting in your way that keep you from getting into the flow and really doing something in Seaside?

I’m just looking for some ideas for some bite sized yet useful articles covering topics I haven’t already covered that’ll help ease someone’s pain just a bit and get me back into the writing mood.

Related posts
    at: "Small Reddit, A Seaside Sample Application";
    at: "On the Smalltalk Browser";
    at: "Great Moments in Modern Computer History";

Maintaining Loose Coupling in Seaside Components

There is an interesting question that often comes up often when writing components. How do my components communicate with each other in a way that doesn’t bind them together explicitly. How does a child component call a method on a parent component without explicitly knowing who the parent is.

Knowing who the parent is prevents the component from being re-used in other contexts with different parents. There is a general solution to this whole class of problems and it was solved quite elegantly by Vassili Bykov with his Announcements framework.

The basic idea is to setup an announcer somewhere global, in the session for example.

MySession>>announcer
    ^ announcer ifNil: [announcer := Announcer new]

Then subclass Announcement for any interesting thing that might happen like removing a child.

Announcement subclass: #RemoveChild
    instanceVariableNames: 'child'

RemoveChild class>>child: aChild
    ^self new
        child: aChild;
        yourself

RemoveChild>>child: anChild
    child := anChild

RemoveChild>>child
    ^child

Any component interested in this announcement registers its interest when it initializes.

Parent>>initialize
    super initialize.
    self session announcer on: RemoveChild do:[:it | self removeChild: it child]

Parent>>removeChild: aChild
    self children remove: aChild

And any component who wants to fire this event simply announces it by sending in an instance of that custom announcement object.

Child>>removeMe
    self session announcer announce: (RemoveChild child: self)

Works great, and depending on where you place the announcer, you could even have different sessions sending events to each other, or different applications.

Here’s a file out of a commented working demo that has a child remove itself from the parent via an announcement.

UPDATE: I use the port of Announcements from Lukas Renggli’s public repository. The one on SqueakSource is a different port.

Related posts
    at: "Smalltalk In Action";
    at: "Pollak On Seaside";
    at: "Ajax: Seaside vs .Net";

Small Reddit, A Seaside Sample Application

I just uploaded a simple reddit clone sample Seaside application to SqueakSource. It’s meant be a very simple reference application to learn from, it’s only about 4 hours work total. There are comments throughout, and various techniques are used to demonstrate different ways of doing things. Some forms are generated directly via Seaside and some other by Magritte. Persistence is implement in image using dictionaries and collections.

Features include login, register, add entry, vote on entry, comment on entry, comment on comment. There are probably a few bugs. I’m not making any claims of best practice, only showing various ways I accomplish things to suite my needs.

Hopefully such an application will make Seaside more approachable for the newbie and help ease the lack of documentation available. I know when I first started learning, I was far more interested in actual samples than outdated documents. Enjoy!

UPDATE: Loading this code requires that you create a repository in Monticello. Just create a new HTTP repository with the following template using the +Repository button.

MCHttpRepository
    location: 'http://www.squeaksource.com/SmallReddit'
    user: ''
    password: ''

Once done, you can open the repository, select the package, and load it. It will create an application on localhost at /seaside/smallReddit, on whatever port you’re running Seaside on. You could also just download the mcz file directly and drag and drop it into your squeak image, at which point you’ll be prompted and asked what you’d like to do.

See my previous screencast about using Monticello for a quick visual on using Monticello.

Related posts
    at: "Popular Posts";
    at: "Rails vs Seaside";
    at: "Aha! Moments in Lisp";

Pollak On Seaside

Found on a Rails blog…

“IMHO Seaside is the benchmark by which all web frameworks should be measured” — David Pollak

My thoughts exactly. It’s not about the language, it’s about the approach. Seaside is the right recipe for writing real applications, not just fancy websites. No other framework can do what Seaside does, as easily as Seaside does it. Real components with their own state, real objects, no pages, no templates, Ajax in pure Smalltalk by simply wiring events together on the server side, calls to other components are actual method calls rather than hacked up URL conventions.

For Rails fans (myself included), don’t compare Seaside to Rails, rather compare Seaside to ActionPack, the view controller layer within Rails. If you want to see an apples to apples comparison of the entire stack, it’d be something like…

ActionMailer == Existing Squeak services
ActionPack == Seaside
ActionWebservice == SoapCore
ActiveRecord == Glorp
ActiveSupport == Existing Squeak code, the image is full of DSL mini languages to make everything pretty

Seaside isn’t the well integrated full stack solution that Rails is, but all the parts are there, you can mix and match your own perfect framework.

Related posts
    at: "No related posts";

« Previous PageNext Page »