• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Anyone else trying to keep up with all the newish .NET stuff?

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Anyone else trying to keep up with all the newish .NET stuff?

    Reactive Extensions for .NET (Rx) for example.

    Code:
     //Create an observable with the initial position and dragged points using LINQ to Events
       var mouseDragPoints = from md in e.GetMouseDown()
                               let startpos=md.EventArgs.GetPosition(e)
                               from mm in e.GetMouseMove().Until(e.GetMouseUp())
                               select new
                               {
                                 StartPos = startpos,
                                 CurrentPos = mm.EventArgs.GetPosition(e),
                               };
    Rather than attaching even delegates and writing even handlers.

    PLINQ and Parallel

    This gem?

    Code:
    public static List<R> Filtering<T,R>(IEnumerable<T>
    source)
    {
    var results = new List<R>();
    using (SemaphoreSlim sem = new SemaphoreSlim(1))
    {
    Parallel.ForEach(source,
    () => new List<R>(),
    (element, loopstate, localStorage) =>
    {
    bool filter = filterFunction(element);
    if (filter)
    localStorage.Add(element);
    return localStorage;
    },
    (finalStorage) =>
    {
    lock(myLock)
    {
    results.AddRange(finalStorage)
    };
    });
    }
    return results;
    }
    Or this PLINQ style code?

    Code:
    public static IEnumerable<T> Zipping<T>(IEnumerable<T> a, IEnumerable<T> b)
    {
    return
    a
    .AsParallel()
    .AsOrdered()
    .Select(element => ExpensiveComputation(element))
    .Zip(
    b
    .AsParallel()
    .AsOrdered()
    .Select(element => DifferentExpensiveComputation(element)),
    (a_element, b_element) => Combine(a_element,b_element));
    }
    I remember when it all looked so obvious. Sort of VB on steroids...

    #2
    That's getting into the showing off in Perl department.

    Yes you can write the entire program in a single line of code personally I would prefer 100 lines with documentation and notes and I'm paying your wages.
    merely at clientco for the entertainment

    Comment


      #3
      I don't think you are, he's a contractor.
      Originally posted by MaryPoppins
      I'd still not breastfeed a nazi
      Originally posted by vetran
      Urine is quite nourishing

      Comment


        #4
        I'm not writing stuff like this, I'm reading stuff like this and thinking "Do we really need all this syntactic fluff?"

        Perhaps we do. Perhaps I'm just getting old and grumpy....

        Comment


          #5
          Originally posted by d000hg View Post
          I don't think you are, he's a contractor.
          I was talking about an equivalent perl program from years back being written at the software house I owned back in the late 90s

          When it comes to code I have a simple rule, readable and maintainable. Fancy short cuts take a back seat because when it goes wrong I want to be able to identify the fault, understand it and fix it in a hurry.
          merely at clientco for the entertainment

          Comment


            #6
            Code:
            };
            });
            }
            is an abomination. That should just never be allowed to happen. Perhaps some indenting would help.
            While you're waiting, read the free novel we sent you. It's a Spanish story about a guy named 'Manual.'

            Comment


              #7
              Originally posted by eek View Post
              I was talking about an equivalent perl program from years back being written at the software house I owned back in the late 90s

              When it comes to code I have a simple rule, readable and maintainable. Fancy short cuts take a back seat because when it goes wrong I want to be able to identify the fault, understand it and fix it in a hurry.
              But what you consider a fancy short cut someone else might consider readable. I find this with C++ templates; to me it's hard to figure out as I learned templates as a useful language feature while those who learned to program using templates as a core programming paradigm see it very clearly.
              Originally posted by MaryPoppins
              I'd still not breastfeed a nazi
              Originally posted by vetran
              Urine is quite nourishing

              Comment


                #8
                Originally posted by d000hg View Post
                But what you consider a fancy short cut someone else might consider readable. I find this with C++ templates; to me it's hard to figure out as I learned templates as a useful language feature while those who learned to program using templates as a core programming paradigm see it very clearly.

                Off topic Bit did you Post a lot in Topcoder back in the Day?

                Comment


                  #9
                  I can't decide if that's better or worse than C++'s hideous lambda syntax.
                  Will work inside IR35. Or for food.

                  Comment


                    #10


                    I mean all the language bloat.

                    Comment

                    Working...
                    X