Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Learning Custom Types in OOP/New Codebases

Learning Custom Types in OOP/New Codebases

Scheduled Pinned Locked Moved The Lounge
csharpasp-netvisual-studiotutoriallearning
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TheOnlyRealTodd
    wrote on last edited by
    #1

    I love C#. The only time I really struggle is when looking at a new codebase, with datatypes. So, for example, I'm now learning a lot of Identity/OAuth related stuff, and code which is actually quite simple, becomes harder for me to understand when I am not familiar with the data types used. See this example:

    public class ApplicationUserManager
    : UserManager
    {
    public ApplicationUserManager(IUserStore store)
    : base(store)
    {
    }

        public static ApplicationUserManager Create(
            IdentityFactoryOptions options,
            IOwinContext context)
        {
            var manager = new ApplicationUserManager(
                new UserStore(context.Get()));
    
            // Configure validation logic for usernames
            manager.UserValidator = new UserValidator(manager)
            {
                AllowOnlyAlphanumericUserNames = false,
                RequireUniqueEmail = true
            };
    
            // Configure validation logic for passwords
            manager.PasswordValidator = new PasswordValidator
            {
                RequiredLength = 6,
                RequireNonLetterOrDigit = true,
                RequireDigit = true,
                RequireLowercase = true,
                RequireUppercase = true,
            };
            var dataProtectionProvider = options.DataProtectionProvider;
            if (dataProtectionProvider != null)
            {
                manager.UserTokenProvider =
                    new DataProtectorTokenProvider(
                        dataProtectionProvider.Create("ASP.NET Identity"));
            }
            return manager;
        }
    }
    

    What this code is doing is actually very simple, and I get that. But, there are a lot of types thrown around that I'm not familiar with... And then when I learn this particular codebase, the same thing will happen with another when I'm new to it. This was just a small example, but for example with the standard value types like int, double, string, it would be much more straightforward. That said, my current strategy is usually to just hit ALT+F12 in Visual Studio to take a peak at the code and just try to memorize it... But s

    S B D F 4 Replies Last reply
    0
    • T TheOnlyRealTodd

      I love C#. The only time I really struggle is when looking at a new codebase, with datatypes. So, for example, I'm now learning a lot of Identity/OAuth related stuff, and code which is actually quite simple, becomes harder for me to understand when I am not familiar with the data types used. See this example:

      public class ApplicationUserManager
      : UserManager
      {
      public ApplicationUserManager(IUserStore store)
      : base(store)
      {
      }

          public static ApplicationUserManager Create(
              IdentityFactoryOptions options,
              IOwinContext context)
          {
              var manager = new ApplicationUserManager(
                  new UserStore(context.Get()));
      
              // Configure validation logic for usernames
              manager.UserValidator = new UserValidator(manager)
              {
                  AllowOnlyAlphanumericUserNames = false,
                  RequireUniqueEmail = true
              };
      
              // Configure validation logic for passwords
              manager.PasswordValidator = new PasswordValidator
              {
                  RequiredLength = 6,
                  RequireNonLetterOrDigit = true,
                  RequireDigit = true,
                  RequireLowercase = true,
                  RequireUppercase = true,
              };
              var dataProtectionProvider = options.DataProtectionProvider;
              if (dataProtectionProvider != null)
              {
                  manager.UserTokenProvider =
                      new DataProtectorTokenProvider(
                          dataProtectionProvider.Create("ASP.NET Identity"));
              }
              return manager;
          }
      }
      

      What this code is doing is actually very simple, and I get that. But, there are a lot of types thrown around that I'm not familiar with... And then when I learn this particular codebase, the same thing will happen with another when I'm new to it. This was just a small example, but for example with the standard value types like int, double, string, it would be much more straightforward. That said, my current strategy is usually to just hit ALT+F12 in Visual Studio to take a peak at the code and just try to memorize it... But s

      S Offline
      S Offline
      Super Lloyd
      wrote on last edited by
      #2

      It is just a fact of life. Nobody expect you to hit the ground running when you are dropped in a totally new project!

      A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!

      1 Reply Last reply
      0
      • T TheOnlyRealTodd

        I love C#. The only time I really struggle is when looking at a new codebase, with datatypes. So, for example, I'm now learning a lot of Identity/OAuth related stuff, and code which is actually quite simple, becomes harder for me to understand when I am not familiar with the data types used. See this example:

        public class ApplicationUserManager
        : UserManager
        {
        public ApplicationUserManager(IUserStore store)
        : base(store)
        {
        }

            public static ApplicationUserManager Create(
                IdentityFactoryOptions options,
                IOwinContext context)
            {
                var manager = new ApplicationUserManager(
                    new UserStore(context.Get()));
        
                // Configure validation logic for usernames
                manager.UserValidator = new UserValidator(manager)
                {
                    AllowOnlyAlphanumericUserNames = false,
                    RequireUniqueEmail = true
                };
        
                // Configure validation logic for passwords
                manager.PasswordValidator = new PasswordValidator
                {
                    RequiredLength = 6,
                    RequireNonLetterOrDigit = true,
                    RequireDigit = true,
                    RequireLowercase = true,
                    RequireUppercase = true,
                };
                var dataProtectionProvider = options.DataProtectionProvider;
                if (dataProtectionProvider != null)
                {
                    manager.UserTokenProvider =
                        new DataProtectorTokenProvider(
                            dataProtectionProvider.Create("ASP.NET Identity"));
                }
                return manager;
            }
        }
        

        What this code is doing is actually very simple, and I get that. But, there are a lot of types thrown around that I'm not familiar with... And then when I learn this particular codebase, the same thing will happen with another when I'm new to it. This was just a small example, but for example with the standard value types like int, double, string, it would be much more straightforward. That said, my current strategy is usually to just hit ALT+F12 in Visual Studio to take a peak at the code and just try to memorize it... But s

        B Offline
        B Offline
        Brady Kelly
        wrote on last edited by
        #3

        I understand and sympathise with you being dropped in the deep end, but creating and using custom types, or classes, is a very fundamental rennet of OOP. Even C allows the use of custom types via the use of struct, even if that is miles from OOP.

        Do what thou wilt shall be the whole of the Law. - Liber AL vel Legis 1:40, Aleister Crowley

        1 Reply Last reply
        0
        • T TheOnlyRealTodd

          I love C#. The only time I really struggle is when looking at a new codebase, with datatypes. So, for example, I'm now learning a lot of Identity/OAuth related stuff, and code which is actually quite simple, becomes harder for me to understand when I am not familiar with the data types used. See this example:

          public class ApplicationUserManager
          : UserManager
          {
          public ApplicationUserManager(IUserStore store)
          : base(store)
          {
          }

              public static ApplicationUserManager Create(
                  IdentityFactoryOptions options,
                  IOwinContext context)
              {
                  var manager = new ApplicationUserManager(
                      new UserStore(context.Get()));
          
                  // Configure validation logic for usernames
                  manager.UserValidator = new UserValidator(manager)
                  {
                      AllowOnlyAlphanumericUserNames = false,
                      RequireUniqueEmail = true
                  };
          
                  // Configure validation logic for passwords
                  manager.PasswordValidator = new PasswordValidator
                  {
                      RequiredLength = 6,
                      RequireNonLetterOrDigit = true,
                      RequireDigit = true,
                      RequireLowercase = true,
                      RequireUppercase = true,
                  };
                  var dataProtectionProvider = options.DataProtectionProvider;
                  if (dataProtectionProvider != null)
                  {
                      manager.UserTokenProvider =
                          new DataProtectorTokenProvider(
                              dataProtectionProvider.Create("ASP.NET Identity"));
                  }
                  return manager;
              }
          }
          

          What this code is doing is actually very simple, and I get that. But, there are a lot of types thrown around that I'm not familiar with... And then when I learn this particular codebase, the same thing will happen with another when I'm new to it. This was just a small example, but for example with the standard value types like int, double, string, it would be much more straightforward. That said, my current strategy is usually to just hit ALT+F12 in Visual Studio to take a peak at the code and just try to memorize it... But s

          D Offline
          D Offline
          den2k88
          wrote on last edited by
          #4

          That is the real complexity in any project. It's not the 40ish C++/Java keywords or the standard Bohm-Jacopini flows, nor usually are the algorithms. It's the net of data types and their relationships, which must be learned and should be well documented.

          GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- ++>+++ y+++*      Weapons extension: ma- k++ F+2 X If you think 'goto' is evil, try writing an Assembly program without JMP. -- TNCaver When I was six, there were no ones and zeroes - only zeroes. And not all of them worked. -- Ravi Bhavnani

          1 Reply Last reply
          0
          • T TheOnlyRealTodd

            I love C#. The only time I really struggle is when looking at a new codebase, with datatypes. So, for example, I'm now learning a lot of Identity/OAuth related stuff, and code which is actually quite simple, becomes harder for me to understand when I am not familiar with the data types used. See this example:

            public class ApplicationUserManager
            : UserManager
            {
            public ApplicationUserManager(IUserStore store)
            : base(store)
            {
            }

                public static ApplicationUserManager Create(
                    IdentityFactoryOptions options,
                    IOwinContext context)
                {
                    var manager = new ApplicationUserManager(
                        new UserStore(context.Get()));
            
                    // Configure validation logic for usernames
                    manager.UserValidator = new UserValidator(manager)
                    {
                        AllowOnlyAlphanumericUserNames = false,
                        RequireUniqueEmail = true
                    };
            
                    // Configure validation logic for passwords
                    manager.PasswordValidator = new PasswordValidator
                    {
                        RequiredLength = 6,
                        RequireNonLetterOrDigit = true,
                        RequireDigit = true,
                        RequireLowercase = true,
                        RequireUppercase = true,
                    };
                    var dataProtectionProvider = options.DataProtectionProvider;
                    if (dataProtectionProvider != null)
                    {
                        manager.UserTokenProvider =
                            new DataProtectorTokenProvider(
                                dataProtectionProvider.Create("ASP.NET Identity"));
                    }
                    return manager;
                }
            }
            

            What this code is doing is actually very simple, and I get that. But, there are a lot of types thrown around that I'm not familiar with... And then when I learn this particular codebase, the same thing will happen with another when I'm new to it. This was just a small example, but for example with the standard value types like int, double, string, it would be much more straightforward. That said, my current strategy is usually to just hit ALT+F12 in Visual Studio to take a peak at the code and just try to memorize it... But s

            F Offline
            F Offline
            Foothill
            wrote on last edited by
            #5

            TheOnlyRealTodd wrote:

            I'll implement something like this and then not even have to mess with it for a while (month or more), then start to forget it..

            It is for this reason that I am really starting to like Sandcastle. It requires a lot more effort when writing XML comments but the end product is worth it. I love having a code documentation website with the exact look and feel of MSDN but features my code. It even links forward to the official documentation of .Net classes.

            if (Object.DividedByZero == true) { Universe.Implode(); } Meus ratio ex fortis machina. Simplicitatis de formae ac munus. -Foothill, 2016

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups