golang DI container (work in progress)


golang DI container (work in progress)
http://ift.tt/2j6whW4

Submitted December 16, 2017 at 07:27PM by neko-neko_
via reddit http://ift.tt/2zgCAPI

Advertisements

How to design state which is used in a Map


How to design state which is used in a Map

Here is a dumbed down example of what I am trying to achieve. Let's say we have some sort of application coming from a user. This application can be in different states.

Let's say that our Application can be in these different states:

Submitted | Accepted | Confirmed | Processed | Finished 

We can think of Application as a sealed trait and the states are all case classes which have some different information (compared to each other)

Let's say that we have some sort of state machine which describes the workflow of our application processing. There is some initial state which has Map[UserId, Submitted]. Here we don't use Application but restrict ourselves to Submitted type only, because well in our initial state there are no other possible types of application.

And now for the actual question. Let's say that we validate submitted applications and change our state to ConfirmingApplications where we have Map[UserId, Accepted], but the problem here is that we start our state with applications being Accepted but we don't move to the next (ProcessingApplications) until all applications are Confirmed.

How can I approach the design of this case? First thing that I thought was about having two different maps in ConfirmingApplications state where one map is our input map Map[UserId, Accepted] and the other one is Map[UserId, Confirmed]. It seems ok in this small example but what I have is a bigger amount of application types and in one particular state the type of application can change 4 times, should I create four different maps for that?

The other approach is to bring in some other traits which will somehow mark those application types which are allowed to be in a particular state. For example in our ConfirmingApplications state we could have Map[UserId, AcceptedOrConfrimed] where trait AcceptedOrConfirmed is extended by both Accepting and Confirmed application types.

What do you think about these design approaches. Is there any other way to design it? Something better? Something on the same level? Something more type safe?

Submitted December 16, 2017 at 06:44PM by faorien
via reddit http://ift.tt/2jbeKfH

Is any blog with detailed description and examples of Go standard library exists? (except https://golang.org/pkg/)


Is any blog with detailed description and examples of Go standard library exists? (except https://golang.org/pkg/)

Hello! I wonder is someone created blog with detailed explanation of any Go's std lib unit? If no, i thing about to create this, for anyone who wants to start hacking with Go.

Submitted December 16, 2017 at 07:04PM by scafander
via reddit http://ift.tt/2kAnITR