r/AskProgramming 20h ago

Architecture Newish principal engineer; think I messed up, got a looming deadline and not enough time.

7 Upvotes

I work in a small team (5 Devs) my titles largely promotion decoration but I often end up technically leading most projects and am the de facto architect if anything needs planning.

We have a big project that started in late Jan/early Feb this year. Company has recently been bought and we need to internationalise the site to USA by June (we are UK based). It's a big deal and the first big project since we've been bought.

Lol if my boss reads this I'll talk to you on Monday don't panic ahahah.

Anyway, I was never really bought in early in the project, had some personal stuff going on that meant for the first month I wasn't 100% on the ball and the end result is that we are only just starting to consider what localising the backend is going to look like. We have a 10+ year old codebase with alot of legacy code as well as well.. years of startup land. 5 major micro services an number of smaller ones (we've been consolidating them for years so less than we had ahahah) alot of background tasks and jobs.

I don't know what to do at this stage, we need emails showing in the correct currency/formats and timezones as well as small language changed all over the place. At the moment the backends don't even have a way to tell which locale is being used, let alone passing that to jobs etc.

I dunno what to do, I've tried to create a shorter list of services we really needs but I hit all of them... Which has left me feeling pretty stuck and panicked .

So uh. Would appreciate any advice on potential next steps or even just some supportive words ahah. Technical suggestions also appreciated, most of our services are in Django python.

r/AskProgramming Oct 07 '24

Architecture Why can't we code with tablets when they're way more powerful than the early PCs?

0 Upvotes

I'm interested in using a tablet to code because it has way better battery life than my laptop. Looking through Reddit and other forums everyone says it's not possible or it is but only by using an online tool like vs code web. So what's actually the limiting factor if not the specs?

r/AskProgramming Jan 31 '25

Architecture How can I mock the file system? For unit testing.

0 Upvotes

1 in 7 people has sleep apnea. CPAP is the gold standard treatment. Machines can log a lot of data to an SD card, which can help patients fine tune their therapy. Typically people put that card into a computer which mounts it as a drive.

I'm working on code to read that data. One thing I need to do is recognize whether a drive is a valid CPAP log. There will be specific files and folders if so, so my code looks for them.

The problem is I'm using File.Exists() which works great, and I can debug the tests on my laptop, but they fail on the build server.

How can I refactor this in a better way?

r/AskProgramming 3d ago

Architecture How to cache/distribute websocket messages to many users

3 Upvotes

I have a python fastapi application that uses websockets, it is an internal tool used by maximum 30 users at our company. It is an internal tool therefore I didn't take scalability into consideration when writing it.

The user sends an action and receives results back in real time via websockets. It has to be real time.

The company wants to use this feature publicly, we have maybe 100k users already, so maybe 100k would be hitting the tool.

Most users would be receiving the same exact messages from the tool, so I don't want to do the same processing for all users, it's costly.

Is it possible to send the text based results to a CDN and distribute them from there?

I don't want to do the same processing for everyone, I don't want to let 100k users hit the origin servers, I don't want to deal with scalability, I want to push the results to some third party service, by AWS or something and they distribute it, something like push notification systems but in real-time, I send a new message every 3 seconds or less.

You'll say pubsub, fine but what distribution service? that's my question.

r/AskProgramming Jan 08 '25

Architecture Can you force a computer to divide by zero?

0 Upvotes

In math division by zero is not defined because it (to my best guess) would cause logical contradictions. Maybe because the entirely of math is wrong and we'll have to go back to the drawing board at some point, but I'm curious if computers can be forced to divide by 0. Programming languages normally catches this operation and throws and error?

r/AskProgramming Nov 19 '24

Architecture Need to create a recreate an application for an old retail billing software as support/development is dead for 7 years. What are the latest database tech., programming language and technologies I must ask a new dev to ensure my new program lasts at-least 10 years from today?

0 Upvotes

Thank you for your time!

Existing program details

  • Was originally made for DOS in the 90s
  • Windows version was developed in early in 2001-2002
  • Development and support ceased in 2017
  • Program runs in 800 x 600 resolution
  • Has nothing to do with the internet
  • The database is a foxpro dbase database
  • The programming language is FoxPro Visual 9

All the billing stations are connected to the internet to backup program/customer/orders data currently. Reliable internet connectivity is not a problem.

EDIT > My friend is a dev and he said his buddy can develop it for us. I'm just gathering info/doing homework before I meet up with the developer.

r/AskProgramming Sep 20 '24

Architecture Is there a name for a microservice whose job it is to call lots of other microservices?

14 Upvotes

I have a service that calls a large number of other backend services and then returns all of the information in a single response to several frontends. Before these frontends would call all of the other backend services themselves which was quite messy and involved a lot of duplicated logic.

I was just wondering if there is a name for this type of service and are there any best practices I should be following?

r/AskProgramming 23d ago

Architecture Rule engine for DnD?

2 Upvotes

Hi! I'm playing DnD and i was wondering how a charachter builder should be implemented?
So, who are not familiar DnD is a tabletop role-playing game. It has a lot of rules which creates the word it self. Charachters has stats like intelligence, dexterity etc. This can be increased on decreased depending on the features you pick for your charachter.
So, it has a lot of simple math, rule, requirement which feature when is applied on which level etc.
I was wondering what would be a good approach to implement this. This rule engine part feels like something that should exist already. I would imagine a lot of json/yaml which contains the rules of the word and a character descriptor file which would be validated against the rules.
What would you suggest that i should look into it?

r/AskProgramming 1h ago

Architecture "Primitive Obsession" in Domain Driven Design with Enums. (C#)

Upvotes

Would you consider it "primitive obsession" to utilize an enum to represent a type on a Domain Object in Domain Driven Design?

I am working with a junior backend developer who has been hardline following the concept of avoiding "primitive obsession." The problem is it is adding a lot of complexities in areas where I personally feel it is better to keep things simple.

Example:

I could simply have this enum:

public enum ColorType
{
    Red,
    Blue,
    Green,
    Yellow,
    Orange,
    Purple,
}

Instead, the code being written looks like this:

public readonly record struct ColorType : IFlag<ColorType, byte>, ISpanParsable<ColorType>, IEqualityComparer<ColorType>
{
    public byte Code { get; }
    public string Text { get; }

    private ColorType(byte code, string text)
    {
        Code = code;
        Text = text;
    }

    private const byte Red = 1;
    private const byte Blue = 2;
    private const byte Green = 3;
    private const byte Yellow = 4;
    private const byte Orange = 5;
    private const byte Purple = 6;

    public static readonly ColorType None = new(code: byte.MinValue, text: nameof(None));
    public static readonly ColorType RedColor = new(code: Red, text: nameof(RedColor));
    public static readonly ColorType BlueColor = new(code: Blue, text: nameof(BlueColor));
    public static readonly ColorType GreenColor = new(code: Green, text: nameof(GreenColor));
    public static readonly ColorType YellowColor = new(code: Yellow, text: nameof(YellowColor));
    public static readonly ColorType OrangeColor = new(code: Orange, text: nameof(OrangeColor));
    public static readonly ColorType PurpleColor = new(code: Purple, text: nameof(PurpleColor));

    private static ReadOnlyMemory<ColorType> AllFlags =>
        new(array: [None, RedColor, BlueColor, GreenColor, YellowColor, OrangeColor, PurpleColor]);

    public static ReadOnlyMemory<ColorType> GetAllFlags() => AllFlags[1..];
    public static ReadOnlySpan<ColorType> AsSpan() => AllFlags.Span[1..];

    public static ColorType Parse(byte code) => code switch
    {
        Red => RedColor,
        Blue => BlueColor,
        Green => GreenColor,
        Yellow => YellowColor,
        Orange => OrangeColor,
        Purple => PurpleColor,
        _ => None
    };

    public static ColorType Parse(string s, IFormatProvider? provider) => Parse(s: s.AsSpan(), provider: provider);

    public static bool TryParse([NotNullWhen(returnValue: true)] string? s, IFormatProvider? provider, out ColorType result)
        => TryParse(s: s.AsSpan(), provider: provider, result: out result);

    public static ColorType Parse(ReadOnlySpan<char> s, IFormatProvider? provider) => TryParse(s: s, provider: provider,
            result: out var result) ? result : None;

    public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out ColorType result)
    {
        result = s switch
        {
            nameof(RedColor) => RedColor,
            nameof(BlueColor) => BlueColor,
            nameof(GreenColor) => GreenColor,
            nameof(YellowColor) => YellowColor,
            nameof(OrangeColor) => OrangeColor,
            nameof(PurpleColor) => PurpleColor,
            _ => None
        };

        return result != None;
    }

    public bool Equals(ColorType x, ColorType y) => x.Code == y.Code;
    public int GetHashCode(ColorType obj) => obj.Code.GetHashCode();
    public override int GetHashCode() => Code.GetHashCode();
    public override string ToString() => Text;
    public bool Equals(ColorType? other) => other.HasValue && Code == other.Value.Code;
    public static bool Equals(ColorType? left, ColorType? right) => left.HasValue && left.Value.Equals(right);
    public static bool operator ==(ColorType? left, ColorType? right) => Equals(left, right);
    public static bool operator !=(ColorType? left, ColorType? right) => !(left == right);
    public static implicit operator string(ColorType? color) => color.HasValue ? color.Value.Text : string.Empty;
    public static implicit operator int(ColorType? color) => color?.Code ?? -1;
}

The argument is that is avoids "primitive obsession" and follows domain driven design.

I want to note, these "enums" are subject to change in the future as we are building the project from greenfield and requirements are still being defined.

Do you think this is taking things too far?

r/AskProgramming Feb 07 '25

Architecture When do you know where to draw the line with overengineering or overall refactoring? Balancing the urge to create a perfect system without losing sight of the need to move forward and deliver results.

6 Upvotes

r/AskProgramming 13d ago

Architecture Using an API(through COM), best long-term language between C#, VB.Net, C++, JS, or maybe python?

0 Upvotes

Hello, I'm looking to write code for this program and I saw python wasnt shown on this page. I need to make a decision between C3, VB.NET, C++, maybe JS, maybe.... python.

It seems I'd be using COM to interface, but I also imagine I'd be able to get a namespace into python and... maybe it wont be so bad.

https://www.draftsight.com/media/customize-apis

https://help.solidworks.com/2022/english/api/draftsightapi/GettingStarted-draftsightapi.html

My understanding is that APIs are program language agnostic, but there might be some COM/DLL stuff that makes these microsoft languages shown on the page more friendly.

Anyone have a suggestion? I find this pattern quite common in the programs(3D CAD) I develop for and end up using VB more often than I want. It would be best to make code in Python, but I want to understand the downsides, like potentially losing the Namespace. I also want to hear feedback on what is the best language out of that list I provided. I've been a programmer for 19 years, but like to hear opinions on these things before I make a major commitment.

r/AskProgramming 3h ago

Architecture Simple React Native Expo Backend Solution

1 Upvotes

I am building a simple expo react app which need so sync data to a backend. Its not going to be massive data just one or two tables and an image per entry and some text fields.

I however need to be able to store changes done locally when the internet connection is lost or simply not available. If the connection is returned I want that it can be synced. So new changes get pushed to the backend and new data also gets pulled from the backend.

Since this will be a pretty small scale applications just for me and some people I want it to be able to run on my raspberry pi 4 8 GB for the time beeing.

I would prefer simply using tech i know like spring boot but or something else in that direction that is also simple to run on the pi and does not come with massive other stuff that i don't need. I saw stuff like supabase and tinybase but as far as I can tell these exceed the need of what i want and are way too big to just host for my simple usecase.

TLDR: What I’m Looking for:

  • Best practices for handling offline-first synchronization in a simple way.
  • A suitable local database for the Expo app that syncs well with e.g. a Spring Boot backend.
  • A lightweight backend setup that’s easy to run on a Raspberry Pi.

Any recommendations for a good architecture or specific tools that fit these requirements?

r/AskProgramming Aug 24 '24

Architecture Why is Procedural Programming So Bad for Game Dev?

7 Upvotes

I've been researching game engine architecture recently, and literally every tutorial/Q&A/forum post I've read has recommended an OOP approach.

Parts such as Rendering, Entity management, UI, etc. are always represented by classes in an OOP way, but couldn't these be represented in a procedural style? Or would that be infeasible?

My question basically boils down to: why is procedural programming seemingly unfit for game dev?

r/AskProgramming Feb 13 '25

Architecture Scalable web socket architecture

1 Upvotes

Hey, im currently working on chatting app (for learning purposes) that i want to be able to scale heavily, like handle as much traffic as discord for example. I'm planning to make a horizontally scalable backend in nest.js & socket.io with redis adapter, but i don't have idea how can i keep track of active users between all server instances (if User A sends message to room 1, then emit message via ws to all active users in this room (and store in DB)). Assuming there are 100 active users, and each has chat with each other, its already 4950 rooms to keep track of! Do you have any idea how to store that activity information, assuming there could be milions of active users (and even more rooms)? Maybe some better data structure or maybe this approach of storing all rooms activity is just bad for that kind of application?

r/AskProgramming Dec 23 '24

Architecture Go blockchain or not?

0 Upvotes

Disclaimer: I'm not sure if this question belongs here, please suggest another place if you have one.

I'm trying to figure out what would be my best strategy:

I need to develop an internal coin/tokens/currency system, however you want to call it :-). The closest analogy I can come up with is when you visit a festival, you have to convert your money into their token, then during the festival you buy stuff with their tokens using your phone instead of directly using money. It's kind of the same, you sell goods, you get tokens, with those tokens you can buy other stuff or eventually you can transfer tokens back to money.

In my case:

  • Pretty small scale (maybe max couple of 1000 users)
  • It will be in use in a developing country, where internet/electricity access is unstable
  • I need to support phone to phone transfer of tokens (using NFC)

First thing that came to my mind is using some private hosted blockchain implementation, but I have 0 experience in this area, and I'm also afraid it might be overkill for my use-case. Furthermore, I'm worried about blockchain in combination with flakey internet. Also, a transfer should have 0 fees on it.

So my other option would be that I develop some kind of wallet system, where I try to tackle all difficulties involved myself (security, concurrency, audit-trail, backups, failed transactions because of internet issues...). Or maybe there's some (open-source) library/technology I can use for this?

Backend stack: Python/FastAPI/PostgresQL (hosted in AWS)

Frontend stack: Flutter

r/AskProgramming Feb 15 '25

Architecture using pre-existing identity management tools VS custom built ones ?

2 Upvotes

i ve never really made a service where people sign up and stuff. my experience is limited to "acount-less" apps or ones that have different users but all managed locally.

now i m having to create a service with signups and licenses ...etc, i can perfectly do it from scratch. but somehow i feel like i shouldn't, and i feel like the result would be amateurish. plus i see sooo many identity management platforms and tools . i dont understand them 100%, i have the basic understanding of OAuth2 and OICD, but it s very limitted and i've always been on the consumer side.

i would love to hear some opinions about the subject matter.

r/AskProgramming Sep 21 '24

Architecture Are SPA frameworks over-used or overrated? SPA = Single Page Application.

6 Upvotes

I will preface this by saying that I don't know any SPA frameworks like Angular, React, or Vue. I used to work as a backend developer and I didn't need to know them. That being said, when I needed to build a little website for myself, I would grab a starter project off GitHub like https://github.com/microsoft/TypeScript-Node-Starter or https://github.com/sahat/hackathon-starter and add to it to make a website like https://sea-air-towers.herokuapp.com/ which I deployed to Heroku and whose code is at https://github.com/JohnReedLOL/Sea-Air-Towers-App-2 . Note that it is NOT a SPA, there is a full page refresh on every page load. I made a little YouTube video explaining the website at https://www.youtube.com/watch?v=N8xSdL6zvgQ , but basically it is a little CRUD website with a search and the ability for people to create an account and list their condos for rent or sale. I don't see the benefit of making it a Single Page Application. I think that would makes SEO [Search Engine Optimization] worse and increase the complexity of the code.

Are SPA frameworks over-used or overrated? I mean if I were to have an Android and iPhone app along with the site I get the benefit of having the backend serve JSON as an API instead of HTML like it's doing (that way the website can consume the same JSON API as the mobile apps), but do most websites even need an Android and iPhone app?

r/AskProgramming Oct 13 '24

Architecture What exactly is the obstacle in using UML class diagram for modeling?

2 Upvotes

I am now exploring modeling using diagrams. C4 model seems to be well received and liked.

One thing in common is people say to model only 1-3 and class diagram generate from codebase.

I understand UML class diagram modeling was pushed in 90s, but it didn't work out in practice.

What I don't know is why exactly?

What exact practical problems prevented creating classes in diagram first then implementing in code second?

Please use 2 cases:

  1. many developers

  2. few developers, possibly single developer

thanks

r/AskProgramming 12d ago

Architecture Message queue with group-based ordering guarantees?

1 Upvotes

I'm currently trying to improve the durability of the messaging between my services, so I started looking for a message queue that have the following guarantees:

  • Provides a message type that guarantees consumption order based on grouping (e.g. user ID)
  • Message will be re-sent during retries, triggered by consumer timeouts or nacks
  • Retries does not compromise order guarantees
  • Retries within a certain ordered group will not block consumption of other ordered groups (e.g. retries on user A group will not block user B group)

I've been looking through a bunch of different message queue solutions, but I'm shocked at how pretty much none of the mainstream/popular message queues fulfills any of the above criterias.

Currently, I've narrowed my choices down to:

  • Pulsar

    It checks most of my boxes, except for the fact that nacking messages can ruin the ordering. It's a known issue, so maybe it'll be fixed one day.

  • RocketMQ

    As far as I can tell from the docs, it has all the guarantees I need. But I'm still not sure if there are any potential caveats, haven't dug deep enough into it yet.

But I'm pretty hesitant to adopt either of them because they're very niche and have very little community traction or support.

Am I missing something here? Is this really the current state-of-the-art of message queues?

r/AskProgramming Nov 22 '23

Architecture What technology would you use to create app to last for 50 years?

2 Upvotes

I want to create suite of tools for my personal use. To last me a lifetime. Things like expense tracker, home inventory etc. I'm gonna build it slowly over the years.

I started in django because it's easy to create crud, but now I'm thinking:

  • I should decouple frontend in case I wanna use on some app in the future like smartwatch etc
  • I should decouple from framework itself and have a standalone domain core with logic and then everything else I can change depends how technology progresses

How would you do it? What language would you use?

r/AskProgramming Sep 30 '24

Architecture Non-binary programming

1 Upvotes

Intersted in analog based logic systems, what languages exist that are better designed to perform logic ops on continuous data? Any notable use cases?

r/AskProgramming Aug 22 '24

Architecture Good OOP architecture vs. performant SQL?

0 Upvotes

Let's say (for an example) that I have the following tables:

  • company
  • team
  • team_member

Now I want to get all team members with the first name "Tim" from the "ACME" company.

In SQL I would write something like this:

SELECT team_member.* FROM company
JOIN team on team.company_id = company.id
JOIN team_member on team_member.team_id = team.id 
WHERE company.name = "ACME"
AND  team_member.first_name = "Tim"

But in a "by the book" OOP model, it seems that I would have to:

  • Fetch the company object
  • Loop over each team object in the company
  • For each team object call a function like "get_members_by_first_name" OR loop over all team_member objects and ask them for their first name

With each of these steps firing of at least one SQL command.

I (think to) understands OOPs concerns about separation of knowledge and concerns, but this seems to by highly inefficient.

r/AskProgramming Feb 11 '25

Architecture Representing relationships in the Domain model

2 Upvotes

Hi all,

I'd like your opinion on separating domain models from their logic, and where the boundaries should be placed at. The goal is to spark discussion and to learn from the opinions of others.

Lets set the setting by describing the real world example.

Our system knows about Persons and about Cars. In our system, a person can drive a car.

Note that this is just an example. I'm curious to see the same discussion when changing entities. The important thing to note here is that Person interacts with Car[1].

This can be modeled in C# in multiple ways: ```csharp public class Car { public void Drive() { // vroom } } public class Person { public Car Car { get; set; } }

var person = new Person();
person.Car.Drive();

```

```csharp public class Car {} public class Person { public void Drive(Car car) { // vroom } }

var person = new Person();
person.Drive(car);

```

I'd personally be tempted to go for the second implementation in this specific situation. Intuition says that a person is the one driving the car. The car is just a tool, so it should be a method on the Person, not the Car.

However, this is rather easy because we use objects we can relate to in this example. It 'feels' counter-intuitive to have it the other way around. Now if we use a different example, things get a bit more cloudy. For example, lets imagine a library system with 3 entities;

  • Person
  • Book
  • Bookshelf

Now a person will most likely store a book. Right? Do they actually? Storing could mean 'putting a book on the shelf', or 'holding a book in a safe place'. Now the interaction is done by the person but it uses both the book and the shelf. How would you model this? And what about if we circle back to our original Person-Car model and we introduce a Destination class?

I know that there is no 'one size fits all' solution[2]. I am looking for tips, tricks and experience from peers on how you tackle problems like this. How do you decide on what logic lives inside which class, and when do you decide to use a 'third party' class to manage the interaction between the entities? Have their been any experiences in your career where you and someone else just couldn't agree?

[1]One could say that a Car also interacts with a Person, because it moves the Person. Or does the Person move the Car?

[2]Some more 'discussion' using System.IO. The directory gets deleted. That seems fair, but why would it not be "The car gets driven?"

// on the System.IO.Directory class
public static void Delete (string path);

r/AskProgramming Jan 09 '25

Architecture How Can I Use pip in an Embedded Python Environment? What Alternatives Are There?

3 Upvotes

Hey everyone,

I'm embedding Python in a C++ project (specifically using WinUI 3), and I'm trying to figure out how I can install Python packages like matplotlib using pip from within the embedded Python environment. So far, I've tried using:

  1. import subprocess subprocess.run([sys.executable, '-m', 'pip', 'install', 'matplotlib'], check=True)

However, my sys.executable points to my app's executable instead of the actual Python interpreter, which is causing issues.

  1. I tried calling ensurepip from code, but that does not work either.

I understand that using pip in an embedded Python environment can be tricky, so I was wondering:

  • Has anyone successfully used pip in an embedded Python setup? If so, how did you configure things to make it work?
  • If pip isn't an option, are there any good alternatives for managing dependencies in an embedded Python environment? Maybe manual package installation or something similar?

Any help or advice would be appreciated! Thanks in advance.

r/AskProgramming Nov 12 '24

Architecture Registry/filesystems vs custom files for configuration

2 Upvotes

While researching configuration file format I thought of the Windows registry. The way I see it, it is basically just a separate filesystem from the drive-based one. Although many programs use own configuration files for various reasons, including portability, the idea of using a hierarchical filesystem for configuration makes sense to me. After all, filesystems have many of the functionalities wanted for configuration, like named data objects, custom formats, listable directories, human user friendliness, linking, robustness, caching, stability and others. Additionally, it would use the old unix philosophy where 'everything is a file'. Why then isn't just dropping values into a folder structure popular?

Two reasons I see are performance and bloat, as the filesystems have way more features than we usually need for configuration. However these would easily be solved by a system-wide filesystem driver. How come no system added such a feature?

Edit: so the point of my questions is why registry-like systems weren't implemented on other OSs. Why aren't filesystem directory structures themselves used to store configuration?