Monday, September 9, 2019

Flow demoed at Smalltalks2014

 In November 5, 6 and 7th I was at Smalltalks2014 where I presented a talk about Startups and Smalltalk that mentions flow.
I want to say a thanks to the organizers for having me there to bring this topic that gave me the opportunity to share this information among many Smalltalk enthusiasts, but also because I met new friends and found some old ones.
One common theme I've found: I had many great and deep conversations with lots of them. There is something fundamental that is interesting about this technology that seems to make people to be really conscious and thoughtful.
Special thanks to Esteban Maringolo for being a great roommate and pal; to Facundo Vozzi for having big laughs and teaching me about new beers; to Boris Shingarov for deep technical talks about Cathedral's organs and going from the Plank Scale to the Cosmos in half second; to Andrés Valloud for being that pre-adolescent friend sharing games in floppy disks in the 90's rediscovered twenty years later presenting the notion of "the kid's play is the man's work"; to Peter Hatch for amazing deep chats and World Conquer plans and talking about George Carlin!; to Allen and Rebeca Wirsf-Brock for great long chats and being part of this Smalltalk invention and making JavaScript better; to Juan Vuletich for helping to figure out "what should be maximized?" when using Metcalfe's Law and to James Foster that so kindly showing me a fantastic way to work with Gemstone/S.
Thank you guys!!!
As you can see in the slides of the talk, one of the topics is Single Page Applications and flow is actually quite on topic about that. At the end of the day, it was the "Show your projects" section and I demoed flow in about 10 minutes.
It was nicely received and the video of that might actually get published eventually. I'll share it as soon as I have news on that. One thing that is worth mentioning is that, with Esteban Maringolo, we're actually thinking making a Mapless adaptor to Postgres and with the fantastic work of Sebastian Hiedbrink we had a pre-alpha of flow in Gemstone/S.
Can you feel the power?
Excited?
We are!
Here are some photos
Peter Hatch giving his talk about Virtual Machines, Critical Thinking and Reliability
Andrés Valloud and me "twenty years later"
Thanks to Esteban Maringolo for noticing that FAST has its own Chris Anderson in Hernán Wilkinson from 10Pines. You almost can notice how he is mesmerized by Nicolás Papagna's TED-style talk☺
From left to right: Esteban Maringolo, Jannik Laval, Sebastian Sastre, Adam Jacques, Prof. John Sarkela, Josh Fridstorm, Kurt Kilpela and

Controller based title change with Angular

Here is a tip on how to keep nice titles in your AngularJS-based SPA - Single Page Application.
The strategy is this:
  1. Remember current title (whatever it might be)
  2. Set the title to whatever new value you want
  3. Observe when the controller gets destroyed and
  4. React restoring that previous value in the title
controllers.controller('AmazingDetailController', [
    '$scope',
    '$window',
    function ($scope, $window){

      // Sets this controller with the expected initial state
      // and perform any other initial activity needed
      $scope.initialize = function () {

         // Remember the previous title (whatever it might be)
         $scope.previousTitle = $window.document.title;

         $window.document.title = 'Amazing Detail!';

         // Observes $destroy to restore the title of the page to its original
         // value once user navigates out of this controller
         $scope.$on('$destroy', function() {
           $window.document.title = $scope.previousTitle;
         });
      };


      // Does specific behavior 1

      // Does specific behavior 2

      // ...

      // Does specific behavior N


      $scope.initialize();
    }]);
A realistic use will probably be use a model that is coming from a service from the backend (or cache) or collaborating with other objects somehow. But this strategy is still valid, clean and works like a charm.
Enjoy and let me know how it goes for you!

Controller based title change in Angular

Here is a tip on how to keep nice titles in your AngularJS-based SPA - Single Page Application.
The strategy is this:
Remember current title (whatever it might be) Set the title to whatever new value you want Observe when the controller gets destroyed and React restoring that previous value in the title
controllers.controller('AmazingDetailController', [
    '$scope',
    '$window',
    function ($scope, $window){

      // Sets this controller with the expected initial state
      // and perform any other initial activity needed
      $scope.initialize = function () {

         // Remember the previous title (whatever it might be)
         $scope.previousTitle = $window.document.title;

         $window.document.title = 'Amazing Detail!';

         // Observes $destroy to restore the title of the page to its original
         // value once user navigates out of this controller
         $scope.$on('$destroy', function() {
           $window.document.title = $scope.previousTitle;
         });
      };


      // Does specific behavior 1

      // Does specific behavior 2

      // ...

      // Does specific behavior N


      $scope.initialize();
    }]);
A realistic use will probably be use a model that is coming from a service from the backend (or cache) or collaborating with other objects somehow. But this strategy is still valid, clean and works like a charm.
Enjoy and let me know how it goes for you!


App, main and other controller accessors

When I've started flow, one of the features I wanted for it was scaffolding from the front-end and be able to do things like:
Flow scaffold model: #User
or:
Flow scaffold crudFor: #Task
and have created the Model and Controller classes and accessors in environment so you can continue developing the app pulling things from there.
There are several reasons to have scaffolding features, the utilitarian and most pragmatic reason is that it helps you to show something useful fast. A cheap positive feedback loop that allows you to scaffold the next basic feature of your app. That's something really aligned with flow's mission regarding to productivity.
A secondary good reason is that scaffolding makes it easier to spread basic good practices. It shows by example to new people how to get new models and controllers in an application that can scale in complexity with elegance and high maintainability.
But I'm not implementing scaffolding just yet.
The reason why is not being done yet is because we are still in discovery mode of what are those practices. The idea is to really confirm if they are common, general and frequent enough.
In this article, I'm going to share the current best candidates for those good practices. If I'd have to implement the scaffolding system today, I'd make it build the App and its main controller, the main controller accessors, models and router and here I'd show you how. Also we'll cover here what's the suggested convention to name things and why is convenient to do it that way.
App and main Since version 0.2.7, a flow-based application has the idea of App and main. A default clone of the flow repo will use the App class and MainController class for a sample tutorial-like application.
The App class is a convenient starting point to access and "talk with your app" whatever app it is. In flow we asume you'll have to investigate things on your app and its controllers so we are trying to make that easy for you. One way is providing easy navigation. Here is how you access the main controller of your application which is the root of the controller's graph. "Used by index.html to start your app."
App start.
"Deals with routes definition and is part of the starting process of your frontend." App setupRouter.
"Accessor to the instance of MainController of your app." App main.
Take the last one for example, it's 2 words, one of 3 characters the other has 4. Really friendly to type. Amber doesn't have autocomplete so by choosing two short words, we are lowering the friction to access the root controller of your application so you can easily inspect, send commands and see how it reacts. Is safe to say it will be used a lot so you'll profit a lot. For example, an inspect on that code allows you to navigate to any controller that got currently instantiated. That makes easy diagnose possible issues and prototype live-coding the next feature.
The MainController should have as minimum two methods: #home and #reset. You should be able to do:
"Get to the default state on the main controller." App main reset.
"Answers the 'home' controller of the app." App main home.
Here is code that implements the #reset method taken from a real application: MainController>>reset
self navbar deactivateAll.
self hideAllBut: #navbar.
self home show
That reset method makes the app to instantly show the home without any blinks on the screen.
Accessors Now take a look at the #home accessor
MainController>>home "Answers the home controller of the app. Creates it lazily if needed." ^ self ifAbsentAt: #home put: [ HomeController for: model on: self appendingTo: ‘#home-wrapper’ asJQuery ]
So by just naming it with App home, you get it created. Once created, you get that instance as answer every time. That's as close as you can be to zero friction between developer's wish and reality (machine's answer). Just the way things should be. Note we are using here the class method to instantiate controllers: #for:on:appendingTo:
Controller class>>for: aModel on: aParentControllerOrNil appendingTo: aHtmlElement “Answers a new instance of this controller dedicated to aModel, child of aParentControllerOrNil and meant to be appended to aHtmlElement.” ^ self new model: aModel; parent: aParentControllerOrNil; parentElement: aHtmlElement; yourself
Lets take a look at what it expects:
  • In the for: part it expects the model for the new controller
  • In the on: part it expects the parent controller, a MainController in this case.
Note that the parent controller has sense to be nil only when you instantiate the MainController which is a controller that is the root of the whole graph of controllers.
In the appendingTo: part it expects a DOM element to be the parent element of whatever that new controller needs to render. Typically that would be a
with an id named consistently with the controller class name plus the 'wrapper' suffix as you see in that snippet. The tutorial sample application of a default flow clone has 5 subcontrollers covering from the most basic template based controllers to two-way data binding, composition and client-server RESTful interactions. On its MainController you find 5 accessors: example1, example2, etc. up to example5. They all use the same idea of this #home accessor.
Models
Models in flow are really friendly. Creating the class is enough to start using them. They are Mapless objects which means you don't really need to declare in advance what instVars and accessors they need to have in order to be usable by your application. This makes really easy to work in a prototypical way encouraging discovery and experimentation, two really strategic features for innovation projects and startups. Any subclass of Model you add is going to be a Mapless. So basically you only care about the model name and add all your model classes. Later you add the methods that makes them to have special behaviour. As general rule, Mapless don't need setters and getters, they use DNU to get and set automatically whatever you tell them to. They will answer nil when you ask for something they don't have. In the following snippet we create an instance of the Visitor class, we set the language according to the browser and we save it in the backend:
"Create a model of the visitor, set its current language and saves it in the backend." | visitor | visitor := Visitor new. visitor language: window navigator language. visitor save. This feature of DNU and returning nil makes them a bit different if you want to have lazy initializations on some of their properties. How does it look a lazy initialization in a mapless? Here is another example taken from real code: Order>>products "Answers the products in this order. Creates the empty collection if needed." super products ifNil: [ self products: OrderedCollection new ].
^ super products
Routes
Lets dig now on the routing system used in flow applications. It all begins at load time. When the frontend is being loaded by your browser using RequireJS, it comes to a moment where it installs the 'App' package containing the App class and all the other classes and methods of your application.
When Amber installs classes on the package loading process, the classes will receive the initialize message on its class side. If there is none, nothing special will happen but if your class implements it, it will perform those custom actions.
In flow, we use this:
App class>>initialize self setupRouter
So even before he application starts, it already will have the router programmed to react correctly to whatever your app should do with the given initial and following URIs.
Lets see the setupRouter now:
App class>>setupRouter "Program the application reactions for different URI routes." Router rlite "Normalization of the home route." add: ‘’ do: [ :r | Router set: ‘#/home’ ]; add: ‘#’ do: [ :r | Router set: ‘#/home’ ]; add: ‘#/’ do: [ :r | Router set: ‘#/home’ ]; add: ‘/’ do: [ :r | Router set: ‘#/home’ ]; add: ‘home’ do: [ :r | App main reset ]; "Reactions related to Contact models" add: ‘contacts’ do: [ :r | App main showContacts ]; add: ‘contacts/:id’ do: [ :r | Router set: ‘#/contacts/’,r params id,’/view’ ]; add: ‘contacts/new’ do: [ :r | App main showNewContact ]; add: ‘contacts/:id/view’ do: [ :r | App main showContactId: r params id ]; add: ‘contacts/:id/edit’ do: [ :r | App main editContactId: r params id ]; add: ‘products’ do: [ :r | App main showProducts ]; add: ‘products/:id’ do: [ :r | Router set: ‘#/products/’,r params id,’/view’ ]; add: ‘products/:id/view’ do: [ :r | App main showProductId: r params id ]; add: ‘search/:target’ do: [ :r | App main showSearchResultsFor: r params target ]; yourself
At this point you'll see that the code is quite self explanatory which is one of the guiding principles behind flow. In the same way this example uses #showNewContact, #showContactId: and editContactId: you would do different routes for different models on your own application. Bonus As a bonus, here is how #editContactId: looks like:
MainController>>editContactId: anId self hideAllBut: #navbar. self contactEditor editId: anId
The editor accessor that you already can infer:
MainController>>contactEditor
^ self ifAbsentAt: #contactEditor put: [ ContactEditorController on: self appendingTo: ‘#contact-editor-wrapper’ asJQuery ]
The #editId: on the editor controller taking the model from the backend:
ContactEditorController>>editId: anId
self showPreloader. Person findOne: #{ ‘_id’ -> anId } then: [ :person | self editContact: person. self hidePreloader ] ifNone: [ ] onError: [ :res | self showError ]
And finally:
ContactEditorController>>editContact: aPerson
self model: aPerson. self show done: [ "specific stuff" ]
The #show method in Controller always return a promise so you can do your own custom stuff when the view gets created asynchronously without complicating your code. So we don't have yet scaffolding today (January 2015) but I hope this article encourages you to write highly readable code on flow.
Happy coding!

flow

I’m starting this blog here to make a coder-friendly open conversation with contributors and enthusiasts about flow’s design.
This blog will be doing two things in one move:
  1. A source of fresh input, so feedback, so inspiration.
  2. An output about progress on this line of work, so relevance of the mission.
But lets back up a bit, what is flow after all?
I like to say that flow is a mission with a framework.
Here is flow’s mission from the project’s readme:
flow’s mission is to provide consultants, startups and software houses with a competitive Smalltalk full-stack framework that allows them to quickly deliver a demo with all the modern html5 features the market expects today (2014). The idea is that they can tactically use this framework to keep momentum up among their prospects and clients and scale things to full successful projects delivered by kickass productive teams or individuals.
Why Smalltalk you might ask? Is a great question that should be experienced more than described, but if I have to tell you only three things about it, they will be around flow the psychological phenomenon embedded into the principles of design of Smalltalk itself and I particularly want to highlight that they help with:
*Intuition Instant feedback (discovery) Personal mastery *
Does that resonate in you? I encourage you to join this effort!
It’s all open source, MIT License, and the project's Kanban is being organized in this open board you can join here. By the way, I had the chance to presented flow at CampSmalltalkVI2014, big thanks to Sebastian Heidbrink for the hard work of organizing it and the invite!
There is no video about the talk but here are some slides I’ve made for it:
flow: a living full-stack ‎framework for the web
~900 views in a couple of days, and many shares? That’s a nice signal that we might just be into something here Beside a nice quantity of views on those slides what I like is the offline reception of the project and how people reacts to it during the few pairing session I had showing it. People is asking for the petshop sample app already!
I have concrete needs of my own with the framework, mostly being pulled by my clients and projects. That's great because is validated needs that will eventually cascade features to the framework. So all that is expected to be a major drive of course.
At the same time I'm interested in innovation in general and how talented individuals and teams deal with innovation for their needs so I’m curious about how would you push this mission forward. I see this blog like a good opportunity to ask design questions and talk about it.
In the next posts I'll write about the current technical challenges and hopefully you might have good ideas to share on how to face them best.
I'd like to expose things so people can understand why flow is a curated project and how it's being done.
But before digging ourselves into tech stuff too soon, let me ask you…
What do you think about the mission?
How would you use it?
If not, what stops you in using it? What bumps or showstoppers have you found?
Have your clients asked you to do Single Page Applications for them?

The way you understood it wrong

When I was doing engineering, I had a very good algebra teacher.* Those where the days full of vectors and subspaces and subspaces of polynomials and matrices and subspaces of matrices of polynomials.
All from 7 a.m to 12 p.m.
In the middle of that math trench he said once something that my head really saved.
The teacher was explaining yet another concept while the sky was still dark in the morning and there was this guy that asked him to clarify a detail.
The question was asked and the teacher clarified.
He was a good teacher so, before moving on, he asked to this student if the idea was now understood.
He wanted this student validation.
The guy said ‘yes’ and right away this student started to describe all sorts of details about how he was reaching to the wrong conclusions by following an alternative reasoning based on the wrong assumptions he had while not having clear what he later asked about.
The teacher stopped him saying something I've never forgot:
No, no, wait, wait. Please do not explain me how you understood it wrong. Tell me instead how you're going to remember it right.

Update: together with my good friend Pablo Dobrusin we joined efforts and figured out who the teacher was, he was Fernando Acero at FIUBA - Facultad de Ingeniería Universidad de Buenos Aires.
Timeless insight.
Hats off to teachers like that.


Context is King

When you trust your content is when you can forget it. At that point you’ll get that Context is King.
…to make a Leonardo you need more than his innate ability. You also need Florence in 1450. Paul Graham.
Yes I know… we are not da Vinci, we don’t have Florence in 1450 nor we have a Medici patron for our talent.
Florence in 1450 is context. The problem is that without an appropriate context talent is useless. To be fair, not useless but seriously compromised. That’s why talented people want to run away from places that are hostile to their talent and, the opposite of that problem: knowing how to build appropriated contexts will cultivate talent and open you more doors than working on the content. The good part: today is simpler and cheaper to build desirable contexts so wealth creation can find its way to be deployed in the world.
Some examples:
  • A blank sheet of paper, something to write and a pleasant ambiance.
  • Your laptop + WiFi in an inspiring coffehouse.
  • To be able to write about high culture in a conversational tone.
  • A great story for you blog or, way better, book chapter.
  • When the world gives you the present of a synchronicity or a serendipity.
  • Your sketching tools and your favorite music in the background.
  • Finding the layout that works.
  • Your design when it has your rules and honors the basic principles at the same time.
  • To fit that image in the rule of thirds. And the right light and shadows!
  • When you make your model feeling natural and engaged during the shots.
  • Your camera and accessories in an historical moment.
  • To be able to capture technically well without being distracted by technical stuff.
  • When you can make your actors to inspire one to each other when filming.
  • Your musical instrument and a couple of friends.
  • To relax before an audition confident on your practices.
  • The visual finalization details of your site.
  • The usability of your application.
  • The ambiance you were able to architect.
  • A customer has a problem you can help with.
  • The results created by your movement before asking for donations.
  • To say “hello” with a sincere smile.
  • To listen your interlocutor’s problem.
  • To ask the right question.
  • When you renew the inspiration and hope of a member of your community.
  • Your intervention adding momentum to a project.
Because context is dynamic in nature, it can be very brief. When you get one that works take advantage of it putting all the momentum in the substance and commit to the truth. If you do that you can be sure you will be closer to some valuable things:
The identity of what you provide will be faithful to what you are.
Your talents will have a better chance to shine over their opposite keeping what you don’t like in you at a safe distance. When something you don't like comes up, the feedback will be more useful because is the right input on the right problem, which leads to good diagnosis and good reviews and solutions.
Ultimately this is useful because all the contexts you manage to build are the real signature of your consciusness and you can be familiar with it while, unfortunately, most people don’t even know they have one.
Originally published in July 7, 2009. Reviewed in November 17, 2017