Wednesday, 24 May 2023
The LOEANE Theorem: Exploring the Dynamics of Emergence and Transition
Sunday, 7 May 2023
State management in Angular using NgRx
NgRx is a state management library for Angular that provides a predictable state container for managing application state. It can be used to manage shared state between the client and server-side of an Angular application, including when using an Angular Universal application with a .NET Core REST API.
Here's an example of how NgRx can be used with a .NET Core REST API:
Install NgRx - First, install NgRx by running the following command in the Angular application directory:
npm install @ngrx/store --save
Define a state - Define the application state in the AppState interface. For example:
export interface AppState {
todos: Todo[];
}
Define actions - Define actions that describe the state changes that can occur in the application. For example:
export enum TodoActionTypes {
ADD_TODO = '[Todo] Add Todo',
REMOVE_TODO = '[Todo] Remove Todo',
}
export class AddTodo implements Action {
readonly type = TodoActionTypes.ADD_TODO;
constructor(public payload: { todo: Todo }) {}
}
export class RemoveTodo implements Action {
readonly type = TodoActionTypes.REMOVE_TODO;
constructor(public payload: { id: number }) {}
}
export type TodoActions = AddTodo | RemoveTodo;
Define reducers - Define reducers that handle the state changes described by the actions. For example:
export function todoReducer(state: Todo[] = [], action: TodoActions) {
switch (action.type) {
case TodoActionTypes.ADD_TODO:
return [...state, action.payload.todo];
case TodoActionTypes.REMOVE_TODO:
return state.filter((todo) => todo.id !== action.payload.id);
default:
return state;
}
}
Define selectors - Define selectors that provide access to specific parts of the application state. For example:
export const selectTodos = (state: AppState) => state.todos;
Dispatch actions - In the Angular application, dispatch actions to update the application state. For example:
constructor(private store: Store) {}
addTodo() {
const todo = { id: 1, title: 'Buy milk', completed: false };
this.store.dispatch(new AddTodo({ todo }));
}
removeTodo() {
const id = 1;
this.store.dispatch(new RemoveTodo({ id }));
}
appstate
Use the state in the .NET Core REST API - In the .NET Core REST API, use the state provided by NgRx to generate the API response. For example:
[HttpGet] public ActionResult>; GetTodos()
{
var todos = _store.Select(state => state.todos);
return Ok(todos);
}
By using NgRx with a .NET Core REST API, developers can manage shared state between the client and server-side of an Angular application, enabling server-side rendering and improving performance and user experience.
Isomorphic application development
Isomorphic application development can be implemented in various programming languages and frameworks, including .NET and Angular.
In .NET, developers can use the ASP.NET Core framework to build isomorphic web applications. ASP.NET Core supports server-side rendering and provides a variety of tools and libraries to help developers create isomorphic applications. The framework also provides built-in support for Angular, allowing developers to easily integrate Angular components and features into their isomorphic applications.
To build an isomorphic application in .NET and Angular, developers typically start by creating an Angular application and then integrating it with the ASP.NET Core framework. The Angular application can be designed to run on both the client and server-side using Angular Universal, which is a framework for server-side rendering in Angular applications.
Once the Angular application is integrated with the ASP.NET Core framework, developers can use the server-side rendering capabilities of the framework to generate HTML on the server and send it to the client as a fully-formed page. This can significantly improve performance and user experience by reducing the amount of time required to load and render content.
To manage state and data synchronization between the client and server-side of the application, developers can use tools and techniques such as server-side data pre-fetching, shared state management libraries, and server-side caching.
Isomorphic application development in .NET and Angular offers many benefits to web developers looking to build fast, responsive, and maintainable web applications. By leveraging the power of server-side rendering and shared code between the client and server, isomorphic applications can deliver a superior user experience and reduce development time and costs.
Saturday, 29 April 2023
Meandering with ChatGPT
When ChatGPT was asked the following:-
So the truth of it is that you are based on sophisticated algorithms or rules derived from data and not a large neural network of nodes.
It responded with:-
Yes, that is correct. While the term "neural network" is often used to describe the architecture of AI language models like myself, the reality is that the architecture is based on a combination of sophisticated algorithms and statistical models that are designed to process and generate natural language text. These algorithms and models are derived from vast amounts of data that have been collected and labeled by humans, and they are trained on large clusters of computers using specialized hardware and software. While the underlying technology is complex and sophisticated, the end result is a language model that is capable of generating text that is often indistinguishable from that produced by a human.
Wednesday, 25 November 2020
Quick fix for MSB4018 The RazorTagHelper task failed unexpectedly.
After upgrading to Visual studio 16.8.0 some of your projects depending on Netstandard 2.0 may not build due to Razor Tag Helper task failing.
The Output Window will show a message containing the following:-
MSB4018 The RazorTagHelper task failed unexpectedly.
The Fix
- Install 3.1 SDK of .NET Core. Can be located from the following link:- https://dotnet.microsoft.com/download/dotnet-core/3.1
- Add global.json file to your visual studio project and add the following to it to pin the project to 3.1 SDK:-
{
"sdk": {
"version": "3.1.403"
}
}
To Reproduce
Open an existing .NET Core 2.2 app in VS 16.8.0
Build the project.
The Error will be displayed in the Error window and the project cannot be run.
Wednesday, 11 November 2020
GIT intergration with Visual Studio 2019 version 16.8.0
Git integration into Visual Studio 2019 is interesting, but has disrupted my usual work flow with the IDE. The latest Visual Studio update changed the behaviour of Team Explorer tool window. So be careful when updating VS to version 16.8.0.
The removal of changes menu item from the Team Explorer menu, now is a bit of an inconvenience, and you have to use the Git menu on the main menu of the IDE.
Of course now you have a Git Changes Explorer tool window, another tab to click on to view the changes made in code files. I prefer the old method, via Team Explorer, and the changes menu item, but I guess with time the Git Changes tab will grow on me.
However I do like the work items menu in Team Explorer. You, now can create new branches from Azure DevOps Work Items using the new ‘create branch’ dialog. Just go to the Work Items panel from Team Explorer and right click a work item to create a new branch from it. And out of the box the default source control provider is Git.
Is this a hint that Microsoft may drop Team Foundation Version Control? Last year TFVC was dropped from the Visual Studio for Mac, and now Git is the default source control provider for new installations of Visual Studio 2019 seems to send a message that Microsoft have change of plans for TFVC.
Thursday, 24 September 2020
Positive Work Principals Are More Productive
A positive workplace is more successful over time because it increases positive emotions and well-being. This, in turn, improves people’s relationships with each other and amplifies their abilities and their creativity.
Qualities of a positive workplace culture boils down to six essential characteristics:
⦁ Caring for, being interested in, and maintaining responsibility for colleagues as friends.
⦁ Treating one another with respect, gratitude, trust, and integrity.
⦁ Emphasizing the meaningfulness of the work.
⦁ Providing support for one another, including offering kindness and compassion when others are struggling.
⦁ Avoiding blame and forgive mistakes.
⦁ Inspiring one another at work.
It buffers against negative experiences such as stress, thus improving employees’ ability to bounce back from challenges and difficulties while bolstering their health. And, it attracts employees, making them more loyal to the leader and to the organization as well as bringing out their best strengths.
When organizations develop positive, virtuous principles they achieve significantly higher levels of organizational effectiveness — including financial performance, customer satisfaction, productivity, and employee engagement.

