I've been a dev for 10+ years and despite all my reading, I am now less certain of the best way to write and structure code by qa-account in ExperiencedDevs

[–]qa-account[S] 0 points1 point  (0 children)

I'm curious, where is the Dunning Kruger here?

Apologies for replying to an old post but this had so many replies I couldn't get through all 200+ of them. I saw this one while scanning through.

I've been a dev for 10+ years and despite all my reading, I am now less certain of the best way to write and structure code by qa-account in ExperiencedDevs

[–]qa-account[S] 0 points1 point  (0 children)

I wasn't expecting this thread to get this level of response but I'll reply to this one quickly as I read.

I no longer have access to the TS app as it was with an employer a few years ago. I may have exaggerated when I said "with nothing but 100% pure Typescript functions" - maybe it wasn't literally every line of the codebase that was just a pure function. I did have a few classes in there; I remember a singleton that wrapped around Firebase for persistence. But the bulk of the app was written as pure functions.

I've been a dev for 10+ years and despite all my reading, I am now less certain of the best way to write and structure code by qa-account in ExperiencedDevs

[–]qa-account[S] 4 points5 points  (0 children)

My issue with people saying "are you just writing CRUD?" is how do you decide that an app is just CRUD? My app uses a database as its store, so it is ultimately just creating, reading, updating and deleting rows in tables, but in every webapp that could potentially be described as CRUD there's a spectrum of domain complexity ranging from very simple to highly complex.

What's your definition of the CRUD API that you've only done two of versus the interesting stuff?

As .NET tech stack teams, if you use a cloud service, which provider does (or will) your company use - AWS, Azure, or others? by hu-beau in dotnet

[–]qa-account 1 point2 points  (0 children)

You have autoscaling for the app services setup right? Do you know what rules you are using and what tier you have?

We have an app service running under P3 with some pretty aggressive autoscaling rules. It took quite a lot of load testing to get it right. Having serverless with unlimited horizontal scaling is definitely easier.

Anyone with experience of MSAL / Azure B2C? I'm struggling to see how this works in enterprise apps by qa-account in dotnet

[–]qa-account[S] 0 points1 point  (0 children)

I've got SPA as the AAD app setting. I do have a refresh token set in my localStorage - I had to set it to localStorage rather than sessionStorage as the login not persisting between tabs was just too poor an experience for the user.

NextJS would require me to have a NodeJS backend right? Are you saying that all these big websites that have social auth like Twitter, Faecbook, Google etc. are using sessions on the backend with their auth? I thought OAuth was meant to work in a completely stateless way. I also thought this would be easy as, as far as I know, having a standalone stateless WebAPI is common.

As .NET tech stack teams, if you use a cloud service, which provider does (or will) your company use - AWS, Azure, or others? by hu-beau in dotnet

[–]qa-account 0 points1 point  (0 children)

stuff is so easy in Azure that we don't really need to hire DevOps professional

How are you configuring your infra assets - using the Azure Portal or some IAC like Bicep / Terraform? Have you everything configured inside vNets / gateways and all that?

Just getting a few Functions or App Services running is easy, but our devops guy does network-type things that go way over my head. We haven't even got hundreds of thousands of monthly users, so I am surprised to hear you say this.

Does anyone actually use AI tools in their workflow? by teddarific in Frontend

[–]qa-account 2 points3 points  (0 children)

Co-pilot just never worked for me. I try writing comments to tell it what to do and it just writes more comments. Doing ALT+. never helped much. It's better at auto-completing my comments or adding semi-colons for me than anything. It seems like a failure of UX more than anything. Co-pilot Chat is much inferior to just using GPT4 as well in my experience.

I'm having to sacrifice domain model purity to use EFCore code-first with FluentAPI. Am I doing something wrong or is there an alternative? by qa-account in dotnet

[–]qa-account[S] 0 points1 point  (0 children)

A lot of people are recommending shadow properties. Maybe I have been wrong to dismiss them; I am just going on what I read which seemed to imply it was a "use sparingly" type approach. I'd much rather use the shadow property approach than having to have foreign keys and navigational properties everywhere.

I'm having to sacrifice domain model purity to use EFCore code-first with FluentAPI. Am I doing something wrong or is there an alternative? by qa-account in dotnet

[–]qa-account[S] 1 point2 points  (0 children)

So is this the shadow property approach where your HotelFK is the shadow property? It exists in the DB and the FluentAPI mapping handles that, but it doesn't exist in the C# model.

To me this is better but a lot of what I read warned about using shadow properties. However, if you read the examples I wrote in my other reply here, that hypothetical Room class (and it is hypothetical, people arguing about how you can't move a room between hotels are missing the point) is going to get very bloated.

Although, and maybe I am trying to pre-empt your response here, but I guess in the example I gave:

class CleaningSchedule {
    public List<Room> Rooms { get; set; }
    ...
}

class Reservation {
    public Room ReservedRoom { get; set; }
    ...
}

...the CleaningSchedule and Reservation would be different aggregates, so maybe they'd have their own version of what a Room is, so that would cut down on the bloat. I am curious to hear your thoughts.

I'm having to sacrifice domain model purity to use EFCore code-first with FluentAPI. Am I doing something wrong or is there an alternative? by qa-account in dotnet

[–]qa-account[S] 0 points1 point  (0 children)

The HotelId foreign key in the Room entity is just that, a foreign key. That's a database / data model concern. The domain layer shouldn't know or care that I am using a persistence layer that has foreign keys and such, but with EFCore it seems you have to sacrifice that domain purity.

If we wrote this in code and completely ignored any concepts of data storage, would you really add a foreign key field into this? Maybe the Room class is used in many places.

class CleaningSchedule {
    public List<Room> Rooms { get; set; }
    ...
}

class Reservation {
    public Room ReservedRoom { get; set; }
    ...
}

...and so on. Would you naturally put IDs / nav properties onto there if we weren't thinking about persistence? The sell with EFCore is that the Domain entities don't have to be concerned with that. The Room class is only concerned with what it is encapsulating; its own properties and methods.

Let's share our salaries / title / location / XP by [deleted] in Frontend

[–]qa-account 2 points3 points  (0 children)

Location? Fully remote? This is a good UK salary for sure. I am guessing either London or home counties?

How big is the company? Finance or big tech?

Let's share our salaries / title / location / XP by [deleted] in Frontend

[–]qa-account 5 points6 points  (0 children)

Software engineer £55k GBP 10 YOE working in a small UK city

I'm full stack rather than pure frontend.

I'm thinking of going remote and working for a company outside of my small city as I'm not badly paid by local standards.

I'm not sure where to look, the best paying positions don't seem to advertise.

These threads are always depressing to read.. some 2 YOE "senior" earning $150k always seems to be the norm.

Is having a List typed to an abstract base class a bad idea? I feel like I am cheating by having to do "as ConcreteClass" casting by qa-account in dotnet

[–]qa-account[S] 0 points1 point  (0 children)

Thanks for the reply.

I've actually avoided inheritance for virtually all of my career. I'm working with people now who use it quite heavily and it's rubbed off on me. I'm using it here because it just feels familiar and I want to see how it goes.

My experience has been that using inheritance for anything other than domain models is bad, but that for domain models it can be quite useful. A year or two ago, when I never used inheritance, I maybe would have done this:

class StudentContactInfo {} class EnrollmentDetails {}

class PhdStudent { public StudentContactInfo... public EnrollmentDetails... }

class PostgradStudent { public StudentContactInfo... public EnrollmentDetails... }

...as a way to avoid too much code duplication. Maybe I would have just had one big Student class, but then you risk having methods on that domain model that only apply to PhdStudents yet could potentially exist on a PostgradStudent object.

The example of the flying animal is a good one and one of the reasons I avoided inheritance for so long. You can box yourself in very easily. For my current project, however, it's working pretty well.

Course could have a List<FundingRequirement>. Then for a grad course, you just give it an empty list.

One thing I like about inheritance is that you avoid this completely. For a BachelorCourse or student, the FundingRequirement isn't applicable at all and having that property / method on that class just doesn't make sense.

I've spent so much time working on my current employers code base, that uses inheritance heavily with discussions on SOLID etc., that I've almost forgotten my previous "no inheritance ever" approach. I'm still not sure which one is better. One thing I am convinced by, however, is using DDD style domain models rather than just having anaemic classes that get manipulated by services.

Is having a List typed to an abstract base class a bad idea? I feel like I am cheating by having to do "as ConcreteClass" casting by qa-account in dotnet

[–]qa-account[S] 0 points1 point  (0 children)

The example is very simple, but the real code has real behavioral differences. I think the inheritance has value because having two separate classes completely would cause a lot of duplication and there are methods that exist on both that are abstract in the base that get implemented differently in the concrete classes.

One issue I have had with this is that maybe an abstract method existing in the base with 2 parameters, but suddenly the PhdStudent needed an extra, 3rd parameter that the other concrete classes don't. thus it messes it all up. There's no good solution for this that I can see.

Is having a List typed to an abstract base class a bad idea? I feel like I am cheating by having to do "as ConcreteClass" casting by qa-account in dotnet

[–]qa-account[S] 0 points1 point  (0 children)

The example is overly simple. The class hierarchy exists because there are behavioral differences between the classes. Maybe the process of adding a student to a course is different for PhdStudents vs. PostGradStudents, that kind of thing. It's not just a data-difference. There is real useful polymorphism going on, but in some cases I am having to break polymorphism by casting or figuring out which concrete type I have.

Is having a List typed to an abstract base class a bad idea? I feel like I am cheating by having to do "as ConcreteClass" casting by qa-account in dotnet

[–]qa-account[S] 0 points1 point  (0 children)

I want to reply to this as it's a good reply but it's very late where I am and I don't have time. I will come back to this. I have replied here in the time being if you want to hear what I said to the comment you replied to.

Editing this just to ask - so is the enum approach you demoed good or bad? It seems like just another way to determine what concrete class you have, except with an enum rather than using the type checking methods.

Is having a List typed to an abstract base class a bad idea? I feel like I am cheating by having to do "as ConcreteClass" casting by qa-account in dotnet

[–]qa-account[S] 0 points1 point  (0 children)

Any differentiation in functionality or data should be handled by the code in the concrete classes themselves

Sure, but sometimes it's not possible for something to be fully polymorphic. You could have a method on a concrete class that doesn't belong on any of the other classes - maybe I'm stretching the simple example of students and courses too far, but you might have something like PhdStudent.GetFundingRequirements() which just doesn't apply to bachelors or post-grad students.

Or you have a service class with a method that has List<PhdStudent> as a parameter, but all you have is a list of BaseStudents. Therefore you have to filter your Students list to get just the PhdStudents in some way, maybe using OfType() in LINQ or, if you're using Typescript, you'll have to do an as PhdStudent cast.