Category Archives: Software Design

Watching/Reading – Reactive Design Patterns – Cont.

https://www.manning.com/books/reactive-design-patterns

Continuing to read the book and additional notes are,

  • Asynchronous interfaces helps decoupling modules and provides horizontal scalability.
  • Location transparency – By writing the application in a distributed manner, even for the local processing, your application can become resilient to the failure. It makes writing tests easier too.
  • Akka’s Actor systems (http://doc.akka.io/docs/akka/snapshot/scala/actors.html) provides simple interface for message passing between components. It provides simple interface and it makes it easier to tests through stubs/mocks on the interface.
  • You need to work with non-determinism in distributed systems. One approach is explicitly synchronize for avoiding ordering issue. The other is to avoid/isolate computations which will be affected by the computation order.
  • Back-pressure and flow control becomes required between components. Reactive stream (http://www.reactive-streams.org/) is one way to control flow.
  • Netflix is building Chaos Monkey which randomly disabled production instances for ensuring system resiliency (https://github.com/Netflix/SimianArmy).

This book covers various concepts and methodologies for building solid system in a distributed manner. Also, the examples written with Scala is relatively simple and good to understand.

Also, the following coursera courses covers similar topic and would help gaining knowledge on this topic too.

Watching – The Rust Programming Language

It’s a nice introduction presentation for the Rust.

Recently, I restarted exploring new programming languages. One is golang, but also the Rust is often compared with it in system programming area. They shares the concept of providing better C/C++, but they’re taking different approaches, and it’s interesting to see the differences between them.

Some description about ownership in official documentation.

The pointer ownership and borrowing concept is interesting idea for managing object life-cycle properly. Relatively simple restriction in grammar – which does not allow referencing same resource from different location – makes that possible at compile phase.

The functional programming languages provides a secure data sharing in data structure layer, and the Rust is providing at grammatical layer (variable assignments).

It’s a little old data, but the Rust seems one of the actively developed languages.

Mono Timer – Pomodoro-style timer on Ruby on Rails

https://github.com/parroty/mono_timer

Recently, I just learned about Pomodoro Technique, and started applying on my daily life, as indicated in the post before.

There’re many good applications which implements the pomodoro-style timer, but I couldn’t find good one which consistently works on laptop and mobile. Then, I came up to create one for my specific needs, and also for my study on Ruby on Rails application development.

It’s initial implementation yet, but I will be adding some more capability for fighting against my procrastination habits.

Microservices and Coming Archtectures

Software Development in the 21st Century by Martin Fowler

Some watching notes of the above talk. Mostly about first-half of the talk. second-half is more conceptual and couldn’t understand enough.

  • [Around 8:00] Microservice concept affects the team structuring. Instead of having technology oriented team structure like UI, Server and DBA, cross technology members can build a team which responsible end-to-end relatively smaller service product.

  • [Around 8:30] The historical SOA (Service Oriented Architecture) is somewhat similar concept as Microservices, but SOA was focusing too much of smartness in the center of communications which leads to complex structures. Instead, Microservice tries to put the small set of smartness in each endpoint. What’s required is the powerful communication channel between endpoints.

  • [Around 12:00] Infrastructure automations are required for managing many services, with continuous integration or green/blue deployment technologies. Without this backbone, Microservice approach will fail.

  • [Around 14:30] What’s the difference between Microservice and SOA? SOA has too broad meaning, and Microservice concept can be considered as useful subset of SOA.

  • [Around 17:00] How big the Microservice should be? Many organizations are reluctant to answer this question straight. Actually, asking how many people are involved in a service results in wide variety of answers. It’s difficult to find one solution, but amazon’s 2 pizza team is a good notion.

First Step on Learning Haskell

As part of my practicing in functional programming, working on some Haskell program for several weeks. It’s great experience, but the learning cost is pretty high around I/O and Types. I’m pretty much struggling, but there are many nice resource online, and gradually grasping the underling concept.

Especially, http://learnyouahaskell.com/ is a great resource to learn its concept step by step. With some experience on funcational aspect of Erlang/Elixir/Ruby, gradually getting to understand them, though the Monad or IO Action part is difficult to digest yet. Anyway, its declarative expressions are powerful and concise and impressive.

Then, it starts with fibonacci as always.

The pattern match is pretty nice as always. The lazy evaluation and memoziation would be one Haskell’s key factor, and it works nicely.

(on my MacBook Air)

% /usr/bin/time -p runhaskell fib.hs 40
102334155
real        11.71
user        11.49
sys          0.22

% /usr/bin/time -p runhaskell fib_memoize.hs 40
102334155
real         0.30
user         0.16
sys          0.05

References

Ruby Rogues Code Reading – Dotenv

Ruby Rogues Code Reading

A nice code reading session on dotenv by ruby rogues.

dotenv is an environment variable loader for ruby. It’s a simple library, but there’re some edge cases around parsing and loading setting from the .env file, and resulted in a good session about some good ruby techniques.

It talks about

  • difference between protected and private
  • enumerator behaviors with inject and each_with_object method
  • composing complex regexes with multiple sections and recursions
  • parsing quoted and unquoted variables in the .env file

etc.

Looking for another session.

Scala and Monad Tutorial

Scala Monads: Declutter Your Code With Monadic Design

I had been staying out of the keyword “monad” as it’s often described as difficult. But, this tutorial video nicely explains it with concise and clean examples.

It’s interesting to explain monad as “design pattern” in the functional programming world. Also, the example compares normal Java-way of handling null and exceptions with monadic-way ones in Scala.

[Java]

if (foo != null) {
  Bar bar = foo.getBar();
  if (bar != null) {
    Baz baz = bar.getBaz();
    if (baz != null)
      return baz.computer();
    else
      return null;
  }
  else
    return null;
}
else
  return null;

[Scala]

for {
  foo <- maybeFoo
  bar <- foo.bar
  baz <- bar.baz
} yield baz.compute

Pretty much concise. When I was learning Scala at coursera course, I could understand the basics (for statements, Option with Some/None and map/flatmap concepts), but I wasn’t thinking about its underlying concepts like monad. It would be worthwhile to dig-deep a little more.

Watching – The People vs. NoSQL Databases: Panel Discussion

The People vs. NoSQL Databases: Panel Discussion

A little old one, but it’s a nice panel discussion about NoSQL databases. Each participant represents a specific NoSQL database product, but having Martin Fowler additionally helps maintaining the balance between the NoSQL and SQL in a practical way. NoSQL world sometimes criticizes SQL, but many people are accustomed to SQL, and are using them along with certain amount of complaints (maybe as similar way as Java getting criticism, in some sense).

A lot of new data-store options are available lately, along with the various ‘BigData’ requirements and technical transition to distributed systems. As mentioned in the discussion, it’s getting more difficult to choose a data-store which fits all use cases. Even a single application can require multiple different requirements.

NoSQL databases are relatively new and they still require specialists and experts to design into the system properly, due to the different type of complexity. It is largely imposed by the nature of distributed systems, in contrast to their simple data model. It’s pretty much tough to catch up, but this kind of discussion helps understanding the underlying concepts.

Watching – Explaining Agile

Explaining Agile – Martin Fowler and Neil Ford at USI

An explanation of agile process. It’s a little old one (at USI 2010, though it’s uploaded last year), but it’s a nice presentation.

Some notes are,

  • Traditional Plan-Driven approach is “Plan your work. Work your plan”. It’s about making prediction, and its success is evaluated by if it worked as planned. Plan depends on stable requirements. It’s usually hard in software development, and agile development came into play for addressing this issue. Agile development is taking more adaptive approach for removing this dependency itself.
  • Software process tries to fit people as component within the process. However, behaviors of people are not linear, and it’s difficult to predict and be controlled by given process. In the agile practice, people comes first to choose their own process.
  • There are two different approaches – defined process and empirical process. Defined process is to convert the input to output using the pre-defined processing method. Empirical process iteratively adjust the output through the feedback loop of the monitored outputs. If there are large unknowns, empirical approach is more suitable.

Types in Scala and Dotty

http://www.infoq.com/presentations/data-types-issues

Nice talk about the difference in types at different languages from the scala author.

The following category was used for describing static type systems.

  • Type it to the max (Scala, Haskell, OCaml, F#)
  • Cutting corners (Dart, Eiffel, Typescript)
  • My way or the highway (Go, Pascal, Java4)

Interestingly, each of the category has actively developed ones, like Dart, Go, Scala, along with majority languages like C and Java. It would be indicating the difficulty in optimizing the policy for every problems.

As indicated in the presentation, major part of the scala’s complexity may be coming from the types. When I tried some, understanding type error was difficult. The major pain was to identify how to solve them (how to convert one type to another is sometimes difficult).

dotty seems one trial for alleviating the complexity, and code is uploaded in the following GitHub repository.

https://github.com/lampepfl/dotty

Dotty is a platform to try out new language concepts and compiler technologies for Scala. The focus is mainly on simplification. We remove extraneous syntax (e.g. no XML literals), and try to boil down Scala’s types into a smaller set of more fundamental constructors. The theory behind these constructors is researched in DOT, a calculus for dependent object types.