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
T

TheOnlyRealTodd

@TheOnlyRealTodd
About
Posts
58
Topics
36
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How do you problem solve?
    T TheOnlyRealTodd

    We all know programming is problem solving, and often the ability to problem solve effectively is one of the most desired traits in a professional programmer. However, compared with syntax books and tutorials, there are surprisingly few articles on steps used to problem-solve any programming-related task. Give us a list of general steps that work for you to solve programming problems. Here is mine. Feel free to critique it as well: 1. Determine the problem. 2. Break the problem down into smaller problems 3. Prioritize the smaller problems 5. Think of solutions for the first problem on the list and begin working 7. Review code and make it better I often hear in interviews that people are "Trying to see how the candidate solves/approaches problems," so clearly this is a big one. Also, please note that the scope of this post is specifically smaller problems such as basic algorithms used in programming tests. Not talking about system architecture here. Any tips appreciated.

    Design and Architecture architecture help question lounge

  • Working Between Visual Studio and Visual Studio Code
    T TheOnlyRealTodd

    I started working on a project with some guys who are using Visual Studio Code. I've not much experience with it, but I'd like to use my VS 2015 as usual because there seems to be all kinds of features lacking from VSC that I use a lot. It seems to have no concept of namespaces, and I can write a class that doesn't exist yet and it won't turn red, etc... I try to open the folder in Visual Studio 2015 by going to File -> Open Web Site and doing it that way, and then all hell breaks loose. I know it needs to make .sln and csproj which is fine, but Resharper races my CPU for like 5 minutes straight and then there is no project resources area so even main VS has absolutely no idea about the namespaces, classes, etc... Does anyone know how I could use VS to work on this C# .NET Core project, alternatively if I can get some VS features in VSC? This is sort of baffling my mind how challenging opening this C# project has become. Regards.

    C# csharp visual-studio asp-net dotnet question

  • What is this JWT Code Doing?
    T TheOnlyRealTodd

    I agree with you. It's pretty clear to me that, just like in many other areas/trades, there are many "features" included in modern programming languages which are to be blunt, for lazy people. Or at least abused by them. The thing that always baffles my mind is people do everything they can to try and type less, yet I've never met one programmer whose problem is that they spend too much time typing. In fact, I wished I spent more time typing and less time dealing with bs!

    C# json tutorial question csharp data-structures

  • What is this JWT Code Doing?
    T TheOnlyRealTodd

    I'm following a tutorial for Web API Jwt Tokens but am confused on what exactly this below code is doing. When I read tutorials, I like to take the time to understand the content rather than just sorta copy/paste blow through them. If anyone is familiar with this type of code, please give me a little walkthrough. I'll go ahead and narrate how I feel this is working below to start it off:

    public string Protect(AuthenticationTicket data)
    public class CustomJwtFormat : ISecureDataFormat
    {

        private readonly string \_issuer = string.Empty;
    
        public CustomJwtFormat(string issuer)
        {
            \_issuer = issuer;
        }
    
        public string Protect(AuthenticationTicket data)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }
    
            string audienceId = ConfigurationManager.AppSettings\["as:AudienceId"\];
    
            string symmetricKeyAsBase64 = ConfigurationManager.AppSettings\["as:AudienceSecret"\];
    
            var keyByteArray = TextEncodings.Base64Url.Decode(symmetricKeyAsBase64);
    
            var signingKey = new HmacSigningCredentials(keyByteArray);
    
            var issued = data.Properties.IssuedUtc;
            
            var expires = data.Properties.ExpiresUtc;
    
            var token = new JwtSecurityToken(\_issuer, audienceId, data.Identity.Claims, issued.Value.UtcDateTime, expires.Value.UtcDateTime, signingKey);
    
            var handler = new JwtSecurityTokenHandler();
    
            var jwt = handler.WriteToken(token);
    
            return jwt;
        }
    

    The code appears to: 1. Accept user claims as an argument called "data" (?) 2. After ensuring the data isn't null, it pulls an "AudienceId" and "AudienceSecret" from AppSettings in web.config and assigns to two variables. 3. It decodes the AudienceSecret from Base64Url into a byte array? <----This is where I'm confused. The secret is just a URL??? 4. It now takes the decoded URL and then passes it into a hash function, creating a keyed-hash message authentication code "signing credentials" (also confused a bit here) 5. Assigns issued and expiry date to the claims/data. 6. It then creates a token with the above data 7.News up a "token handler" and then creates yet another jwt token variable and finally appare

    C# json tutorial question csharp data-structures

  • Is there anything wrong with passing state via argument?
    T TheOnlyRealTodd

    Awesome thanks for the feedback.

    C# csharp business question

  • Is there anything wrong with passing state via argument?
    T TheOnlyRealTodd

    I first learned C# then C. As I've been working in C a lot lately, I've had to do without classes obviously since it's not really an OOP language. I've gotten rather accustomed to passing stuff in as arguments and I'm writing a C# program right now where I've been passing "state" around via the method arguments rather than the typical storing fields/properties on the class and then accessing them from the class methods. Is there anything "wrong" about doing this? Is there anything "wrong" with not using the constructor to initialize member variables to certain values and instead just using a function in the class that calls the other business functions? E.G.

    someObject myObject = new someObject();

    var processResult = myObject.process(someString,Processor_Option_1);

    Instead of:

    someObject myObject = new someObject(someString,Processor_Option_1);

    var processResult = myObject.result;

    Note: Option 2 also uses class state member variables whereas 1 just passes it function-to-function as argument.

    C# csharp business question

  • Who would you hire and why?
    T TheOnlyRealTodd

    You're a hiring manager. You are responsible for picking a candidate who will be in a long-term position with the company and who you know you will be able to mold/teach. Both candidates are friendly and willing to learn. But there's a slight challenge. Candidate A writes extremely clean and readable code, follows SOLID principles, writes great unit tests, and overall has the software engineering side of things down, but he knows nothing about algorithms or data structures aside from just using what is provided in the standard libraries. Candidate B knows all of the sorts, trees, and hashes like the back of his hand and is able to whiteboard them out no problem and answer all of your questions quickly under pressure. However, Candidate B has no experience with object-oriented design, SOLID principles, has a few demo apps which are only procedural in nature, and has never written a unit test in his/her life. Both candidates are friendly and both seem like they have potential to learn. Your firm uses object-oriented programming in either C# or Java and produces applications that must meet a efficiency standard and also meet OOP design guidelines. Who do you hire and why?

    The Lounge question csharp java design testing

  • Motivation for Data Structures
    T TheOnlyRealTodd

    Thanks. And I appreciate your post. Sometimes I need a kick in the right direction, which is also why I ask these types of questions. I try to follow this advice:

    I am the smartest man in Athens because I know that I know nothing. - Socrates

    The Lounge design question career

  • Motivation for Data Structures
    T TheOnlyRealTodd

    Awesome. I think I just needed to find the right instruction source and implementation. I found a book that is now working for me and I'm finding it much more interesting/fun to implement the data structures in C++ than C# or Java, mainly due to how pointers work.

    The Lounge design question career

  • Motivation for Data Structures
    T TheOnlyRealTodd

    Vunic wrote:

    Quite a bunch of my friends know nothing other than C & Assembly.

    I need to make friends like this. Seriously. I've had quite a struggle meeting these types of programmers versus web devs. Web dev stuff is everywhere, not so much lower-level. I feel I could learn a lot from these people. In any event, thanks so much for your insight, it was very helpful! And yes, I meant to say "DS & Algorithms" . My course is simply called Data Structures & Performance, but that is what is really is. Also, Big O and asymptotic notation, and even most of the math I get (and enjoy) pretty well... Its just doing things like crafting up routines to add/remove/replace etc... Data from a structure that can seem a little dry at times. I think it's just a matter of time, but honestly, the advice here has helped a lot and I want to thank everyone for replying!

    The Lounge design question career

  • Web API integration into MVC
    T TheOnlyRealTodd

    Thought i was the only one who caught that.

    The Lounge asp-net json architecture help tutorial

  • Motivation for Data Structures
    T TheOnlyRealTodd

    I'll be honest. One of the things that attracts me to crafting software is the end-product. I also am not always the most patient guy in the world (except for with computers, surprisingly, lol). In any event, I'm not super into data structures, although I try desperately hard to be because I know how fundamental they are and I know how important to even just landing a nice job they can be. But nevertheless, I'd rather spend 5 hours coding and have something to show, rather than re-create an intangible data structure that already exists in the standard library, just for the sake of it (or erm... class). Right now, the data structures are not my strong point and I've been getting a little turned off to programming by spending so many hours on such primitive parts. Surely there must be others who have suffered this? Do you have any tips on keeping motivated to give up production code time to study data structures for a while? I'd much rather write unit tests and design patterns!

    The Lounge design question career

  • Learning a big new codebase
    T TheOnlyRealTodd

    Do you have any recommended strategies for a junior developer when attempting to learn a large new codebase? One of my goals is to make some commits on something like ASP.NET MVC (.NET Core now), Entity Framework, Node.js, or some other major project on GitHub. Not surprisingly however, when I open the project file for these, it can be tough trying to figure out where to even start. Of course I can view the issues and try my hand at solving one, but I found that even that often requires a general idea of the project's moving parts. Do you have any suggestions or resources on breaking down a big project like this to bite-sized chunks that can be learned over time in hopes of a serious contribution? One strategy I've tried is looking at the classes that I am familiar with from using the software and also looking at the unit tests to get an idea of whats happening. Thanks.

    The Lounge asp-net javascript learning csharp dotnet

  • Unit Testing/TDD Help
    T TheOnlyRealTodd

    I'm just now trying to adopt my thinking to Test Driven Development mode and I'm finding strange, inconsistent, and bizarre things happening in my thought processes and code in some ways as well. Is this pretty normal when you first try to learn TDD? For example, I find myself writing a lot of tests and then realizing afterwards "Hey, that could/should have been broken down into 2 separate unit tests" or maybe vice-versa. I'm not really sure what/if there is a gold-standard on how much a unit test should be broken down. Another thing is sometimes I question whether I am wasting my time on a specific test. So for example, say I have some simple code like this:

    public class IntegerStats
    {
    public int MaxValue { get; private set; }
    public int MinValue { get; private set; }
    public int NumberOfElements { get; private set; }
    public double AverageValue { get; private set; }

        public IntegerStats(int\[\] inputArray)
        {
            MaxValue = inputArray.Max();
            MinValue = inputArray.Min();
            AverageValue = inputArray.Average();
            NumberOfElements = inputArray.Length;
        }
    }
    

    My first two unit tests look like this:

    [Test]
    public void ProvideArrayReturnsIntStatsObject()
    {

            int\[\] testArray = {1, 5, 254783, 98, 4793, 67};
            IntegerStats intStats = new IntegerStats(testArray);
    
            Assert.IsTrue(intStats.GetType().ToString().Contains("IntegerStats"));
    
        }
    
        \[Test\]
        public void Length5ArrayLengthIs5()
        {
            var result = new IntegerStats(new int\[\]{5,4,8,9,4});
    
            Assert.AreEqual(result.NumberOfElements,5);
        }
    

    However, should I be passing multiple arrays in to this one test or should I make several array length tests of different lengths? How do I know if the method is adequately tested? My next plans were to continue testing the other properties... But then I was questioning whether I should even be testing these methods since they are using built-in provided standard library algorithms rather than my own custom algorithms in the first place. Also, I had first started out with a test checking whether all of the stats were accurate in one big test but then I realized that's not really a unit test since it could/should have been broken down more. Any advice/resources on this would be super helpful. The thing is, I've done plenty of reading

    The Lounge testing question data-structures beta-testing help

  • Double-Stacking?
    T TheOnlyRealTodd

    Have you found any solution to debugging in MEAN? I'm struggling hard on this right now. It seems to be hell/non-existent compared with ASP.NET.

    The Lounge csharp asp-net data-structures business question

  • Double-Stacking?
    T TheOnlyRealTodd

    Is it valuable or a good idea to know more than one web stack? I've spent most my time working with C#/ASP.NET and associated tech but the majority of guys I am close with in my area use MEAN stack, in addition, my goals are to work for a startup or smaller business and they tend to use MEAN stack around here as well. For this reason, I've been learning MEAN, which, in reality, the A and other front-end stuff is actually used in ASP.NET often anyway, so there is some overlap in knowledge. However, my OOP brain isn't used to thinking functionally like I have to in MEAN sometimes, and it's a challenge for sure, but also fun. If nothing else, I figure I can weigh the pros and cons of both stacks and use them when convincing an employer to use either one.

    The Lounge csharp asp-net data-structures business question

  • Getting a HARD URL for Your own Action
    T TheOnlyRealTodd

    Does anyone know how to create a simple hard URL to an action in MVC5? I'm not using it in the context of a View though, I am generating a unique URL and storing it into the database... Trying to use this:

    public IHttpActionResult Create(Url url)
    {
    UrlHelper helper = new UrlHelper();
    if (!ModelState.IsValid)
    {
    BadRequest();
    }
    url.OurUrl = helper.Action("Go","Redirect", null, "http") + url.UrlId;
    _context.Urls.Add(url);
    _context.SaveChanges();

    return Created(new Uri(Request.RequestUri + "/" + url.UrlId), Url);
    }

    I've tried all kinds of variations on the Action() method... Like just using Go and Redirect as arguments... And what you see there. But it keeps telling me that routeCollection cannot be null I'm confused because routeCollection isn't even a parameter listed in the method. Thanks.

    ASP.NET database tutorial question

  • Finding Well-Written Software
    T TheOnlyRealTodd

    Thank you! Yeah, it seems writing good code stems from both design and good coding practices... Currently, I am reading the books Code Complete and Clean Code by Uncle Bob. Code Complete seems to focus more on the design aspect stuff, and Clean Code seems to focus more on the actual code-writing practices. However, Simply looking at projects gives me at least some insight into the coders' styles out there and what type of code I will run into out there.

    The Lounge csharp c++ java algorithms question

  • Finding Well-Written Software
    T TheOnlyRealTodd

    California 90025 wrote:

    Another thing is there is no objectively "well written" software. When you go out into the industry (I'm assuming you still haven't or are new to it), you will come across all kinds of a-holes who find fault with every f-ing thing no matter how well it's written. I think there was someone who posted here about how the boss rejected his code because the others were too incompetent to understand it.

    I've wondered about this, as someone who has not yet worked at a shop. I hear a lot about how there really isn't any ideal code and "as long as it works, it's fine" but at the same time, there are highly acclaimed books and articles that suggest that there is in fact a "right way" to write code, such as Code Complete by Steve McConnell, and that Clean Code book by Uncle Bob. Ultimately, of course this is just their suggestions, but nonetheless, they seem to be well-accepted suggestions. Though, I believe every word you say about people picking apart your code no matter what, I may not have worked at a shop yet, but I've been working with people for a long time, lol.

    The Lounge csharp c++ java algorithms question

  • Finding Well-Written Software
    T TheOnlyRealTodd

    Interesting, yet what you said makes sense about deadlines and stuff... Unfortunately the real world doesn't always allow for nicely-put-together stuff... In any profession really. Well, I've been reading several good software engineering books lately and was just looking for more real-world examples besides the simplified stuff in the book. Surely someone must be able to write what they call "clean code", no? If not, what exactly are most employers judging you on? If they don't really care about the code quality, then what are they looking for in the interview? I've done a few small projects/freelance jobs but I have not yet formally worked for an employer.

    The Lounge csharp c++ java algorithms question
  • Login

  • Don't have an account? Register

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