A Clockwork Engineer

Cheat sheet for dotnet cli

Visual Studio is one of the best IDEs in the market. I started to use it when it’s name was Visual Basic. It had the same name with the programming language. Then Visual Studio came out with the support for multiple programming languages. Now, it supports more languanges from outside of the .NET ecosystem and it even has a free version.

Lately, .NET Framework started to transform into .NET Core to meet needs of developers that work on various operating systems. But Visual Studio is really big to port on to the other operating systems. Microsoft created a modern IDE Visual Studio Code which is nothing like Visual Studio and OS agnostic like .NET core. It looks really neat and fun, but you should know some commands to work with it. On the other side, I think, the beautiful Visual Studio -with it’s intellisense menu as well- spoiled us a lot so we did not go much for consoles or terminals like others do.

I am not happy about what they did with dotnet to make backwards compatible but still I love it. I try to specialize on it but remembering those commands that I use once in a while is getting boring and time consuming. I tried to find a cheat sheet but apperantly it is not that popular right now. So I created my own cheat sheet and I hope you enjoy it, too.

You can find it on good old Cheatography or download as PDF.

otomatik muhendis dotnet cli cheat sheet

Source: Microsoft Docs - dotnet command - .NET Core CLI

PS: While I was preparing this cheat sheet, I found a miss typing in the Microsoft documents, just fixed it and my change is on the way to production with Sprint 138.


Freebies for Developers

I have built my first websites on free hosting services like GeoCities and Tripod. I like to apply what I learned instantly and the main purpose of these kind of free services is providing an environment to try our new skills.

Here is a curated list of freebies for developers.

In general, they limit their target area to students but you can be a student at any age. Life-long learning is our motto of life right? After all those engineering bachelor and master’s, I am still a student of photography and cameraman.

Github Student Pack

You can access to this package on https://education.github.com/pack address and I think it is the most comprehensive one. The list is changing with the time but it still has a wide range of products. I suggest you to try all of them.

Microsoft Imagine (previously Dreamspark)

You can see the full product catalog on https://imagine.microsoft.com/en-us/catalog website. It is for generally Microsoft products with a range from tutorials to operating systems.

JetBrains

This was in the Github Student Pack list before. Now, you can through their webpage on https://www.jetbrains.com/student/ link. If you are a strudent then you can get a JetBrains certificate for every usefull product of JetBrains like ReSharper and WebStorm.


Isolating Integration Test Data

When we write an integration test, we should leave the persistence as it was before. I will show you how to do it with NUnit easily.

After covering every corners of our code with unit tests, we can move on to integration tests that we normally test happy path scenarious. If we are using a database as a persistence then we need to run our DML commands backwards. So you should write your CRUD operations for DRUC (delete, read, update and create) as well.

On the other hand, we can use good old TransactionScope in the System library. Thanks to NUnit unit-testing framework, we do not need to initialize a transaciton scope every time we write a test case. We can create an attribute which is inherited ITestAction interface so it would be ran before and after every test case.


Software Craftsmanship

Raising the bar.

For all those companies which are in the middle of agile transformation or transformed already.

As software developers, we have another manifesto that raises the bar a little bit higher over Agile Software Development, that is called Software Craftsmanship and signed by same people who wrote Agile manifesto.

We should start from definitions to understand anything so let’s examine Software Craftsmanship word by word.

Craft

A craft is a profession that requires particular skills and knowledge of skilled work. Software Development is our profession so it is our craft.

Craftsmanship

Craftsmanship is our journey and we can define our journey like;


Code in Stranger Things 2

If you want to break a software’s security pass in early 1980’s, you need to code in BASIC like in the series Deutchland 83

Stranger Things 2 is in 1984 as well so once again we are dealing with some BASIC code.

hawkinsLabSystemsHack.png

As you can clearly see there are nested 4 loops to find 4 digit numbers of the password but interesting part is that there is a misterious function called checkPasswordMatch which gets an integer as a parameter and returns a boolean result. Actually the important part is in that function, the rest that we see on the screen just tries some brute-force attack.


Guru99

Tutorials Library

Guru99 is a website worth to mention. Their comprehensive tutorials contain beautifully annotated screenshots. Their goal is to provide fun and free education for everyone.

Sometimes I prefer video tutorials but they can be time consuming so a source like this is more accesible with its content.

I could only check out their amazing JUnit tutorials for one of my posts called Attributes and Annotations of Testing Frameworks. As a blog writer I can see their effort in it.

The JUnit course covers;

  • JUnit Basics like Introduction, Test framework, Download and Install Guide
  • Introduces Junit Annotation, API, Assert and JUnit Test Suite
  • Advanced topics like Ignore Test, Exception Test, ErrorCollector and Parameterized Test


PostgreSQL Introduction

Postgres Notes of a .NET Developer

This post is continuation of the series. If you do not have Postgres on your machine or sample data, you can read Installing PostgreSQL and Loading Sample Data post first.

First of all, we have to create a schema to manage easily our domain. It is in best practices, do not let dbo schema to seize your database. I use Navicat for my DDL operations but there are free softwares like pgAdmin.

create schema membership;

Functions use dollar signs to show scopes and language keyword for the language in the scope. We have a different datetime type here; TIMESTAMPTZ, timestamp with time zone. You must specify a time zone when inserting into a column with this type. Again, it is a best practice if you have inputs from different timezones. There are several ways to change it; Set timezone = ‘UTC’ in postgresq.conf or on connection, or in your queries.

create or replace function membership.random_string(len int) returns text as
$$
	select substring(md5(random()::text), 0, len) as result;
$$ language sql;

create or replace function membership.the_time() returns TIMESTAMPTZ as
$$
	select now() as result;
$$ language sql;


PostgreSQL as NoSQL

Postgres Notes of a .NET Developer

This post is continuation of the series. If you do not have Postgres on your machine or sample data, you can read Installing PostgreSQL and Loading Sample Data post first.

There are two JSON (JavaScript Object Notation) types for storing JSON data.

The json data type stores an exact copy of the input text, which processing functions must reparse on each execution; while jsonb data is stored in a decomposed binary format that makes it slightly slower to input due to added conversion overhead, but significantly faster to process, since no reparsing is needed.

Create a table with a column with jsonb data type.

create table film_docs(data jsonb);

Insert all the data in the row to that column. The original table comes from the sample data.

insert into film_docs(data)
select row_to_json(film)::jsonb
from film;

select (data ->> 'title') as Title,
(data -> 'length') as Length
from film_docs
where data -> 'title' ? 'Chamber Italian';

There are lots of JSON functions and operators. I think Entity Framework does not have these functions.


PostgreSQL Advanced

Postgres Notes of a .NET Developer

This post is continuation of the series. If you do not have Postgres on your machine or sample data, you can read Installing PostgreSQL and Loading Sample Data post first.

There are functions like date_gt to compare date types.

select * from payment
where date_gt(payment_date::date, '2007-04-01'::date);

You can use date_part to get a part of datetime.

select amount, payment_date, date_part('quarter', payment_date) as quarter, 
date_part('year', payment_date) as year, concat('Q', date_part('quarter', payment_date), '-',
date_part('year', payment_date)) as display_quarter
from payment;

generate_series(start, stop, step) generates a series of values, from start to stop with a step size of step. We need a function like f(x) to get the value. If we use a negative number as step, it will be decreasing.

select x, md5(random()::text) from generate_series(100, 0, -5) as f(x);

select x from generate_series('2001-10-01'::TIMESTAMP, '2002-10-01'::TIMESTAMP, '10 days') as f(x);

postgres_generate_series.png