Introduction to React

This is a minimal introduction to React. These are intended to be rough notes for my future self. Any other use is entirely fortuitous.

I have taken the Pluralsight course: https://www.pluralsight.com/courses/react-js-getting-started

This is based upon using the online repl found at:  https://jscomplete.com/repl

// This is a simple function based react component.
// Note that the name of the component has to start with a capital.
// You need to treat the props as immutable.

const MyComponent = (props) => {
  return ( 
{props.greeting} {props.name}
); }; // This is a simple class based React component // State is mutable, but you need to use the setState function // so that the UI will be re-rendered. // The state defined here is a proposed js extension that works through Babel. class App extends React.Component { state = {name: "Fred"}; render() { return (
); }; }; // This is the bootstrap that injects React into a page // Here mountNode is an id of a div ReactDOM.render(<App />, mountNode);

 

So from the above sample a quick comparison of React to AngularJs.

React is a view model that can be injected into a page. It follows functional programming idoms (props are immutable, state is updated by returning deltas that are merged into it). The html is embedded into the script so it does not require a distinct template language. It creates a virtual DOM that is dynamically updated when the data changes.

AngularJs is a full framework with routing, templating. It is typically added via custom tags. The developer needs to cede control of a region of a page to angular. Angular typically has distinct templates that are rendered.

They can be made to play well together – React can act as the View to an Angular application.

Operating a Kubernetes Application via 12 Factor Application

For the last few years I have been working on a suite of Heroku applications (previously Azure had similar functionality).

One of the beauty of these is the separation of config and build. This allows the only difference between environments (for secrets such as db connection strings or feature toggle environment variables) to be a versioned secure set of configuration. Importantly these configs can be changed without rebuilding the code.

Here is an article that discusses the capability of running kubernetes as a 12 factor application.

https://www.mirantis.com/blog/how-do-you-build-12-factor-apps-using-kubernetes/

Looking at Kotlin

I like to keep up with languages.

Currently I am studying too many at once (Elixir, Scala, Haskell) so why not add another one.

This is meant to be a best of breed combination of Scala, Groovy and C#

First thought: It’s the first new language that requires explicit returns. Most recent languages that I have used simply treat the last thing in a function as the result.

I have found the  Kotlin Koans project:

git clone https://github.com/Kotlin/kotlin-koans

Testing Tools Eventually Become Support Tools

I have recently noticed an odd pattern in code that I write.

First I add a helper method to a unit test to speed up setup.

This then become so useful to manual testing that it gets added to the test tools in the UI.

Subsequently the customer service team start to ask about this feature.

The general rule is if it is going to speed up development consider adding the test tool to the customer service ui. Edge cases in code will become customer service wrinkles.

Equivalent Ecosystems: Groovy vs Elixir

Given that a little over two years ago I was a C# developer I have had to learn the JVM way of doing things fairly rapidly. Java does has many ways of solving things but these are those that I am familiar with:

Here is a map between the Java world and the Elixir world

JVM => BEAM

Gradle => Mix

https://search.maven.org/ => https://hex.pm

JUnit => ExUnit

JavaDoc => ExDoc

Dropwizard (or web framework of choice) => Phoenix

Jooq => Ecto