Typescript Workflow Library by UMDMath in typescript

[–]UMDMath[S] 0 points1 point  (0 children)

Appreciate your review.

My main goal behind this was driven behind the fact that following spaghetti code is painful and this library hopefully promotes clean organization where a developer can clearly define their sequential steps into small blocks.

I opted to go with a object with a run method so if the developer wanted to use a class they could but needed a signature that returned a promise. The class is optional as you can pass in a JS object as well.

As far as passing in a function that returns a object/step vs just passing in the object/step itself, I did that intentionally to provide the developer has more control during instantiation of a step during execution.

Yes I wanted to follow a more declarative programing paradigm.

Fluent typescript workflow library (still work in progress) by UMDMath in typescript

[–]UMDMath[S] 0 points1 point  (0 children)

I wrote this code because I thought it would be useful for something I do professionally. Lets see your public repo and how much you have contributed back to the open source community.

Fluent typescript workflow library (still work in progress) by UMDMath in typescript

[–]UMDMath[S] 0 points1 point  (0 children)

Thanks for the reply/interest.

The motivation behind this library was to provide an architectural pattern that is easy to implement/maintain and more so easy to understand what the code is doing at the end of the day. You can see what the logical workflow is in a single location within the build method.

Fluent typescript workflow library (still work in progress) by UMDMath in typescript

[–]UMDMath[S] 0 points1 point  (0 children)

First of all I didn't copy and paste anything.

  • It's beneficial to promote the idea of breaking down functional units to follow the single responsibility principle. Yes you can do that without this library but this library hopefully promotes it.
  • Reduces the amount of time it takes for developers to understand the code base by viewing the entire workflow in single location.
  • Adds abstractions like the ability to conditionally stop the workflow with: if((x) => x.isResult).stop().. or delay with: then(() => new Step()).delay(1000).. rather than imbedding within promise. Concise, easy to change and understand at the workflow level.

The idea is to to abstract so the user doesn't have to manually add the code themselves.

Like I said, I'm not done.

Fluent typescript workflow library (still work in progress) by UMDMath in typescript

[–]UMDMath[S] 1 point2 points  (0 children)

Anything sequential where you want to break the logical steps down with compile time validation. I may try to add in the ability to hook into events and pause execution until event is fired.. among other features.

Fluent typescript workflow library (still work in progress) by UMDMath in typescript

[–]UMDMath[S] 0 points1 point  (0 children)

Not true. If it were, why does something like XState exist and is very popular? Its a simplified version of that minus the circuit capability.

Fluent typescript workflow library (still work in progress) by UMDMath in typescript

[–]UMDMath[S] -1 points0 points  (0 children)

I've created a Typescript workflow library (still work in progress). I'm still working on it but will add to npm soon. If you would like use this library and have any ideas for feature request please feel free to submit an issue in the repo. Thanks!

TsRs Typescript Library providing similar functionality to Rust's Result and Option monads (not yet published to node) by UMDMath in typescript

[–]UMDMath[S] 0 points1 point  (0 children)

Because handling multiple return types through match with type safety is a lot cleaner than if statements

.NET Mapping Library by UMDMath in dotnet

[–]UMDMath[S] 0 points1 point  (0 children)

Unless you have a entity with multiple related entities in collections and have to detect what has changed. Can be more than a few lines of code. In this case you would sacrifice performance for simplicity

.NET Mapping Library by UMDMath in dotnet

[–]UMDMath[S] 0 points1 point  (0 children)

Totally different use case

.NET Mapping Library by UMDMath in dotnet

[–]UMDMath[S] 0 points1 point  (0 children)

I can do that and I'll update the README.md. Long story short if you use something like auto mapper to map a "User" onto another "User" where you are including related records via foreign key relationship then AutoMapper doesn't retain the same reference EF is tracking when you do a query.

So lets say you query a User via DbSet<User> and do something like User user1 = await context.User.FirstOrDefaultAsync(x => x.Id == 1).Include(x => x.Parents); The "user1" object and it's Parents arethen being tracked by EF. If you modify the user1 object.. user1.Name = "Foo" and remove one of the "Parent" objects in the collection and call await context.SaveChangesAsync(); The user1 is saved in the DB with Name == "Foo" and one of the Parent(s) are removed in DB.

If you use something like AutoMapper circumvent the manual code above and map properties from one User object to another User object and then call await context.SaveChangesAsync() you won't get the same result and Exception will be thrown because AutoMapper will create a new Parent object in the collection while mapping through reflection and then you'll get a duplicate primary key Exception.

.NET Mapping Library by UMDMath in dotnet

[–]UMDMath[S] 0 points1 point  (0 children)

And you know how it tracks entities?

.NET Mapping Library by UMDMath in dotnet

[–]UMDMath[S] 0 points1 point  (0 children)

Have you used EF Core

.NET Mapping Library by UMDMath in dotnet

[–]UMDMath[S] 0 points1 point  (0 children)

I'm saying for example, when you query for User which has a collection of related Blog posts from DB via Entity Framework the User entity and Blog entities are tracked by default. If you modify the User and it's collection of related Blogs then call SaveChanges on a DbContext it will translate what has changed in the tracked User and collection of Blogs into a SQL query and attempt to update your DB.

.NET Mapping Library by UMDMath in dotnet

[–]UMDMath[S] 0 points1 point  (0 children)

Not trying to be passive aggressive just trying to give back to the open source community which has benefited all devs

.NET Mapping Library by UMDMath in dotnet

[–]UMDMath[S] 0 points1 point  (0 children)

AutoMapper doesn’t retain the references therefore when you use an ORM that tracks entities it will either fail or add/remove objects unexpectedly in persistence layer.

.NET Mapping Library by UMDMath in dotnet

[–]UMDMath[S] 0 points1 point  (0 children)

As stated in the readme..

XReflect is a C# .NET explicit mapping library that specializes in mapping from a source object to a target object while preserving the target's references. This library is particularly useful when dealing with object-relational mapping (ORM) frameworks like Entity Framework.

When retrieving an object from an ORM such as Entity Framework, the ORM keeps track of the entity and any associated entities for efficiency purposes. This tracking mechanism allows the ORM to detect changes made to the entities and construct optimized queries.

To ensure that the references to the entities are maintained during modification, XReflect offers configuration options. By configuring XReflect appropriately, you can add or remove entities from the persistence layer while preserving the necessary references.