• 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!

Retraining as a C# dev?

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

    #11
    Thanks all for the words of encouragement. Good to hear it's not just me who struggles with delegates!

    I have now decided to focus specifically on WPF and MVVM as it's an in-demand technology which I can gain experience with at work whilst also bolstering my ability to understand and implement the basics: value vs reference types, writing methods, arrays & collections, exception handling etc.

    I will still have some exposure to WinForms at work too but I can't see this being a major negative as it's all relevant experience?

    Amar, how long did it roughly take you to get to the stage whereby you felt confident stepping into contracting as a developer? I have set myself a target of 3 years experience but I feel that this may be a little optimistic...

    Comment


      #12
      Delegates and Events in C# are not that bad, they just seem to have a counter intuitive syntax I agree.

      I highly recommend a book "C# 5.0 in a Nutshell" . At 1062 pages it's a big nutshell, but it explains EVERY aspect of C# in great detail with examples.

      Here's what it says about delegates:

      A delegate is an object that knows how to call a method.

      A delegate type defines the kind of method that delegate instances can call. Specifically, it defines the method’s return type and its parameter types.

      The following defines a delegate type called Transformer:
      Code:
      delegate int Transformer (int x);
      Transformer is compatible with any method with an int return type and a single int parameter, such as this:

      Code:
      static int Square (int x) { return x * x; }

      Assigning a method to a delegate variable creates a delegate instance:

      Code:
      Transformer t = Square;
      which can be invoked in the same way as a method:

      Code:
      int answer = t(3); // answer is 9
      Here’s a complete example:

      Code:
      delegate int Transformer (int x);
      
      class Test
      {
      static void Main()
      {
      Transformer t = Square; // Create delegate instance
      int result = t(3); // Invoke delegate
      Console.WriteLine (result); // 9
      }
      
      static int Square (int x) { return x * x; }
      }
      A delegate instance literally acts as a delegate for the caller: the caller invokes the delegate, and then the delegate calls the target method. This indirection decouples the caller from the target method.
      The statement:

      Code:
      Transformer t = Square;
      is shorthand for:

      Code:
      Transformer t = new Transformer (Square);
      The expression:

      t(3)

      is shorthand for:

      t.Invoke(3)

      Note: A delegate is similar to a callback, a general term that captures constructs such as C function pointers.


      Writing Plug-in Methods with Delegates.

      A delegate variable is assigned a method at runtime. This is useful for writing plugin methods. In this example, we have a utility method named Transform that applies a transform to each element in an integer array. The Transform method has a delegate parameter, for specifying a plug-in transform.

      Code:
      public delegate int Transformer (int x);
      class Util
      {
      public static void Transform (int[] values, Transformer t)
      {
      for (int i = 0; i < values.Length; i++)
      values[i] = t (values[i]);
      }
      }
      class Test
      {
      static void Main()
      {
      int[] values = { 1, 2, 3 };
      Util.Transform (values, Square); // Hook in the Square method
      foreach (int i in values)
      Console.Write (i + " "); // 1 4 9
      }
      static int Square (int x) { return x * x; }
      }

      The book then goes on to explain Mulitcast delegates, Generic delegate types, Func and Action delegates, delegate compatibility, delegates vs interfaces, and then goes on to explain Events in detail and how these are related to delegates.


      Hope this helps. I would suggest becoming a member of Stack Overflow and ask questons and read answers.

      Comment


        #13
        The stuff you mention like delegates are pretty advanced topics by normal standards. C# is full of features.

        I think you're going the right route, if you can self-learn to the point someone will hire you you are doing OK!
        Originally posted by MaryPoppins
        I'd still not breastfeed a nazi
        Originally posted by vetran
        Urine is quite nourishing

        Comment


          #14
          Yes, thanks I'll check out the C# 5.0 book

          I understand to a point that a delegate is a way of indirectly calling a method and ultimately several methods at once with multi-cast delegates via the invocation list. I know how to new up an instance of the delegate and call the delegate, passing in a suitable method as a parameter or add methods to the invocation list with += etc. I also have used simple lambda expressions to add methods to a delegate with a different return type or method 'shape' so I'm obviously building some understanding. Just get lost in the examples when multiple classes, events etc appear but it'll come with time & exposure I'm sure.

          Yes, I think I was very fortunate that my Geography & GIS background got me into my current role. I'm not being mentored by any other devs as it's a small company & my boss is an SQL guy so I have to really motivate myself learn off my own back. Luckily I normally get at least a few hours everyday when I can sit tinkering with VS or watching PluralSight videos so I'm in a fortunate situation re time for learning.

          Comment


            #15
            Originally posted by Hardgraft View Post
            Just get lost in the examples when multiple classes, events etc appear but it'll come with time & exposure I'm sure.
            All this delegates/lambda stuff is often as confusing to seasoned devs, it isn't what many/most of us learned so I wouldn't feel too bad. Learning solid programming that lambas help you avoid is well worth it (because in other languages you'll have no choice).
            Originally posted by MaryPoppins
            I'd still not breastfeed a nazi
            Originally posted by vetran
            Urine is quite nourishing

            Comment


              #16
              Originally posted by d000hg View Post
              All this delegates/lambda stuff is often as confusing to seasoned devs, it isn't what many/most of us learned so I wouldn't feel too bad. Learning solid programming that lambas help you avoid is well worth it (because in other languages you'll have no choice).
              Often it's the terminology. In my brief experience of C# I found the use of the word "delegate" highly confusing until I realised it was just a pointer to a function (more or less). In what way anything is "delegated" I've no idea.

              And I'm not convinced lambdas are a good idea, beyond perhaps saving on a bit of typing.
              Will work inside IR35. Or for food.

              Comment


                #17
                Originally posted by VectraMan View Post
                Often it's the terminology. In my brief experience of C# I found the use of the word "delegate" highly confusing until I realised it was just a pointer to a function (more or less). In what way anything is "delegated" I've no idea.

                And I'm not convinced lambdas are a good idea, beyond perhaps saving on a bit of typing.
                Delegate - Get someone else to do it for you.

                So you invoke the delegate and it invokes the function or functions if it's multicast.

                There's lots of reason why you need and want lambdas.

                c# - What&#39;s the point of a lambda expression? - Stack Overflow

                For a start no lambdas no LINQ.

                I'm not sure any client should be hiring anyone that doesn't understand these things inside and out. It's the 21st century, programming languages have moved on and become powerful and expressive.

                Comment


                  #18
                  Yes. I've quite quickly learnt that I can't skim read the fundamentals of OOP and then expect to understand more advanced topics. Seems like you really need to know the basics well and then the more advanced topics will be fall into place as and when you need to use them.

                  Fed up of being skint so that's my motivation to keep pressing on with the learning!

                  Comment


                    #19
                    In any turing-complete language, there are no reasons you 'need' lambda functions. Windows and Linux and Visual Studio were all written without them

                    If I'm hiring a C# dev I want someone who knows how to program more than someone who throws fancy new features around to show off. Loads of companies will still be stuck on .net 3 which means many excellent developers simply haven't been exposed to the newer features. Same goes for the new C++ stuff really - a good developer can learn that stuff as needed but the core is what counts.
                    Originally posted by MaryPoppins
                    I'd still not breastfeed a nazi
                    Originally posted by vetran
                    Urine is quite nourishing

                    Comment


                      #20
                      Originally posted by d000hg View Post
                      In any turing-complete language, there are no reasons you 'need' lambda functions. Windows and Linux and Visual Studio were all written without them

                      If I'm hiring a C# dev I want someone who knows how to program more than someone who throws fancy new features around to show off.
                      To be honest I thought the same when reading Nick's advice. I don't think I've created a windows application in years and simply don't see the demand in the market to justify learning it. Everything I've done is web based and its been that way for coming on for two decades.

                      Even the windows apps I've done over the years have been front ends to data feeds...
                      merely at clientco for the entertainment

                      Comment

                      Working...
                      X