Graphinder – Project Introduction


Quick introduction

Ahoy!
My name is Michał and I’d like to welcome you to my half-zombie/half-hyperactive programming blog that covers mostly anything connected with Microsoft technologies. If you want to contact me or know anything more about me, please navigate to ‘About me’ section on your left. Thanks!
Going next to Daj Sie Poznac 2016, I’d like to elaborate a little about the topic of the project I’m going to develop throughout upcoming 3 months.
First of all I’d like to offer my deepest condolences to all of you who might find my written language boring and/or chaotic. I hope you’d get used to it quickly!
And.. as for the starters, let’s talk a little bit about what babble you’d be going through.
You’ll definitely see lots of graphs. And by lots I mean LOTS.
Origins of this project are not quite distant, as they belong to one of my school projects for artificial intelligence classes from recent semester. To be precise, it’ll try to leverage optimization algorithms operating on graphs and move them from boring command-line* space to some kick-ass web app with lots of front-end sugar and so on.
Let’s split the topic into few sections to add some readability to this TLDR.

* I’m joking ofc. I freakin’ love console apps.


Project organization

Starting with organization side…
I’m going to put a section just below the logo for quick navigation throughout the topics inside the project, in case you’re interested in jumping around on your lecture. This functionality will be available in every article so you’re welcome to give it a shot.
GitHub link for the project will also be provided below the logo, in case you want to go straight to the code.
As for the other tools and means of work organization, I’ve decided to go for good old Trello board for my current tasks, found bugs, backlog and icelog.

Trello for Graphinder:

https://trello.com/b/g6Rm8Cdm/graphinder

Why this topic?

I’ve decided to go for algorithmic project, because I’ve always struggled with anything revolving around them and throughout recent year or two I actually found myself enjoying writing and doodling in them.
However, please don’t be mistaken that those algorithms will be the most efficent and the most sophisticated ones because they won’t be. Hell, I’m even about to bring down Azure Service Fabric, provided I’ll have some time left for actual micro-service decomposition.
While quite boring from the surface, it should be fun for all of you to read some (I hope) interesting stuff I’m gonna share.
Basic implementation of Graphinder so far involves Minimum Vertex Cover problem and two algorithms, attempting to solve it, ie. Simulated Annealing and simple Genetic algorithm.

Current state of project

Currently I’ve finished two algorithms (Genetic and Simulated Annealing) along with Minimum Vertex Cover problem implementation. I’m currently thinking through some decoupling ideas for Genetic algorithm, that’s why only part of it is available in GitHub repository right now. Most of currently committed stuff is loosely covered with basic unit tests and more tests are coming soon. Actually, you’ll probably see at least one article about my struggle and thoughts that came up during unit testing so far (and probably more of it coming with growing amount of components).

Technologies

Ahhh… technologies!
Frameworks, libraries, APIs and services!
To be honest I almost gave up on this project trying to stop myself from doing I can do anything project to something more, more narrowed.
If you didn’t came up with description of my project on devstyle.pl so far, I’m about to write everything in C#, mostly ASP.NET MVC 5 (6?), SignalR (I have no idea what I’m doing), Entity Framework, xUnit (+ NSubstitute) for backend, and pure JS with AJAX or one of major JS frameworks for front-end along with D3.js for graphs visual representation.
If only time allows, I’ll also attempt to decompose application backend into smaller micro-services, mostly for solution-finding (high processor cost, needs to move elsewhere) and authentication/authorization in some sort of WebAPI (I guess?) implementations.
You’ll probably see some reactive programming around as I’ve got used to it working for a quite time now in game development in Unity3D, so if you’re not really into webdev nor graphs, maybe that will catch your attention?

Logo

Have you seen this sexy, shiny, new logo for the project?
Which logo? What do you mean by ‘which logo’?
Hey, don’t go away, hey wha-…
Alright, just joking. Hope you like it as I thought of coming with something for the challenge anyway.
Either way, let me know what do you think ’bout the project!

Wow, 66 revisions of this post so far. When did it happen anyway…

Joining “Daj sie poznac 2016” challenge

Daj sie poznac 2016

This post will be short, yet quite exciting for me. I’ve recently decided and enrolled for Daj sie poznac 2016 (Get to know yourself 2016) challenge organized by one of the top figures of both .NET and programmers community in Poland, Maciej Aniserowicz from http://www.maciejaniserowicz.com.

More about a challenge on:

http://www.maciejaniserowicz.com/daj-sie-poznac/

My tools of trade will revolve around the technologies stack I’ve worked with (C#, .NET, web-stack) but I’ll attempt to touch technologies I’ve never worked with (SignalR, Oauth 2.0, one of top frontend MVVM JavaScript frameworks – not decided yet), while trying to boost up my skills in OOP in general, ASP.NET MVC and ASP.NET WebAPI toolset and having even more fun and headache with adding some sugar powder of optimization problems on graphs and algorithms that will attempt to try finding solution for them.
I’ll probably overextend this project significantly to the point of no return so make sure to watch me over, as it will definitely be fun reading my frustration flowing upon you. ;)

I’ve added extra section for upcoming challenge on nav on the left, so make sure to visit it sometime when it all starts on March 1st!

uFrame MVVM and Separation of Concerns

Some of you that used to work (or work) with Unity3D might be tempted to use library called uFrame MVVM to get things seperated in proper, documented way.
As I’m currently working on a project that uses uFrame MVVM, I’d like to add few words of how and where I find uFrame MVVM actually not meeting one from many SOLID rules, that is Single Responsibility Principle and it’s a-like principle: Separation of Concerns (SoC).

About uFrame MVVM

Few words about uFrame MVVM first.
UFrame has been developed by Invert Game Studios to mimic MVVM pattern behaviour known to C# developers from WPF or ASP.NET frameworks.

Direct link to uFrame is here:

https://invertgamestudios.com/mvvm/overview

Although it’s marketed as ‘MVVM’ and it does have Views that bind to ViewModels, it resembles me more how ASP.NET MVC work with MVVM client-side, JS-based frontends.
Actually it lacks the ‘M’ (Model) part. ViewModels are used from start in a way generally models are. Logic that sometimes grows too much in WPF MVVM inside ViewModels lays in Controllers here.
I’m really delighted that finally that big-blob-VM are gone from my code and instead a true Controller taken from MVC pattern takes the responsibility.
Current way how uFrame works would be probably easier to understand with diagram I’ve prepared:

uframe mvvm seperation of concerns

Straight to the problem

Here comes the real problem though: access to instantiating views from code is accessible from Views only(!?).
I can imagine that it’s due to the fact that they’re the only ones deriving from MonoBehaviour but it strictly implies that we should use them for non-UI logic, that is validation and modification of data that should drive instantiation of Views (for ex. ModelCollection that instantiates new View based on ViewModel added to it and notified OnPropertyChanged).
Although I can understand reasons why it was designed that way (Unity3D limitations probably), I can hardly accept way of design it promotes.

My solution

My idea is to implement widely known (also from everyday life) pattern known as Producer/Consumer pattern.
We can subscribe with great reactive-programming library UniRx tool that is already used in uFrame, that is Subscribe and IObservable to ModelCollection, then we can do any business logic and validation in Controller, that is in way it’s mean to be designed.
Our next step will be pushing newly added item do InitializationContainer if it meets our business requirements/is valid etc. Then we will need an Initializer (that will be View in uFrame sense but will behave as normal MonoBehaviour for us) where T is type of ViewModel/View that we’re going to subscribe for to InitializationContainer and then consume it.
Consuming of notified View to initialize should end up in deleting the item from initialization queue in container.
We need to remember that our notification should contain both View and ViewModel, so that Initializer knows what View with what ViewModel it should instantiate.
For better understanding of an idea, here’s a next diagram:

uframe mvvm container initialization

Hope it helps anyone struggling with inconsistend seperation of concerns in uFrame MVVM! :)