Ionic Monorepos with NX

Today I am writing about Ionic and how to use it with NX. As I explained in previous posts Ionic enables you to write Angular code that can be used as the base for Android/iOS applications. So it enables you to write code that can be shared across all plattforms, which is a great opportunity. Together we will create a Nx monorepo which contains an Ionic application and can be extended very easily. You can find the code in my Github repo.

Why do we need Monorepos for creating this type of application? For many applications you not only need a frontend but also some backend functionality. In some businesses you might also have severall applications created in a project, something like a mobile app, a administrative application and so on. Most of the time you share functionality across both applications. To face that challange there are different approaches, one are node libraries which are shared across both applications. Another one would be to use Microfrontends and bundleling those frontends to two different applications. The third option is to create monorepos. All three approaches have pros and cons, however, if you have one or two frontend applications and maybe a Javascript backend application monorepos might be a good option for you. In general a monorepo is a project, that contains different projects and some shared functionality. NX is the framework that is used most the time in Angular projects. NX also creates configs for TypeScript, EsLint, Webpack and so on. So it provides a base to create extendable and maintainable applications that are consistent.

Basic setup

To start you need to have a running Node enviroment with an installed npx version. You can install npx by using npm i npx

Nx has in general some plugins that are summarized by Nxtend. Those are built to create specific type of applications in a NX enviroment. For instance, there is the @nxtend/ionic-angular plugin or a plugin for creating Nest backend applications.

To start of our application we need to create an empty nx workspace. That is done using the following command:

npx create-nx-workspace my-org --preset=empty

After typing in that command you might get asked if you want to use nx cloud. For this post I did not use that type of configuration. After the command is completed you will see an empty workspace that was created for you. This workspace does not contain of any application yet. If you have a short look into the created project you will see that the structure is a little bit different from normal Angular applications. Of course, you have a package.json but also there is no src directory. There is however an apps folder as well as a libs folder. The apps folder will later contain our applications and the libs folder can be used to create shared libraries. Also you might notice the jest.config files, that is because Nx is using Jest as the default test runner for unit tests.

Generating applications

I will create an Ionic application that uses Capacitor here. First of all we need to install the Nxtend Ionic Angular dependency and initialize it:

npm install --save-dev @nxtend/ionic-angular

In order to be able to use nx as a npm command I extend the package.json with the following script:

....
"scripts": {
  ....
  "nx": "nx"
},
....


npm run nx generate @nxtend/ionic-angular:init

After executing these two commands you can generate the new application:

npm run nx generate @nxtend/ionic-angular:app demo-app

Great! Now we have created our Ionic application in our Nx workspace. If you have a look into the code you will see that there is now a new folder in the apps which contains the demo-app. Also nx has created an E2E testing project for us that contains everything to get started with E2E testing with Cypress, great, isn’t it?

Now let’s have a look into the created application. Type in the following command to start a debug version of the app:

npm run nx serve my-app

It is possible that you see the following error after typing in that command:

Property 'name' has no initializer and is not definitely assigned in the constructor.

This is because of the default tsconfig which forces you to initialize all variables. To get rid of that error you need to go to the tsconfig.base.json and add that line to the compiler options:

"strictPropertyInitialization": false

After running the nx serve command again the compilation should work and you can checkout your awesome application.

Creating the Android app

Next, we want to create the Android app out of the code that we have so far. For doing that we need to build the app and than add the android plattform. For building the app you can call nx build demo-app. Also it is a good idea to extend the package.json with a script that is doing that in the future for us:

"scripts": {
  ...
  "build:demo": "nx build demo-app",
  ...
},

To add the android project you need to run the following command:

npm run nx run demo-app:add:android

This will create an android folder within the demo-app. This is used to create the APK. If you want to create iOS apps you can run the command

npm run nx run demo-app:add:ios

To open the app you need to call npm run nx run demo-app:open:android. Here I also suggest to add that script to package.json:

"name": "ionic-workspace",
"version": "0.0.0",
"license": "MIT",
"scripts": {
  ...
  "open:demo:android": "nx run demo-app:open:android",
  ...
},

If the code is changed you need to copy the new code to the android app. That is done using the command npm run nx run demo-app:copy:android. I also add that script to the package.json:

"scripts": {
  ...
  "copy:demo:android": "nx run demo-app:copy:android",
  ...
},

Creating shared libs

In the introduction I already explained that nx provides a possibility to create shared libraries that may contain shared functionality or model classes shared in different projects. To create the lib you simply need to type in the following command: npm run nx generate @nrwl/angular:library shared-lib

This command will setup everything so that you can simply use that lib. As already explained, libraries are created in the libs folder. After you create some class you will see the true magic of Nx, there is no need to recompile the library or add some package to a npm repository. You can simply import the created class if it is added to the index.ts of the lib:

import { ExampleSharedClass} from '@ionic-workspace/shared-lib';

Conclusion

As you see from that blog post, it is really simple to use Nx for Ionic Angular applications. Nx will bring you a scalable application with very useful preconfigured parts. That is why I would suggest using Nx for your next project if it fits to your requirements.

What do you think about using Ionic with Nx? Have you used Nx in the past? Was it useful to you?

Why automated E2E testing is essential for a valid agile process

Automated End to end testing (E2E) is something that you as a software developer should at least have heart multiple times about. This topic is always something that has haters and supporters but it is an important one anyway. Most of the people I know are not a big fan of E2E testing because of all the effort it occurs together with the dependencies you need to consider. In this blog post I will discuss why the effort is worth it and why agile development principles need E2E testing to work in a propriate way.

Let’s start with a very provocative sentence: Without E2E testing you cannot have reliable and a working continues deployment. Continues deployment describes the process of trying to deploy new releases in a continues way, so you will not have the big bang one time but you are going to deliver software every time a feature is ready for testing. Something that is essential if you are living agile development correctly as customer integration is a core part of that way of software development. But what does that mean? After every sprint, so every 1-3 weeks you need to deliver working software to the customer. Nothing worse if you are a one man development team which delivery is just a zip with one web app folder. But this is alone a pretty big deal if you have many development teams working on a microservice architecture. In such a scenario you need some kind of automation when something is ready for deployment as well as some kind of automation in terms of how the software gets ready for the customer. And in automation you always need some kind of validation, a way to have that kind of automation is E2E testing.

First of all what does E2E testing mean? E2E testing is the process of testing the whole application. So in contrast to unit testing where you just check if a granular part of the application works in E2E testing you check if the whole application works with the interactions the user might do. In a typical web application which has a registration form that would cover an automatic interaction with the GUI which the user fills out to register as well as the storing of the user and the email confirmation process. So to cover that scenario you need the whole application being set up.

What are the parts you need to consider when you decide to doing E2E testing? First of all the whole application needs to be setup in way that E2E testing is possible. If you have a web app ids on the HTML elements are very important as it is extremely difficult to address a specific element if you don’t have that. If there are no ids you would need to formulate a xpath query which is sometimes not only difficult but also might result in multiple results. Also such queries need to be adopted when something changes in the web app.

Next it is important that you need to specify when your app should be tested automatically. That is a topic for the build pipeline which needs an extra step for E2E testing which covers the setup, the execution and the clean up of the tests. Such a build step should not be a part of the actual application build process as it needs some time and a goal for efficient automatic build pipelines is that developers get feedback quick. So a typical way is that first the application gets build and pushed to a global repository (for instance Nexus) and then the E2E testing process starts.

Also you need to specify when E2E testing is necessary. As E2E testing is an effort it is typically a specify user story task. And also not always it makes sense. The discussion whether or not the user story needs E2E testing needs to take place in a meeting where the development team, testers and the PO sits together as it needs all the different opinions. A meeting which is ideal for that is a refinement. Typically you need to do E2E testing in case you have repetitive work like signing up for an application or creating some sort of general entities. More complex processes which need to be thought througth are done by manual testers. The aim of E2E testing is not to replace manual testing but to let them do the important work!

Next question might be who is responsible for creating those E2E tests as normally you need to create code for that. In my opinion creating E2E tests is a task for software developers but in a big company you might think of having employees with special know-how in E2E testing so that difficult tests can be created by them. But software developers should also create those tests so that everybody understand why something needs to be coded in a certain way (like having ids on HTML elements). Software developers are also responsible of making sure that new features do not destroy E2E tests. That in mind when estimating a new feature it is also important to think of which test might be affected.

But what has that to do with agile development? I agree that E2E testing should also be done in other software development processes. But especially for agile development principles it is important to have automated E2E tests. To understand that, you first need to think why E2E testing is done? To increase application quality, as everytime when you do tests. In agile development high quality software is important as too many bugs will result in problems when it gets to reaching sprint goals. And manual testers have lot of work to do, so they should not retest basic functionality all the time. If manual testers can focus on complex work they will find more relevant issues and this can only be done when you reduce other tasks they might need to do. Also you can make sure that the customer will not discover basic bugs when rolling out the new release as tests have checked that before.

So that is my opinion on E2E testing. It is a lot of effort but it is still worth it. What do you think about that topic?

Angular best practises, or what goes wrong when designing an Angular application

Hola a todos!

A new day and a new blog post. There are thousands of tutorials out there on how to implement Angular apps. But when you get into a situation where you need to think of a nice architecture for a B2B application, tutorials and blog posts get rear. Actually that situation is clear because of the fact that to be a good software architect you need experience on real world scenarios. However, as I saw some typical errors in the past many times in the different projects I was working on, I thought that it would be a good idea to talk about those architectural errors and how to solve them typically.

This blog post need some kind of basic Angular knowhow because I will not explain basic Angular things in detail but before jumping into some best practises for Angular, first things first, a quick recap what this framework is about. With Angular you have a rich typescript based frontend framework that enables you to create web applications in a structured way. Therefore Angular provides the following main parts (I know, this description is a very short one but I would like to focus on the architectural perspective in this post):

  • Components
    Components are parts of the application. A component can be anything, from a small button to a complex side made out of different components.
  • Services
    In services you capture business logic. So services are typically used to hold data for the app, communicate to backend services or to manipulate data.
  • Modules
    Modules are combined components and there needed services. So you can understand a module as a group of components.

Best Practise #1: Use base components

Let’s start with components and how to structure them. In most applications you get some requirements that are the same all over the whole application. For instance, if you display data somewhere (which is pretty likeable) mostly you need to add some data tables or data grid. First error that I see very often is the not using of specific components for an element in the UI.

Let me show that by a quick example:
It is very likely that users need to input data into your app. To do that you need some input fields. In Angular creating input fields is obviously very easy, something like the following:

<input class="form-check-input" id="textInput" [(ngModel)]="textVariable" type="text">
<label class="form-check-label" for="textInput">
  Enter text
</label>

Nothing spectacular so far. In a business application you will need plenty of such input fields. If you are implementing it everytime in above way you probably going to end up with different ways of implenting the input field, one may have a placeholder, one may have no id, one may not even have a databinding but is storing the data by a (change) event. So it will be very difficult to be maintained in the future. It is also likely that you get problems when you get a new requirement for all instances of inputs, something like “We need a check on the length of inputs of text fields” because then you need to go over every single instance which is timeconsuming.

A better way is using whenever possible base components that are used by the application. Creating such a base component, is of course, not always straight forward as the component should be used by different scenarious. But this effort will count out later when your app’s complexity increases. By creating a base component You will also capsulate a frontend library from the rest of the app, that means you are able to switch it when neccessary by only adopting one class instead of many classes.

When designing the component you should think of what the needed inputs and outputs of a component are. A textfield needs some kind of configuration (label, placeholder,…) and should emit changes to the parent so that it is possible to use the entered text somewhere. A button might have some event that is sent to the parent when clicked. The most important thing here is that you are documenting the inputs and outputs of the base component.

One example of a framework that supports the kind of capsulation that I explaned is storybook. It has documentation features but also it enables you to preview single components and their behaviour.

Best Practise #2: Do not forget about object oriented programming (OOP) when implementing components

Yeah, OOP is definetively something you had learnt in the past. But during the work we do and especially during stressful situations we tend to forget about the basic principles of software engineering. One is to think about how to solve the problem before you start doing something. Another one is the use of object oriented design patters.

Components cover some kind of logic. Often you need some injected classes all over the whole application (for instance a logger which is needed everywhere). In some applications you also need some kind of setup before the component is rendered. To cover such a requirement it is very recommendable to use a base class which is extended by the different components in the app.

My example should describe the mentioned best practice by using a simple logger which is used everytime to log when a component is created. This should just explain the concept, in business applications you are more likely to load a some user information or initiate services but you can use the base component concept for these problems too.

// what to avoid
@Component({
  selector: 'app-somecomponenta',
  templateUrl: './somecomponenta.component.html',
  styleUrls: ['./somecomponenta.component.page.scss'],
})
export class SomeComponentA implements OnInit {
   constructor(private logger: MyLogger) {}

   ngOnInit() {

     this.logger.log('Component was created');
  }
}

@Component({
  selector: 'app-somecomponentb',
  templateUrl: './somecomponentb.component.html',
  styleUrls: ['./somecomponentb.component.page.scss'],
})
export class SomeComponentB implements OnInit {
   constructor(private logger: MyLogger) {}

   ngOnInit() {

     this.logger.log('Component was created');
  }
}

The better way to do it is creating a base component. To create the logger instance I use the Injector class. By doing that I avoid problems when we need to extend the base class later by other injected services because in such a case you would need to change all constructors of implementations of the base class which is not a good idea.

export abstract class BaseComponent implements OnInit {
     protected logger: MyLogger;
     constructor(injector: Injector) {
        this.logger = injector.get(MyLogger);
     }

     ngOnInit() {
        this.logger.log('Component was created');
        this.componentCreated();
     }

    abstract componentCreated(): void;
}

@Component({
  selector: 'app-somecomponenta',
  templateUrl: './somecomponenta.component.html',
  styleUrls: ['./somecomponenta.component.page.scss'],
})
export class SomeComponentA extends BaseComponent {
   constructor(injector: MyLogger) {
      super(injector);
   }

   componentCreated() {

     // custom implementation to set everything up
  }
}

@Component({
  selector: 'app-somecomponentb',
  templateUrl: './somecomponentb.component.html',
  styleUrls: ['./somecomponentb.component.page.scss'],
})
export class SomeComponentB extends BaseComponent {
   constructor(injector: MyLogger) {
      super(injector);
   }

   ngOnInit() {

     // custom implementation to set everything up
  }
}

Best Practise #3: Use and documentate a clear application structure

Angular provides a structured way of creating apps. But still there are many possabilities to create components, modules and their dependencies. So in the beginning of the app is very important to specify how the code of the app should be structured. You need to think of where you put base components, model classes, services and how to create pages with different components. You also have to think of how you are grouping the components in modules. A clear structure will help new developers get in the project faster and also you will find an implementation faster if you have a clear structure.

One pattern that I use very often is the following:

  • Base module
    In this directory I put in everything which is used by many/all components. For instance if you are not using libaries the global logger should be put in somewhere. This module can be importated by other modules.
  • Basic component modules
    For all basic component implementations (button, datagrid, input field, etc.) I would recommend to create a module for each. That will enable you to import only components you will need in the app and so you will be able to make a page loaded faster.
  • A module per menu
    In your app you will have a variety of menues. A good pattern is to create a module for every main screen you have. This screen can, of course, contain a variety of components (lists, detail views, popups, etc.). But grouping all of them is definetivly a good idea. If you are using the Router it is actually essential to use that pattern.
  • Services and data model classes
    Placing services is most of the times a bit more complicated. This is because the same service might be used by a variety of screens. But also, some services might be assigned to exactly one component. So, for services there is no “right or false” but I think it is a good idea to create the service near to the place where it is needed. For instance, if a component is using the service you might end up better if the service is next to the component.
    The same applies to model classes. If you have a shopping list component the shopping list item should be located in the same module.

Best Practise #4: Create small components

Components can end up with many lines of code. Sometimes you have many functionalities it must cover, sometimes you need to put everything together. But big sourcecode classes are difficult to understand, difficult to be tested and more difficult to be fixed when something goes wrong.

Therefore I recommend to make sure that a component don’t get too complex. As I explaned already, use your understanding of OOP to create components with a specifc purpose. Many programmers are complaining about legacy source code basis which are difficult to be maintained, but do not forget to keep attention on not also creating such a legacy code base for future software developers. Angular provides everything to create a clear structure but still you can end up in a big mess.

To create smaller components there are severall possabilites. One is to split the component into serverall small components. For instance, it does not make a lot of sense to put into a component the menu together with all its popup dialogs. It is better to create a component for each popup dialog. That will increase readability of the code and maybe you find out that you can reuse a dialog from somewhere else by doing that practise.

Another option to reduce the amount of code lines is to create service classes for a component. That is a good idea if your component has lot of logic it must cover. One example where I implemented such a thing is a datagrid which is on the one hand displaying data sets but is also performing the data requests. In such a scenario it is an idea to split the code logic into ui logic and business logic, so to create a service that handles the user interaction, create a class that handles the data requests and let the component only display it. You can use the MVVM pattern to design such kind of components.

Important to know is that you are using the same pattern all over an application. If you use one pattern for problem A and another one for another problem it will be difficult to understand what is going on in the component.

Best Practise #5: Create a unit test base libarary

As I explaned in my article about TDD (TDD sucks), testing is complex and needs time. But it is important to provide a good software quality. To make it easier to create a test a good approach is to provide a library which supports developers to create unit tests. One example would be a method which can be used to create the setup for components. Another method could provide all the things we need to provide for jasmine.js to be able to setup the component (change detection etc.). The main goal here is to make testing easier. That totally depends on the case but you should make your and your collegues life easier by adding such implementations to your project.

Best Practise #6: Use one css framework, not all of them

With Angular you get many css frameworks which are doing most of the work for you. That is fantastic! But not every css framework provides a solution for every job. Many times unexperienced developers are then googling for the next framework that provides the solution. Nothing wrong with that, but a library should only be choosen by criteria and not by intention. A new library brings in new functionalities but it also brings in a new bundle size, so a bigger application. That means that your application will take longer to load which means that the user experience is being decreased. Also, if you have different libraries providing the same feature (for instance a handsome button) developers are going to use both libraries which means that the user gets not one type of button but two. That will again, decrease the user experience.

If you want to create an application that should be used on android devices like a native app, use the material design libarary, if you create a rich business application use PrimeNg or KendoUi but do not mix them.

Best Practise #7: Create a base service which is used to perform HTTP requests

In applications you need to communicate to some sort of backend. Normally you need to perform REST requests to do that. Angular provides a base http client but this http client can be used in different ways. Also you may need to add some common headers in all of your REST calls. Most of the time error handlings or caching must also be done everytime a REST call is made. Therefore it is generally a good practice to create a base class which is always used to communicate with rest endpoints.

One very simple example would be the following:

@Injectable()
export class GenericRestConsumer {
    private baseUrl: string;

    constructor( protected httpClient: HttpClient) {
      this.baseUrl = environment.baseUrl;
    }

    /**
     * Will perform a get request.
     * @param path the path to be used.
     */
    get<T>(path: string) {
        const headers = this.setStandardHeaders();
        const url = this.baseUrl + path;
        return this.httpClient.get<T>(url, { headers: headers });
    }

   setStandardHeaders(apiType: TypeOfAPI): HttpHeaders {
      // Some standard headers that must be set all the time
      const headers: HttpHeaders = new HttpHeaders({
          // ....
      }
     );
     return headers;
   }
}

As you see from my example, this class is implemented in a generic way so that many different components can use it to do get calls. By doing that your application is going to get clearer and more understandable. Also you will decrease the amount of bugs produced by forgetting to set some headers and so one.

Best Practise #8: The same procedure as every year… use Angular libraries

When you create severall Angular apps your will soon recognise that you get over the same problem again and again. To prevent copying code from project A to project B and to be able to use some kind of central versioning it is essential to use Angular libaries.

Such libaries can contain of base components, base services (like the generic one) or some combination of both. Before creating the library please make sure to think about what you want to achieve with it. Libaries will provide functionalities over different projects but you might end up a bit more frustrated when you need to change something in the library as you need to do more steps (compiling the library, uploading it to a npm registry).

By using libraries you will get more encapsulation from base tasks. That enables you and your collegues to focus on the actual project.

Conclusion

As I described with some examples there are many ways with that you can increase the quality of your Angular software architecture. Even thought Angular provides a very structured way of how you would implement something it is still essential to think of how you can structure the software you write. By a good and a well documented architecture you and your developer collegues will have a better life in the future when you need to write new software parts.

What do you think about Angular architecture? What are your suggestions how to improve Angular code? Do you have any best practises you like to use when implementing an Angular app?

Things to consider when choosing a new technology

Happy new year! Finally we are in 2021, the last year was definitely something very special. Hopefully everybody of you had fantastic holidays and now you get back to your job fresh-minded and motivated. And what better opportunity can we get than the beginning of new year to start with a new technology ? Wouldn’t it be great to eliminate the problems of the old framework or wouldn’t it be fantastic to use all the advantages of a new programming language?

First of all, nowadays we face the fact that we get new languages, new frameworks, new technologies nearly every hour. You just need to compare how you implemented code in 2015 and how you do it today, actually two different things. If you look a little further back in time you will see that 20 years ago solutions needed to be reimplemented all the time. For instance, most softwares included some custom implementation of a datagrid with all of its functionality. Must have been hell, or? In contrast to that, most of the programming languages used today enable us to use third party libraries for free, so we don’t have to reimplement things again and again. Ironically we get to the problem now, that there are too many libaries out there, just check the number of Javascript libraries and you understand the problem.

So, in that big cluster of programming languages and frameworks, how can you choose the correct one for your problem? The first step for me is always to check if you really need a new framework or if you can use something that exists in the company. Of course, starting from zero is something great, you can choose whatever you want, but in reality you always start from somewhere. Maybe some modules exist already, maybe there are already implemented parts. It occurs too often that programmers are too enthusiastic about a new language, just check your own feelings when you see some new language that will make your life so much easier. Personally I think that today we need to stay up to date in terms of technology but there are too many people that are a bit, let’s say critical, when it comes to learning a new technology. And that is a key factor as you are not the only software engineer in your company, if you are the only one that is aware of a language your life will get very difficult when it is used in your company.

What you also need to consider is whether or not the new technology fits to existing software modules. Sometimes it is neccessary to reimplement a software from the bottom up. But when you do that, you not only have a lot of work to do that has no obvious advantage for users of the software, but also you are throwing away years of experience. I am not saying that you shouldn’t modernize applications, but often there is a step by step way so that you do not run into a big bang where you loose all the experience from past years. I did that mistake already when I used a technology which wasn’t able to communicate with some old services that were delivering data via CORBA (yes, that thing still exists…). So I needed to reimplement the whole service, a bit more research on the project requirements would have lead to solutions that provide a interface for CORBA.

Next it is important to check if the technology is being updated regularly. Nothing is worse than implementing something in a way that will not be able to maintained because of some old technology. By doing so you would run into the same problem as I explained already, at a point you need to throw away everything and this point will come earlier than you might expect. Maybe you ask yourself now where you can check if something is maintained. Often that is specified on the website of the creators of a technology. When using a Javascript framework it is always a good idea to check the number of weekly downloads together with when the last version was deployed to npm. Also you can check Github for the last commits if there are some. For me a good number of releases is at least one every half year and if I check github and see that the last commit was 2 weeks ago everything is fine. If you see that the last commit was 5 months ago it is likely that the framework is no more supported. To make sure that this is the case also check the weekly downloads because maybe the framework is just so stable so that no checkins are needed.

Another important question is the existing know how in your company and also how likely it is that the new technology will get used without problems. Sometimes it is necessary to switch the used programming language but if nobody is able to write code with it it will not help you a lot. For instance, in a company full of C++ programmers you will not be able to choose Java as the one and only programming language, senior software developers will argue with you about the speed of the language, about how bad Java is and so on. In such a situation it would be better to question why you would use Java. Maybe it is because of the fact that it is easier to find new employees or because you are able to use some framework. To improve the acceptance it is one idea to make workshops, trainings or coding sessions with that you are able to prove that some language is better for the company. Another possability would be to choose a technology that is easier to be learned from software developers with their existing skills (in my example C# for example).

Ok, now we have chosen something that fits the requirements and is able to be used by others too. Unfortunally every creator promises everything from some framework or some language. That means that you need to make a prototype to check if the technology is really the correct solution for the problem you have. Prototyping doesn’t mean to include all the details, it means to provide some proof of concept. How long can prototype building take? Good question, the answer is actually “it depends”. But I would say, for a medium-sized problem (for instance a new module for displaying something with 3D-grafics) I would take a day to create a proof of concept. This prototype always includes an interface to one existing module to proof that it is possible to connect it to the existing software. Also I normally go throught the code with some of my colleagues just to check if everything is understandable. What you also can do is to start with a version of the framework or technology that is older and then try to update the proof of concept. By doing so you can check if the framework is able to be updateable.

Sometimes you need to cover very specifc requirements or you need to cover requirements that you are not able to cover with the proof of concept. One example would be a performance requirement in production that you will not be able to cover at the early stage as you have not the data available. In such example it is recomendable to check the internet for reports or blog posts like mine when I explained why I prefer using Angular (https://www.styriandev.at/styriandevblog/index.php/2020/02/23/some-reasons-why-i-think-you-should-consider-using-angular-for-your-next-project/). By doing so you are also checking the size of the community, a bigger community means that you can find help faster.

Also include a check if you are still able to test the software with this technology. Not only I mean that you are able to click throught it but also check if automatic unit tests or E2E tests are still possible.

One point that programmers might forget is the compatibility of the technology with the companies strategy. For instance, you will not be very successful when you try to make the company use Firebase (Backend as a Service solution by Google) when the company states in the strategy to not move towards the cloud. To not loose credability during the presentation of a technology in front of the management you should check that point.

Before we get to the end I would also like to state something that seems clear to me but might be unclear to some of you. Every decision process must be documented. It is not important which decision you make, but it is for sure that this decision will be questioned by somebody all the time. And if you have nothing that explains why you decided that something should be used by the company you can’t do this explanation. So make sure to document the advantages of the new technology, document how you plan to use it and which problems are not covered by that technology. Also communicate that documentation, at least somebody will read it and may give you useful input that you can include.

I would like to end this post by addressing you to try something out. There are fantastic new technologies enable us to do things you couldn’t have imagined some years ago. Take your pick, you will find something that will generate a perfect solution! If you try you do more than most of the others.

Get it done – How to organize yourself during stressful times

Finally back, I am sorry that I wasn’t able to write something during the last months but the reason is that the last months were full of work for me. As we are getting to christmas finally everything gets a bit more silent and relaxing (especially in that year) so there is finally more time to work on this blog which is a work I like a lot. And what better topic I could write about than how to organize yourself in stressful times as I experienced one in the last months.

In one of my first blog posts I was writing about things that you can do during a lockdown situation as we have that again right now (https://www.styriandev.at/styriandevblog/index.php/2020/03/18/how-to-make-the-best-out-of-the-corona-crisis/). Maybe you found some new activities to do and you would like to keep working on them, so it seems that you need some extra time during your daily routine. The same situation occurs when you get new tasks in your job, maybe you worked well and you proved yourself as ready for the next stage within the company. You might be ready for being team lead or just having more responsability in the company. That means that you need to organize yourself because it will be more work to do in the same time. Not only that, often you also need to educate yourself to meet the requirements of your new role. Such a situation occured to me as I got more responsability in the company I work now.

First things first, it is important to know that you cannot do everything at once. Therefore, one of the most important things is to say “No” to things that you cannot work on. I know, this seems obvious, but haven’t you been in a situation where your boss came to you and needed something you were more or less forced to say yes even thought you knew that finishing that task needed extra time in the evening? I was in such a situation too often as saying “No” seemed to be difficult to me. For me the reason for that was that often I didn’t know why I can say no because I didn’t know what was left to do – so not being organized that well. Often I was working on something that I didn’t know exactly how long that task would take and for getting a clue on how much time I need to finish I always thought in the best case szenario which especially in software engineering is a thing that never gets achieved, is it? So what I started doing was to write down the tasks that I want to finish during the day, and the thing here is to really write it down. You could of do that on paper, I am preferring it in the digital way to have it everywhere. With that list it is easy to decide whether or not a task can be completed and also this list can help to argue why it is possible to say no.

To-do lists can be very easy but of course they can also be very complex. For me the best way is a very easy list. I am using the most easy tool to work on them, which is for me a single Notepad++ document which I am using to write down tasks and when I am finishing them I am deleting the lines. I am using the simple technique as a more complex creation of tasks for me often leads to actually not doing it because administrative work is nothing that we like to do.

For more complex works like my bachelor’s thesis which I could finish during the summer I prefer using some kind of Kanban board. For me the most important part is having a tool which is pretty flexible in the stages that it has as every work has different stages. This is important because whatever task you are working on that can be pretty different, some examples are the following: For software developement you would have something like “NEW”, “Technical Specification/Analysis”, “Development”, “Testing”, “Finished” for academic papers I was having “Not Done”, “Finding literature”, “Literature summarizing”, “Writing”, “Re-read”, “Finish”. Some tools that I like to use for Kanban boards are Trello (https://trello.com/de) or the Planner app in Teams.

Another important thing in getting something done is having an idea when it is done. This simple line is summarizing one topic that many people forget having which is specifying goals. I prefer having short time and long time goals. It is important to have some strategy and vision, something like “In 5 years I would like to have my Master’s degree or something like “Next year my thesis should be completed”. But this long time goals will not help you a lot. Our brain’s are programmed in a way that they can work on things that seem to be achievable soon or seem to be very tangible. For instance if I specify that I would like to finish my thesis within a year it is difficult to motivate myself as I do not know how the hell I should finish all of that work. It is easier for me to motivate myself if I work on something like finishing a concrete topic. This is also the reason why so many people are having good intentions for the new year but never achieve them.
As you might already saw from my examples the timespan of such goals can be very different. To know if you are specifying short time goals or long time goals it is often enought to think if you would work on that immediatly. If yes that is normally a short time goal. So my suggestion is creating long term goals but also creating some short-time goals that you can achieve. This suggestion is not only for tasks but also for your life in general, with goals you know what you are working on and what you want to do with your life. By doing so you are going to be more motivated and more organized as well.

Another point that will help you which is also needing some kind of goals is having a plan for the next day/week/month. It helped me a lot when I started creating weekly plans. Those plans are not including a detailed plan for every hour of every day but they are including a general goal on what I want to achieve on the different days of the week. Formulating such goals will need some ideas on what you need to do at the specific days and therefore you will have an idea on what this week will bring to you. I prefer doing that type of task at Sunday evening when I have some minutes and I note those goals down on a paper which I stick onto a wall where I can see it. I also use that technique to note down things that I do for myself during the week, when I would like to work out or when I will meet my girlfriend. Having things that you look forward to is important to stay motivated.

My last suggestion is including how you organize your day. Especially now, when we are doing home office, you need to keep track on which activities you do in which order. The point I am trying to make is that if you are doing things you are pleased to do before you are doing things you do not like it is very likeable that you will not finish the second one as you might not be able to motivate yourself to do it. This is some error that I used to make a lot when I was spending time on YouTube before doing the actual work. The reason for that is your brain which gets a reward for wathing YouTube but not for a task that it needs to do. Therefore it is better to first work on the things you need to do and then reward yourself at the end of the day.

I hope I was able to give you some ideas how you can achieve what you want to achieve. Having goals, daily plans or just To-Do lists are some examples which will help you getting your things done.

Do you also experience a stressful time during this special year? What are you doing to get things done?

My opinion mobile app development

Finally back on spot! Today I would like to talk about mobile app development. An exiting topic, isn’t it? But when it comes to choosing a particular technology it gets a bit difficult. There are million ways out there to create that awesome flashlight app for mobiles that will make you rich. You could create a native app, you could create web apps, your could go some hybrid way, so what is the best option? Simple answer? There isn’t one. Or as consultants prefer, “it depends”.

I was also at the point of choosing a technology for an application. And as I had no idea what I was doing I needed to more or less test all the ways that are available. That is why I would like to share my opinion, of course, there are plenty of tutorials for different technologies. But when it comes to choosing a specific technology answers get more rare.

Ok, lets start. If you think of mobile app development the first thing that might come to your mind is to check out the development pages of the creators of the mobile operating system you would like to support. I think that is a very good idea and as both, Apple and Google, explaining basics of their systems you are getting a basic understanding on how those platforms work. Also you get an idea on the design guidelines that applications for those platforms need to meet. Actually that is a very important point if you create apps, your app should follow the usability guidelines so that users are not getting confused. Especially when you focus on Apple apps you need to follow those principles, if not your app will not be able to get into the app store.

What the platforms of Google and Apple are also describing is how to create applications for their operating system. This is called “native app” development and means that you are creating an app just for one operating system. In some cases that is totally fine, maybe you want to address only one platform. But if you want to support both systems that gets a bit complicated. As you need different programming languages (Kotlin or Java for Android, Swift for iOS) it is nearly impossible to share code between both platforms when you do native app development. That is why often other technologies are used these days which I am going to explain later. However, in some cases two native apps make sence. If you need to create lot of device specifc features it is always a good idea to use the native ways.

Another option is going a complete other ways. The web today offers the possability to use native features in a web page. This powerful technology is called PWAs and such applications behave like native apps even thought they are opened in a browser. Many web pages use such technology already and in many cases this make sence. I used such a way when I created an application for a fair. So in that case the most important thing were the informations and creating native apps for such a thing would be too much work. With a PWA I could use the camera of the mobile phone or to create Push notifications when something was started. With PWAs you are able to share 100 percent of the code between both platforms. One disadvantage of such a way is that users cannot find your application in the app store. At the fair some people immediatly opened the app store when they saw that there is an application. That might be a problem. Also it is more difficult to make users use the app often, for PWAs it is essential that everything works as users expect, if that is not the case they would go to another site and will never come back to your app. If applications are installed they payed at least the effort on installing the app, so getting to a new app is more difficult. Also it is still not possible to access all native features as well as games could be difficult to realise in such a way.

A good way in the middle is creating cross plattform applications using the Apache Cordova framework. One framework that uses Cordova as well as Angular is Ionic. I like to use Ionic for many reasons. It provides many components that mobile apps need, it has a fantastic documentation and it can be used to create applications for all platforms (you can create native apps, windows store apps and web apps with just one framework). What that platform does is creating a native application that opens a browser were your content is displayed. The user just sees the native-like application. By using Cordova you are able to access device specific features. By using a CSS all the components really look like native components. I would choose cross plattform development using Ionic when it comes to business applications were you need to display and enter data in different masks. The only thing I do not like is that most of the Ionic components look like iOS components, in Android those should have a bit more adoption. But you can have native Android experience by adding another CSS framework like Material Design.

As I described above, with cross-plattform-application development in Ionic you are creating an application that runs in a web browser that the user does not see. That brings some disadvantages. On the one hand, you can have difficulties when trying to create customized native components. On the other hand you might get performance issues on elder devices. But the way of sharing a single code base in different applications is something that is not such a bad idea as nobody of us likes to create the same code over and over again. Platforms like NativeScript, ReactNative or Xamarin try to solve that problem. What those platforms do is creating native code from your code that is written in a shareable way. Which framework you are choosing totally depends on which framework you like. NativeScript supports Angular, ReactNative supports React, if you are a C# guy, Xamarin might be an option for you. I have used Xamarin in the past and I had good experience in using that platform. As you are using C# you can access many features of the .Net framework that are very useful in some cases. One problem that I often had with such frameworks is the time to render the code so that it can be tested. As I described, your code is translated into native code. And this takes some seconds that can be pretty long for a web developer like me that is used to short compiling time. However, that part gets better and better and Ionic has the same problem when it comes to testing device specific features.

Last but not least I would like to write some lines about Flutter. I need to say that I didn’t create whole applications using that framework but I played a little bit with it last time. And in my mind that way of creating applications definitly deserves attention. The idea behind Flutter is to create apps for all plattforms using one programming language (Dart). It provides many so called widgets, that you can see as different kind of functionalities. Flutter is the SDK that provides native applications, so you get all different advantages of native apps without loosing the advantage of a single code base. For me learning Dart was very easy as I have experience in C# and Java. Not only this framework is easy to use by developers, it is also easy to be used by not expererienced developers as the platform provides many different functionalities already. Those are called widgets and provide things like form controls, buttons, accessability, … So everything you need with an app. As this way of creating apps is pretty young but very promising I think it will get more attention and therefore I am going to have a deeper look too.

To summarize, if you are creating mobile apps you have to make a decision on a specific way by looking on your requirements. Not every framework is correct for a specific case. I often use Ionic or PWAs as I am a web developer but in many cases native apps are worth a thought. To share a codebase with a native app you can use frameworks like Xamarin but not always that way is the most performant way. And last but not least you need to have a look on the different trends on the market, like Flutter.

What framework do you like to use? Are you a native app developer or do you prefer cross platform development?

Why test driven development sucks but why you still should do it

Hey, you still reading after seeing test driven development in the title, well done. Let’s face it, testing is nothing that a software developer enjoys to do. It is lot of work, you need to think of many different cases and as your application is deployed the first test that the customer does is something you never thought about. We all know that feeling.

Especially when software is increasing it gets more complicated to test. What is the best aproach then? Of course, one option would getting a tester for your team. But what happens then? Omg, 10000 bug tickets, great, isn’t it? So today I would like to talk about some better ways of testing software and how you can integrate such processes in your existing development process.

Maybe lets start with some basics. There are different testing techniques. The application may be tested manual by someone clicking through all processes. This approach is the one that is used at first most of the time first because obviously it is the easiest thing that also the user does. Some of you may also now frameworks that do that part of testing automatically for you. As explained, this testing technique can be done without many knownledge of this topic. But what you need to keep in mind that when an application gets bigger there are many preparations need to be done to just test some piece of logic you just implemented. That is why there is another testing technique called unit testing. Unit testing is a technique to test the most granular piece of logic you have – in programming terms that means that you test methods. Unit testing is done via writing code logic that tests your code that you wrote. With unit testing you will only test one unit of the logic, meaning that you should not use other units of the application for that. This is because you focus on testing only the logic. Because you may need to test also the behaviour your class has in the context of a bigger part of the application there is also something between the described techniques, this one is called integration testing.

So, next, what is test driven development. It is a way of creating software by thinking first about tests your new logic requires. Literature mostly describes that technique in terms of unit testing meaning that you first create or unit tests and then writing the logic. But in my mind this can also be done at a much higher level. You can also do “test driven development” by formulate tests while creating a new requirement. As a product manager/owner/requirements engineer this is something you do while thinking about requirements anyway. Something like “ok, when I click there I would like this to happen”. By using testing cases while formulating new requirements software engineers will understand the requirements better too. And it could also lead to other test cases by the software engineers or even better ways of doing the same. In a scrum way of creating software I would suggest to add a section in the user story that is covering all the test cases. And that test cases will be used to show how everything should work. This section must be of course flexible because there may be cases where software engineers think of new test cases needed during development.

Alright, now let’s move on to code testing. I think that creating unit tests for your code is essential especially when you are working on a project with different software engineers. That is because such unit tests can be seen as an approve that the whole logic works. Think about new features you develop and during development you may adopt some pieces of code in backend. Wouldn’t it be great to have something that makes you sure that all the other pieces will still work? Unit tests make that happen if they are included in the build. And here comes the most important thing, NEVER, and I really mean NEVER create a production build with some “build-skip-tests” flag. Once done everybody will do that and therefore nobody will care about tests. And when you finally think, ok, maybe let’s fix the test you will end up getting very frustrated because lot of work will be needed to be done.

The amount of time you need to write unit tests isn’t low, that is true. But if you think of the amount of time you would need to retest everything in a complex product just to see if your piece of code didn’t broke any functionality the effort of writing tests is totally worth it. It is much faster to develop pieces of logic incrementally and test the code by the created unit tests. Also, if you write unit tests before writing the class you gonna see that you will think more about the structure and the requirements that this piece of logic should cover. And programming by trying out things is, as we all know, normally not the best way of doing things.

Writing unit tests will also lead to a kind of documentation for the code. Just think of when you last got into a project with thousand different classes covering lot of logic. You normally need lot of time to understand where you should put some code. If the project is well tested and for all logic pieces a test exist you will notice that engineers will first check out the tests and with those tests they can understand the logic. Of course, you can achieve the same by comments in the code, but what project does not include deprecated comments? Deprecated test cases are not possible, because if they cover some old logic they will fail. That is why developers will adopt tests when adding new logic. And that leads to some kind of documentation for the code.

Tests can also be used for new employees to get into the companies way of coding. Together with an experienced developer the new employee could start with creating a unit test for some logic that the senior is then implementing. After some rounds the setup can also be changed that the new employee is writing the actual piece of logic. By doing that the senior could explain frameworks/base methods and so on and the new employee is able to find out how everything works.

Test coverage is a measurement to identify how many lines of your whole application are covered with tests. When companies try to add unit tests they often include a “100% or at least 90% code coverage” strategy. 100% of code coverage would mean that all lines of your whole application are tested, also those boring getter and setter methods. And I have a problem with such strategies. It is simply not possible to cover all code pieces. In my mind all important parts that contains logic must be tested. By that I mean business logic classes, complex calculations and so on. Some code of a framework, like a spring repository in java, is nothing that will not work. Therefore I don’t think you need to test these.

E2E testing is a technique that is used for testing the whole application by something that really clicks through a deployed app. So instead of manually testing everything an automated part will do that. This kind of testing is used to test parts of the application that are not very complex to test but testing these all the time would cost lot of time. By creating E2E tests you will increase the quality of your application since it is testing the whole thing over and over again. But those kind of tests need an application setup that not everybody has. For web applications for instance without ids on all the dom elements it is very complicated to address different pieces of the application. Also such tests are very complex and timeconsuming to create. It is neccessary to create a presetup of the test, than all the tests are executed and then all the things need to be deleted again to not create negative side effects. Also running those tests need many time since they really simulate a user doing things in the application. Therefore such tests should not be included in every build but they should be executed at least once a day. I think E2E tests make sence for application parts that are very boring and repeatable to test like some sign up process. Including such kind of tests needs some preparation and also must be calculated in terms of the time effort that they need.

Alright, those are my thoughts of testing software. What is your experience and which testing technique is your favourite?

Making the best out of the Corona crisis

Very long I was thinking whether I should write a blog post on this hard topic or not, but since everything is changing now from day to day today I thought, why not, lets write that.

First of all, to those who see the apocalypse coming, nope, I don’t think that this will be the case. Yes, it will be different when all of this is over. Yes, we are getting into a complicated time. Without be able to do business many companies will get into problems and therefore many people will loose their jobs. Also people are loosing their lifes because of this virus. And that is why I totally understand if you are concerned, I am normally an optimistic person, these days being optimistic is a little complicated. But as there are so many bad news, lets just talk for now about some positive aspects.

If you recap the last week it was the best option but actually I was very suprised when the Austrian governance introduced its new rules to fight the virus. Not only the Austrian government but also whole Europe has now strict regulations for social distancing. Short summary, we need to stay at home from now on. Therefore many people have now (forcedly) lot of time because going to work is not possible or they work remote from home and therefore do not need to drive so many hours to their workplace. So, what to do with that extra pinch of time? Browse through instagram and watch Netflix? Start a computer game you wanted to start long time ago? Both not bad and probably a good decision for some period but not all the time. Wouldn’t it be great if you can look back to that time in a year and think of something more positive you did? There are so many other things you can do at home.

First, use the time by learning something new. If it is a language you never had the time to learn or if it is a skill you always wanted to learn.

I am not language teacher to list a good way of learning a language but I had great experience on learning spanish in the past years by only using online tools that are available. To do that I am using Babbel (which can be replaced by the free app Dualingo too) to learn vocabulary and grammar, spotify podcasts (I recommend hoyhablamos for learning spanish if you are more skilled, coffeebreakspanish if you are a beginner) and I like to read some IT news on spanish newspapers. Especially listening to podcasts is something you can do while you are doing some other things and therefore is very efficient. What are your experiences on learning languages online? Do you have recommendations?

Learning a new skill has never been easier than now. As a programmer I am facing that necessity all the time but there is more than new programming languages you can learn online. I love the platform udemy for learning new things because it contains almost everything – from programming courses to finances to creative drawing courses to courses on how to play instruments. YouTube has such courses too and I am using that platform too (of course) but in my experience with udemy you are more focused just because of the fact that you payed something for the course. Another advantage is that this platform supports offline availability which enables you to switch off all those popup messages for some time. What is your favourite platform for learning a new skill?

If you are more reading person you can use this time to read a book you always wanted to read. Right now it is not a problem if you don’t have this book at home, you can order it on Amazon and it will be delivered (YES I am a book person and not somebody who love to use book readers). Also you can use that time to read some papers about things you are interested in or maybe will get interested in? Maybe you find some area where you would like to focus on in the next time?

As restaurants are now closed you can use this time to start cooking or baking. YouTube has fantastic introductions on this topic, I have learnt it by this platform too. Use the time to create something you always wanted to create, cook a dish that is very complicated or just enjoy doing something that results in a delightful meal.

Last but not least, use this time to do things you normally do not have the time to do. Clean you house, get order into your personal stuff. But most important, try to avoid personal contact but use your mobile phone to keep contact to those who are important to you. Try to call your family more often, contact your friends, organize a Skype party on saturday, there are ways to keep contact.

Of course this is a hard time, of course it is easier to be pessimistic right now. But wouldn’t it be better to look at this time next year and see what you achieved? New skills, new hobbies, other priorities, use this time, try to do something you always wanted to do.

Some reasons why I think you should consider using Angular in your next project

Hola a todos 😉

Today I really want to talk about a topic I am really enthuasiastic about – and this topic is Angular. Since released in September 2016 many applications started to use this framework. And today I would like to talk about my experiences using the framework in the past years. So maybe you are asking now, why the hell should I read another blog post about that framework? Maybe I can give you a reason. When I came to my current company 3 years ago we started a new project. I have used Angular.js in my recent projects and also I have used React. So first we were sure that using Angular.js is a good idea, why not, it is easy to use (remember the good old days when nothing more was neccessary than including a script and you have a whole framework with you) and there was a hell of a big community out there. But at this time there was already lot of discussions out there in the internet that the new Angular, Angular 2 has many advantages. And that was why I started googling it. Very fast I could find out how this framework works because there are so many explanations out there and Google is also doing a fantastic job from documentations perspective. That was why we started using it and since this time we actually never had any problems with that framewok.

As already described in my introduction, the biggest advantage of using Angular is that it has a big community out there and there are so many ways of learning the framework and getting support using it. Google is doing a fantastic job with their tour of heroes ( https://angular.io/tutorial ) which is explaining the important aspects of Angular very fast. On Stackoverflow there are over 200.000 questions meaning that there is a very active community. And in my mind having many ways of getting information about a framework is one of the most important aspects in modern software development. Nothing is worse than googling an error you have for hours and hours and not finding a solution.

The next good aspect is something that many people don’t like about Angular. It is the strictness of the framework. I know, we all are Software developers and we don’t like too many rules. Especially as web developers we really like the web as it is. We produce code and the browsers are doing the best to correctly run it. That is beatiful. But as projects are growing it is good to have rules – or at least to have some rules. Different software developers are creating code differently. They may use different libraries, they may use different ways of solving problems. Sometimes that is good because it is a way of getting new ideas. But sometimes it is just a big hell of a mess. Hands in the air if you have had any bad experience debugging good old spaghetti style code that was produced by somebody. Angular has solved this issue by providing many features that are normally solved by different libraries. For instance it is including its own HTTP client, it is having a routing functionality and it has all packaging tools included by default. Also it is using typescript which is very recommendable to not run into typical javascript errors produced by somebody that don’t have a clue about that language.

Packaging is something that we as software developers really don’t like to think about. The code should run and the web application should be as small as possible, that is the most important goal. Thank god, today this is something we don’t need to think about since there are tools providing that functionality. Angular is providing those tools and you can run them just by using the angular cli. By the last update of Angular 9 the team also solved a problem that many developers had – that the production bundle is way too big. And also Angular is providing tools to deploy the application directly, so no more worries about copying something to a web server or creating a script that is doing that for you. Check out https://angular.io/guide/deployment for more information.

Ok now some good points but what are the disadvantages? Of course there are also some. As Angular is a framework that can only be used as a whole or not you have to consider that it is developed by Google and if you are using it you are dependent on Google and their developers. I am not one of this guys with their tiny foil hat that are warning you about that company since I think they are providing fantastic features but you have to think about that before using it. If Google wants you to pay for the framework at some time you have to pay them because you are depending on that framework. But isn’t that the same with every framework? No matter if you are using React, Vue.js or some other framework. Either you have to use some library that somebody created or you have to use good old fashioned javascript and DOM functionality and do everything by yourself. But than you will need more time creating things that somebody has already created to get something that somebody else has finished two months ago.

Managing CSS is a problem for many software developers. Creating some nice UI can be pretty different. Today creating a web app is not only focused on providing good functionality but it also needs to focus on good design and usability. So what we are normally are doing is searching for a nice CSS framework and then we are hoping that we don’t have to change too many parts of it. As Angular is a framework with many restrictions searching for UI libraries was used to be difficult, especially in the beginning time of the framework. But that is not the case now. Many UI libraries are providing Angular components out of the box, so you can choose whatever framework you like. If you want to use the styles that are used in every Android phone use Material ( https://material.angular.io/ ). If you more a bootstrap guy you can use ng-bootstrap ( https://ng-bootstrap.github.io/#/home ). PrimeNg also provides nice UIs ( https://primefaces.org/primeng/#/ ).

Now since you still reading I finally can start with the boring part – which is unit testing… 😉 Angular provides everything by its cli to use jasmine testing framework. For those who don’t know it, it is a framework that is nothing more than a whole framework for testing using nothing more than javascript. The Angular cli is creating by default a test by each component or service, so everytime you create a new part of your application also a new test is created. Writing jasmine unit tests is very easy, actually it is so easy that I prefer using unit testing to start an onboarding process with a new employee since you can write tests without understanding a big application. And if you are using WebStorm or vscode you can start the tests without knowing all the cli commandos. I think that is something that is really great because so many times it is a valid excuse for developers that creating tests is so time consuming and so there is no time for it. But creating unit tests provides security for changes in our application as they are telling you if the behaviour is still valid or not. And if a framework is providing you such features by default it is definetivly worth giving it a chance.

I already talked about growing projects that are getting bigger and bigger. At some point it makes sence to create some small libraries that provide functionality with a specified interface. You could create a libarary that provides some base components so that nobody in your company needs to worry about these, you may also want to create a library with all the functionality to create REST calls. Angular is giving you all the tooling you need to do that. Libaries are small projects in a project that are created with the cli. A library can be handled like a normal Angular project. You can write components in it, you can test your components in it and when you are finished you can simply deploy that library and include it. See https://angular.io/guide/creating-libraries how to create libraries in your Angular project.

Google describes its framework as “One framework.
Mobile & desktop”. So one code base for all platforms, sounds like a dream doesn’t it? And so it is, but not by default. What is is meant by one framework is that every platform is able to open web applications. And as we still want to have mobile applications as applications that are available in our app stores this is not enought. I know, somebody out there is right now screaming around because of that point. There are ways to create APKs with Angular code. And yes, calm down, I come to that in a second. But first I would like to start with PWAs. PWA is a technology that provides your web application with functionality that is normally only useable by native applications – so very short, it is awesome. For instance your web application can be used offline or you can use the mobile camera with the app. Maybe you now think, holy shit, that means I have to think about many things like storing all the application data somewhere to be offline available. And also I will not be able to use the dino game of Google Chrome, which is the best inventation that has ever been made by humanity (isn’t that the case?). But here is the good news, not many applications are using PWA technology (which is actually not a good news) and if you want to use PWA it is very easy. Angular CLI provides you commandos to use different functionality. You just need to use the command ng add @angular/pwa and you are able to start. Check out that post to get more information ( https://angular.io/guide/service-worker-getting-started ).

But now, finally, how can we create installable mobile applications with Angular. And here is the good news, there are many ways. One option is to use Ionic ( https://ionicframework.com/docs/). In ionic you build web apps that are then bundled into an installable native app that includes a browser that then is able to display the app. A big advantage of using such a technology that the same code base is usable by a desktop application too (which may be a web app or a desktop app with Electron).

As you see, Angular is a framework that has many advantages. Of course, not everything is good but in my mind it is a framework you should think about when you are in the position of choosing a technology for a new project. What are your experiences with Angular? Do you think that it is a pretty cool framework or do you think that it is too complicated?

Hey there, welcome to my blog!

I am a software developer based in Austria. Just another blog because one guy has nothing better to do than writing texts to somebody? Correct ;P

No, just kidding, this blog should not be another example of content filling up our world wide web by stuff nobody is caring about. Ok, let’s say most of the time, sometimes we also need to talk about funny things and maybe we can learn by them too.

There are so many technology blogs out there now, so why should you care about this blog? The main reason is that I would like to write about my experiences I collected during developing various business applications. So not only I am going to show you how to do things but also I am going to talk about what experiences I had using different technologies or method. Sounds awesome? Great, let me know when you are interested in a topic, maybe we can talk about it.