Posts and articles in English

Kubernetes Dictionary

  • CNI / CSI—The container networking and storage interfaces. Allow for pluggable networking and storage for Pods (containers) that run in Kubernetes.
  • Container—A Docker or OCI image that typically runs an application.
  • Control plane—The brains of a Kubernetes cluster, where scheduling of containers and managing all Kubernetes objects takes place (sometimes referred to as Masters).
  • DaemonSet—Like a deployment, but it runs on every node of a cluster.
  • Deployment—A collection of Pods that is managed by Kubernetes.
  • kubectl—The command-line tool for talking to the Kubernetes control plane.
  • kubelet—The Kubernetes agent that runs on your cluster nodes. It does what the control plane needs it to do.
  • Node—A machine that runs a kubelet process.
  • OCI—The common image format for building executable, self-contained applications. Also referred to as Docker images.
  • Pod—The Kubernetes object that encapsulates a running container.

Resource: Core Kubernetes, by Christopher Love

Continue Reading Kubernetes Dictionary

Pattern matching beyond the statement

The pattern matching in Java 17 reduces the boilerplate code by removing the convertion step.

What interesting is the extended scope of pattern created variable. The function whatIsIt1 has a if block, but the airplane and ship variables are extended out of if scope.

import java.time.LocalDate;

public class App {
  public static void main(String[] args) {
      var app = new App();
      var t1 = new Titanic();
      var b1 = new Boing();

      app.whatIsIt(t1);
      app.whatIsIt(b1);
      app.whatIsIt1(t1);
      app.whatIsIt1(b1);
  }

    public void whatIsIt(Object obj) {
      if ( obj instanceof Airplane airplane )
        System.out.println(airplane.name);
      else if (obj instanceof Ship ship ) {
        System.out.println(ship.name);
      }
      else 
        System.out.println("I Don't Know");
    }

    public void whatIsIt1(Object obj) {
      if ( !(obj instanceof Airplane airplane)) {
        if ( !(obj instanceof Ship ship )) {
          System.out.println("I Don't Know");
          return;
        }

        System.out.println(ship.name);
        return; 
      }
      
      System.out.println(airplane.name);
    }

    static class Airplane {
      public String name = "Airplane";
    }

    static class Ship {
      public String name = "Ship";
    }

    static class Boing extends Airplane {

    }

    static class Titanic extends Ship {

    }
}
Continue Reading Pattern matching beyond the statement

All cases of the switch will be printed

Strange, but in Java that’s how switch works.

In the following program, once numOfballs falls in the 1st case, all the rst cases will be visited regardless the condition.


public class App {
    public static void main(String[] args) {

      var numOfBalls = 1;
      switch (numOfBalls) {
          case 1:  System.out.println("One ball");
          case 2:  System.out.println("Two balls");
          case 3:  System.out.println("Three balls");
          case 4:  System.out.println("Four balls");
          case 5:  System.out.println("Five balls");
      } 
    }
}

Continue Reading All cases of the switch will be printed

Done! Course 2 – Improving Deep Neural Networks: Hyperparameter Tuning, Regularization and Optimization.

I just recently reached an additional milestone by finishing the 2nd course of Deep Learning AI specialization – Improving Deep Neural Networks: Hyperparameter Tuning, Regularization and Optimization.

This course dived into the core of deep learning by understanding performance drivers, analyzing bias/variance, and implementing neural networks using TensorFlow, as well as the skills in regularization techniques, optimization algorithms, and hyperparameter tuning for optimal AI applications.

Continue Reading Done! Course 2 – Improving Deep Neural Networks: Hyperparameter Tuning, Regularization and Optimization.

About debugging, by Elliot, Mr. Robot

“Must cutters think debugging is about fixing a mistake. But that’s boolshit. Debugging is actually all about finding the bug about understanding why the bug was there to begin with; about knowing that its existence was no accident, came here to deliver a message like an unconsious bubble floating to the surface, popping with a relevation you secretly kwown all along.” (Elliot)

Continue Reading About debugging, by Elliot, Mr. Robot

Dart: Factory Constrcutor

Constructors in Dart are very flexible, allowing definition default or named constructor with positional or named parameters, optional, required or default values. 

				
					abstract class IHello {                 // Define interface
    String sayHello(String msg);    
    factory IHello() {                  // factory constructor returns
        return new Hello();             // instance of Hello
    }
}
class Hello implements IHello {
  sayHello(String name) {
    return "Hello $name";
  }
}
main() {
    IHello myHello = new IHello();
    var msg = myHello.sayHello("John");
    print(msg);
}

				
			
Continue Reading Dart: Factory Constrcutor

Dart class

In this basic example, I am using as most as possible features of basic features of the class definition in Flutter. 

				
					class Hello {
  var hello;                          // public
  var _name;                          // private
  sayHello() {
    return "$hello ${this.name}";     // string iterpolation
  }
  get name => _name;                  // getter
  set name(value) => _name = value;   // setter 
}
 main() {
   var cHello = "Hello";              // no type annotation
   final String cName = "John";       // typed annotation + final 
    var myHello = new Hello();        // instance creator
    myHello.hello = cHello;           // assignments
    myHello.name = cName;
    print(myHello.sayHello());
}
				
			
Continue Reading Dart class

Dart is awesome

I recently started working with Flutter by creating my first mobile application for the company’s hackathon.

Prior, I took the course in O’Reilly, which amazingly introduced me to the world of “one code – multiple platforms”.

Flutter is the whole story and requires a separate post.

In the few posts, I’d like to share my expression from the Dart language – which is the language of programming for Flutter apps.

What is Dart

Dart is a programming language designed for client development,[8][9] such as for the web and mobile apps. It is developed by Google and can also be used to build server and desktop applications.
It is an object-orientedclass-basedgarbage-collected language with C-style syntax.[10] It can compile to either native code or JavaScript, and supports interfacesmixinsabstract classesreified generics and type inference.[11]

Wikipedia

The Flutter multi-platform applications are programmed with Dart.

Dart code can be easily converted to JavaScript using dart2js tool.

There is a huge similarity between Dart syntax and Java and JavaScript languages as well as implemented features from other languages like Python.

While JavaScript implements the OOP principles prototypical, the syntax of Dart, is very close to Java with some additional possibilities (like positional and named parameters constructor, default values).

The ease of working with JSON structures and working with them as a Dart object.

Mixins, the widely used feature in Python, can be easily implemented in Dart as, one of the solutions, for multiple inheritances.

Concurrency is another important feature for developing powerful applications. Here, the syntax is also very similar.

String interpolation is the easy and clear way of constructing dynamic contents.

Example

main() {
var h = “Hello”;
final w = “Hello”;
print(‘$h $w’);

print(r’no interpolation for $h $w’);

var hello = ‘Adjusting’ ‘String’;
print(hello);

print(‘${hello.toUpperCase()}’);
print(‘The answer is ${5 + 10}’);


var multiline = “””
This is
miltiline “””;
print(multiline);
}

Dart basic code “Hello World”

Reference

Dart Language Tour by dart.com

Dart in action, by Chris Buckett

Continue Reading Dart is awesome

Effective Java practice is starting

Effective Java, the book of Joshua Bloch, is a classic of Java literature. As the book’s preface put it:

If you have ever studied a second language yourself and then tried to use i toutside the class-room, you kjnow that there are three things you must master: how the lanaguage is structured (grammar), how to name things you want to talk about (vocabulary), and the customary and effective ways to say everyday things (usage)…
It is much the same with a programming language. You need to understand the core language: is it algorithmic, functional, object-oriented? You need to know the vocabulary: what data structures, operations, and facilities are provided by the standard libraries? And you need to be familiar with the customary and effective ways to structure your code…
This book addresses your third need: Customeary and effective usage.

I believe every programmer should go through the best books every few years and refine its techniques and best-practice.

In this thread, I will cover the practical examples and practices from the items of the book.

Continue Reading Effective Java practice is starting