. .

st4u

ST 4U 354: Collections and Streams

March 8, 2013 9:00:18.451

Today's Smalltalk 4 You looks at collection limitations, and how they can be bypassed using streams. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

Collections and Streams.

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:


Today we'll take a look at streams and collections. We've pointed out before that streaming works across any collection (not just strings) - but streaming also "bypasses" some of the limitations built into some of the collection classes. Take an Array, for instance. Being fixed size, this will fail:


array := #(1 2 3 4).
array add: 5.

Normally, that's not an issue - you probably picked an Array because you had a fixed set of objects, and didn't need to grow it. But what if you did? Well, you can use a stream:


array := #(1 2 3 4).
stream := ReadWriteStream on: array.
stream upToEnd.
stream nextPut: 5.
^stream contents.

If you inspect the results, you'll see that you still have an Array, now with 5 objects rather than 4. It's actually a copy of the initial array, not the same one grown. You could, of course, accomplish the same thing via the transformations APIs:


array := #(1 2 3 4).
oc := array asOrderedCollection.
oc add: 5.
^oc

Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.

Tags: , ,

Enclosures:
[st4u354-iPhone.m4v ( Size: 1060479 )]

posted by James Robertson

 Share Tweet This

st4u

ST 4U 353: Looking at UIs in ObjectStudio

March 6, 2013 11:10:39.199

Today's Smalltalk 4 You looks at how GUIs are constructed in ObjectStudio. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

ObjectStudio GUI

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:

Tags: , ,

Enclosures:
[st4u353-iPhone.m4v ( Size: 930149 )]

posted by James Robertson

 Share Tweet This

st4u

ST 4U 352: Sample Browser in ObjectStudio

March 4, 2013 8:25:33.729

Today's Smalltalk 4 You looks at the sample browser that comes with ObjectSTudio - a useful repository of simple examples. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

Sample Browser

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:

Tags: ,

Enclosures:
[st4u352-iPhone.m4v ( Size: 830801 )]

posted by James Robertson

 Share Tweet This

st4u

ST 4U 351: Reflecting with instance variable names

March 1, 2013 10:25:31.567

Today's Smalltalk 4 You looks at reflection using instance variable names. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

Reflection.

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:


Today we'll put a few pieces together on reflection in Smalltalk. Let's assume that you've read some data from an external source into a dictionary, with data like this:


dict := Dictionary new.
dict at: 'id' put: 101.
dict at: 'first' put: 'James'.
dict at: 'last' put: 'Robertson'.

Now, what if you want to create an instance of class Person and fill it with that data - but not using the sort of slot binding approach assumed by #instVarAt:put:? Consider the following:


person := Person new.
dict keysAndValuesDo: [:key :value |
	| msg |
	msg := (key, ':') asSymbol.
	person perform: msg with: value].
^person

Notice how we assume that the dictionary keys are the names of variables, and we construct the messages that get sent to the object. Realistically, you would want exception/error handling around that, for cases where the file format and the class format get out of synch - but that's the basic approach, and it's used commonly in Smalltalk.

Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.

Tags: , ,

Enclosures:
[st4u351-iPhone.m4v ( Size: 931310 )]

posted by James Robertson

 Share Tweet This

st4u

ST 4U 350: Configurations in Pharo 2.0

February 27, 2013 8:22:20.999

Today's Smalltalk 4 You looks at configurations in Pharo - no more wondering which magical incantation to perform in order to get some code to load :). If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

Configurations

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:

Tags: , ,

Enclosures:
[st4u350-iPhone.m4v ( Size: 833020 )]

posted by James Robertson

 Share Tweet This

st4u

ST 4U 349: Emergency Evaluator in Pharo

February 25, 2013 1:32:47.982

Today's Smalltalk 4 You looks at the emergency evaluator in Pharo. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

emergency evaluator

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:

Tags: ,

Enclosures:
[st4u349-iPhone.m4v ( Size: 553290 )]

posted by James Robertson

 Share Tweet This

st4u

ST 4U 348: Reflecting on Class Names

February 22, 2013 0:49:38.922

Today's Smalltalk 4 You looks at the common way to look up Smalltalk class names (things differ a bit in VisualWorks and ObjectStudio). If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

Class Lookups.

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:


Today we'll continue looking at reflection in Smalltalk. In most Smalltalk implementations (Cincom Smalltalk being the exception), there's one namespace (Smalltalk). Thus, looking up a class by name is simple:


clsName := 'Person'.
cls := Smalltalk at: clsName asSymbol.
^cls new.

That makes reading in data from a source (a file, for instance) that includes class names pretty easy - get the class name, create an instance, and then dump data in the variables as it's found in the file. We'll take a look at that next time.

Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.

Tags: ,

Enclosures:
[st4u348-iPhone.m4v ( Size: 739326 )]

posted by James Robertson

 Share Tweet This

st4u

ST 4U 347: Which Inspector in ObjectStudio?

February 20, 2013 7:51:02.264

Today's Smalltalk 4 You looks at the inspector that's used in the latest versions of ObjectStudio. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

Inspector

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:

Tags: , ,

Enclosures:
[st4u347-iPhone.m4v ( Size: 653328 )]

posted by James Robertson

 Share Tweet This

st4u

ST 4U 346: Finding Strings in Code (OS 8)

February 18, 2013 11:36:30.722

Today's Smalltalk 4 You looks at finding arbitrary strings in your ObjectStudio code. Turns out that this feature in OS is easier to use than the equivalent one in VisualWorks. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

String Finding

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:

Tags: , ,

Enclosures:
[st4u346-iPhone.m4v ( Size: 692462 )]

posted by James Robertson

 Share Tweet This

st4u

ST 4U 345: instVarAt:

February 15, 2013 10:14:56.721

Today's Smalltalk 4 You looks at one of the low level API aspects of Smalltalk - #instVarAt: and #instVarAt:put:. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

instVarAt.

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:


Today we'll look at a way you can break encapsulation in Smalltalk - useful for some low level tasks (interfacing with databases, for instance) - but dangerous in general. Still, it's useful to know what you can accomplish, so long as you are also aware of the dangers. Consider this class:


Object subclass: #Person
    classInstanceVariableNames: 'nextId '
    instanceVariableNames: 'id first last '
    classVariableNames: ''
    poolDictionaries: ''

Now consider this code:


person := Person new.
person first: 'James'.
person last: 'Robertson'.


person instVarAt: 1

Execute that, and you should get back the value in 'id' = the first instance variable. Again this is not something you want to make use of on a normal basis. It can be useful when debugging (say you have a class without accessing methods), or when creating accessing frameworks for external data. Similarly:


person instVarAt: 1 put: 0.

Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.

Tags: , ,

Enclosures:
[st4u345-iPhone.m4v ( Size: 1182765 )]

posted by James Robertson

 Share Tweet This

Previous Next (554 total)