Giter Site home page Giter Site logo

operation's Issues

No Change Log

It is important to have a change log so that people can know what has changed.

"Throw" function seems misnamed

This is just a note on the API method "Throw", which is documented as:

Unwraps the Operation if Successful and Throws an Exception if an Operation Fails

The function name "Throw" implies that the method always throws, or throws for a failed operation (It looks like this is how it used to work?). However the method also returns the value of the operation on success - not really what it says on the tin.

Why not rename the function to "Unwrap"? That's the word you're using in the documentation and it seems to fit the actual use-case somewhat better as well.

Simple Constructors for Success and Failed States

I think using Operation.Create for Creating Successful and Failed Operations is a bit heavy handed as you must allocate an Entire Delegate.

We could have something like Operation.Fail(string message) and Operation.Success(), Operation.Success<T>(T result) methods for both Operation and Operation<T>

NOTE- Moving Forward Operation and Operation<obj> where Operation<obj>.Result = null are treated as the same thing

Create should take a Delegate that Returns Operation

Operation.Create should take a Delegate that Returns Operation and Unwrap it Implicitly. Instead of Throwing it explicitly

Operation.Create(() => {
    //Do Some Operations
    var doStuff = SomeOperation(param1, param2)
    return doStuff;
});

Support Idiomatic Operators

I think the Next Operator is kind of misleading and it's doing too much. So for version 1.1. I am proposing that it supports the classic
Map
Bind
Fold - Needs to be redefined
Collect
Unit instead of Create
So that it is using the Idiomatic Functional Operators
The Existing Operators will still remain only that they will call the underlying Operators

Add Catch Operator for On Error Cases

Add an OnError Operator something like

operation.OnError(e => ());

That way you don't need to explicitly check before you do something on the Error

Operation<IEnumerable> returns IEnumerable

While using query expression syntax and interacting with an Operation<IEnumerable>, the result of the expression is an IEnumerable instead of Operation<IEnumerable> i.e.

var stringOps = Operation.Create(() => new List<string> { "Some", "String" });
var result = 
      from strings in stringOps
      from strng in strings
      select strng +" "+ "Appended String";      

"result" is an IEnumerable instead of Operation<IEnumerable>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.