Wednesday, November 27, 2019

Parallax Scrolling

This seems to be old but gold: Parallax Scrolling.
It is an effect where you push content into different layers and scroll or move them in different speed.

You can see a demo here on w3schools:

The things I found out during research (and that are really new to me) are:

- different speed means also zero speed (static background images are counted as parallax)
- it is not forbidden to create effects on scrolling (so eg: one image can be shown in different situations while the content in the background represents the scenes) AND this is also counted as parallax.
- parallax is still cool :-)

Saturday, April 13, 2019

Over Engineering

Over-Engineering is something most of the developers I know struggle with. Nevertheless, the term is also very subjective. What is over-engineered for developer A might be a perfect strategic step in the right direction for developer B. (in the following section the italic sentences are direct quotes from hackernoon here)

Over-Engineering is subjective and the damage of its subjectiveness increase as the requirements fail to present the full picture of the problem

So to define the term:

Over-Engineering is when someone decides to build more than what is really necessary based on speculation

So if we assume that speculation is the root cause then the following quote is the logical consequence:

To reduce the chances of considering something as Over-Engineering we need to understand the problem and to understand the problem we need to clarify the requirements as much as possible by asking "why"?

But there is more than that... Further Reasons (as described in cloud-foundry on youtube here):

  • consider the data
    • like:
      • how often are things used
      • how often are things changed
      • how long does a process take
      • is the process responsive
      • ...
    • we don't have it (green field, bad data gathering)
      • it might be too early to make a decision for further engineering (refactoring)...
      • will we have the data somewhen?
      • can we ask someone?
        • do we really trust this guy?
    • do we ignore the data and might make bad decisions
    • even if something is crap: 
      • is it worth changing it?
        • return of invest?
      • do we have use-cases that work out better by improving the software
  • unnecessary complexity because of pride
Further reasons (as described in build stuff-youtube here):
  • we are not listening to what we need to deliver (bicycle -> spaceship)
  • frameworks don't deliver value (even if funnier to solve any problem then one specific)
  • business guys are responsive to risk and not preventative so not implementing stuff might be ok for your product owner
  • don't focus on all the things that might go wrong, but recognize that you're still on the happy path (that nothing went wrong right now)

Friday, August 17, 2018

cs-script or compile


today I evaluated how easy it is to compile code in the command line and wanted to compare it to C# interactive window.

This is my generic script to compile

@echo off
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /t:exe /out:output.exe *.cs >nul 2>nul
del output.exe

Consider, I need a fully blows c# file to write hello world to the console:

Something like
// A Hello World! program in C#. using System; namespace HelloWorld { class Hello { static void Main() { Console.WriteLine("Hello World!"); // Keep the console window open in debug mode. Console.WriteLine("Press any key to exit."); Console.ReadKey(); } } }

(see: )

This is a bit much in comparison to (started in developer command prompt):

command: csi csitest.csx
content:     Console.WriteLine("Hello World!");

We definitely have a winner here... 


Friday, June 15, 2018

using angular-cli for vanilla javascript projects

it is very handy to use the angular CLI using "ng serve --open" especially in combination with vs code... the usage of web-pack under the hood (and many more state of the art stuff) are very nice and implement all needed build steps with no effort at all.

For HTML projects consider to use this template too, but reduce it to the following:

* index.html: remove app-root
* main.ts: remove AppModule import and usage and remove app-folder at all
* use style.css as style sheet file
* add a js file and add it to the scripts part in the angular.json (like src/logic.js)

Monday, May 28, 2018

c# string concatenation beyond StringBuilder

I compared in a race with 1 million iterations the execution times of

  1. StringBuilder with an Action call to "Append" a single character (as string)
  2. StringBuilder with a function call to "Append" a single character (as string)
  3. direct string = string + character (as string)
  4. StringBuilder with an Action called to "Append" a single character (as string) but initialized with 1M+1 size
  5. StringBuilder with a direct call to "Append" a single character (as string) initialized
  6. like 5 but a single character is added as a character.

Here the results in ms:

                V5 13
                V4 20
                V6 29
                V2 35
                V1 57
                V3 839343

As we see in V4/5/6 the initialization of a string builder without the need of reallocation is the absolute performance gain by far. The indirection using an action I would consider to be a cheap operation (see 4 vs 5). 

Using a StringBuilder, in this case, is a MUST as we can see it on the scoreboard. 

Interesting is that adding a character instead of a string doubles the execution time.

Comparing 1 and 4 makes it obvious how expensive the allocation of further storage is. 

In V3 garbage collection is called constantly.

While these results differ heavily (especially the numbers of the execution time) from run to run even on the same machine, they differ even more on different machines. Nevertheless, the statements derived are valid.