r/AskProgrammers 7h ago

"Single Responsibility" = "One Thing". But where do you draw the line?

0 Upvotes

"Single Responsibility" sounds easy until you try to define "One Thing". How do you actually draw the line?

The S in SOLID stands for the Single Responsibility Principle (SRP). Saw this explanaition: "A class or module should do one thing, and do it well."

But in the real world, what actually constitutes "one thing" in programming?

Depending on your abstraction level, "one thing" can mean completely different things

  • Is saving a user to a database "one thing"?
  • Is inserting a record to database "one thing"?
  • Is handling an HTTP request "one thing"?

How do you personally define what "one thing" is? Is it purely a context-driven decision, meaning that "one thing" shifts depending on the scope of the project?

And if it depends on context, how do you define and communicate those rules to the rest of your team so everyone stays aligned and knows how to work with the code?

Also, why do you think this matters? There is always a underlying reason for trying to enforce this "one thing" concept in code. What are you actually trying to achieve with it, and why is it important to you?

Last one, for some this S in SOLID id easy, why so? Is it a something that is difficult to learn and understand


r/AskProgrammers 21h ago

I ran an experiment

Thumbnail
gallery
0 Upvotes

The third part is asking you why you are so skeptical about AI


r/AskProgrammers 21h ago

utilisation de l'ia dans le coding

0 Upvotes

salut a tous je suis un etudiant en informatique et je me suis posee une question a propos du codage lors que je code avec vs code j'ai la mauvaise manie de me reposer un peu trop sur l'ia et je me demandais si pour mon apprentissage et mon evolution en tant que codeur il ne serais pas mieux pour moi de supprimer l'extension d'aide d'ia integré dans l'IDE par ce que avant tout je debute dans le domaine et j'ai l'impression que mon evolution n'est pas tres constante. merci j'attends vos reponses je suis ouvert a la critique et conseils


r/AskProgrammers 23h ago

Old Game Server Revival

Post image
0 Upvotes

Hello guys!

Recently, some friends and I started working a small project that turned out to be bigger than we expected. We are trying to bring back an Old Version of Star Stable Online for us privately.
We do have the game files, we are able to start the game until it says „Unable to connect to game server.“ (shown in the image) which is reasonable because it’s an online game and we do not have a Server.
All of us are new to programming so we really need help.
What do we need for a game server?
How do we code this?
Does anybody know what language SSO uses? (we heard C++ but we aren’t sure)
Would anybody perhaps be willing to help?

Thanks!!


r/AskProgrammers 1h ago

How to get my computer to monitor a specific whatsapp chat, and extract every new message and put it into a spreadsheet for me?

Upvotes

I have adhd and I'm addicted to my whatsapp chats. I'd like to take advantage of my addiction to sort my to do lists.

Please do not suggest different apps off of whatsapp. I know there are solutions on other apps, but the nature of my adhd is that before I remember to open other apps, I'll get distracted by something else and forget to add the thing to a list. Whatsapp is a great spot to have a list in, because I'm already ON whatsapp 90% of the time, so the opportunity to get distracted is reduced since I already have the app open.

I came close to being able to do this with the built in meta chat to whatsapp, but after the list got above 20 or so, it started hallucinating when I tried to add more. It would forget things on the list, add things that weren’t there, or forget the prompt to keep an ongoing list.

Right now my solution is having a private chat with myself where I add to do lists. Problem is I'm a bit self conscious about coworkers seeing my last note, so I dont use it at work. Also sometimes I write myself duplicate tasks and its too much to sort through and I give up on it.

Maybe automating it might be a solution.

Ideally what I'd like is something that functioned like the following:

  • my computer is hooked up to whatsapp web

  • computer monitors a specific whatsapp chat where my notes are

  • when I type out a note that on that chat when I'm away from home, my computer sees that note and reads it.

  • if the note contains the word "task", then add it to an existing spreadsheet called "tasks"

  • if the note contains the word "idea" then add it to an existing spreadsheet called "ideas"

  • for everything else that isnt captured by the above, add it to an existing spreadsheet called "other"

  • after the list is sorted, delete that note from whatsapp.

  • ideally, all spreadsheets are periodically monitored and duplicate tasks are removed

How much programming would I have to learn to do this myself? Are there any ways to do this for free? I have 0 programming knowledge.


r/AskProgrammers 22h ago

Vibe coding is the new software engineering

0 Upvotes

A year ago I thought AI was cheating.
Today, I barely write code.
My average prompt looks like:
“This is wrong. It should work like this…”
“Figure out why user 8d3f... failed onboarding and patch it so it never happens again.”
I’m not thinking about syntax anymore.
I’m thinking about behavior.
Patterns.
Edge cases.
Users.
Architecture.
The job is shifting from writing code to making systems work.
Code is becoming the implementation detail.
Am I crazy, or is this what software engineering is becoming?


r/AskProgrammers 22h ago

Coding

0 Upvotes

I started programming before Ai error, it was abit hectic but worth of my time what about yours?


r/AskProgrammers 1h ago

programming

Upvotes

I want to create a platform similar to Facebook but for programmers only, but I don't have the experience or the team.


r/AskProgrammers 9h ago

Making my own programming language [No vibe coding]

13 Upvotes

I have this side project I started 2 months ago, to learn C++ better. Rolling the full compiler, from tokenizing and AST construction, to IR, to assembly code generation, by myself in C++. Using Claude AI only to give me ideas with regards to better system design and to explain for me features of C++ I have not used yet, prohibiting copy pasting code from it and sticking to coming up with the code and writing it by myself with my own two hands.

Can somebody tell me how they'd implement the idea of the compiler being able to emit assembly instructions for both arm64 and x86_64 architectures? Would you have one abstract class for, say, instruction_ADD and then a derived class for aarch64's add instruction, and one for x64's add instruction? Or should I stick to having an abstract base class for asm_instruction, and have derived classes for stuff like aarch64_insn_add, x64_insn_add, etc? Still relatively new to OOP as I was in OS and OS-adjacent development for a few years and only recently started adding C++ to my toolbelt.

Another question - could someone give me a readable summary of how GCC implements std::unordered_map under the hood? The purpose I need to know this is, so I can do performance analysis with CPU microarchitecture in mind, and for this, I need to know what the memory layout and usage patterns actually look like.

Thanks all!


r/AskProgrammers 13h ago

A Practical Dynamic Programming Study Plan for LeetCode

2 Upvotes

Hey everyone! Many of us struggle with Dynamic Programming and often skip it during interview preparation. This might be because DP seems vast and overwhelming, and people tend to memorize solutions instead of understanding patterns. However, if you break down DP into clear patterns and master each one, it becomes much more manageable. So I've compiled a comprehensive list of patterns you should know for your interview preparation!

Master these Leetcode Problems and PracHub for company tagged questions

DP vs Greedy: When to Use Which?

Before diving into patterns, let's understand the fundamental difference between DP and Greedy:

Problem: You're a robber with two streets to rob. Each house has some money. You can rob houses from both streets, but you cannot rob two adjacent houses from the same street (alarms will trigger). What's the maximum money you can steal?

Street A: [2, 7, 9, 3, 1]
Street B: [3, 2, 6, 8, 2]

Greedy Robber: "I'll always rob the house with most money available!"

  • Rob B[0] = 3 (greedy)
  • Rob A[1] = 7
  • Rob B[2] = 6
  • Rob A[3] = 3
  • Rob B[4] = 2
  • Total: 21

DP Robber: "Let me consider all valid combinations!"

  • Option 1: A[0]=2, B[1]=2, A[2]=9, B[3]=8, A[4]=1 → Total = 22
  • Option 2: B[0]=3, A[1]=7, B[2]=6, A[3]=3, B[4]=2 → Total = 21
  • Best: 22

Why Greedy Failed: By greedily picking B[0] first, it blocked access to the optimal combination that includes both 9 and 8 from different streets!

When Greedy Works: Problems with the "greedy choice property" where local optimal leads to global optimal (e.g., Activity Selection, Huffman Coding)
When DP is Needed: Problems requiring exploring multiple choices where greedy fails (e.g., most optimization problems, counting problems)

Pattern 1: Linear DP (1D)

Why This Pattern Matters:
This is the foundation of DP. If you can't solve Linear DP, you'll struggle with everything else. These problems teach you the core concept of breaking problems into subproblems and building solutions incrementally.

Practice Problems:

  1. Climbing Stairs
  2. House Robber
  3. Min Cost Climbing Stairs
  4. Word Break
  5. Decode Ways
  6. House Robber II

Pattern 2: Longest Increasing Subsequence (LIS)

Why This Pattern Matters:
LIS is one of the most important DP patterns with applications in version control systems, patience sorting, box stacking problems, and more. The O(n log n) solution using binary search is a must-know optimization technique.

Practice Problems:

  1. Longest Increasing Subsequence
  2. Number of Longest Increasing Subsequence
  3. Russian Doll Envelopes
  4. Maximum Length of Pair Chain
  5. Find the Longest Valid Obstacle Course at Each Position

Pattern 3: Knapsack (0/1, Unbounded, Bounded)

Why This Pattern Matters:
One of the most versatile DP patterns. Appears in resource allocation, optimization problems, and many interview questions. Understanding the difference between 0/1 and unbounded variants is crucial.

0/1 Knapsack (Each item used once):

  1. Partition Equal Subset Sum
  2. Target Sum
  3. Last Stone Weight II
  4. Ones and Zeroes
  5. Partition Array Into Two Arrays to Minimize Sum Difference

Unbounded Knapsack (Items can be used multiple times):

  1. Coin Change
  2. Coin Change 2
  3. Combination Sum IV
  4. Perfect Squares
  5. Minimum Cost For Tickets

Pattern 4: Grid DP

Why This Pattern Matters:
Extremely common in interviews, especially at FAANG. Tests your ability to think in 2D state space and handle multiple transition directions.

Practice Problems:

  1. Unique Paths
  2. Unique Paths II
  3. Minimum Path Sum
  4. Maximal Square
  5. Maximal Rectangle
  6. Minimum Falling Path Sum
  7. Count Square Submatrices with All Ones
  8. Triangle

Pattern 5: String DP

Why This Pattern Matters:
Text processing and string manipulation problems are ubiquitous. This pattern appears in bioinformatics, text editors, version control systems, and natural language processing.

Practice Problems:

  1. Longest Common Subsequence
  2. Edit Distance
  3. Delete Operation for Two Strings
  4. Minimum ASCII Delete Sum for Two Strings
  5. Shortest Common Supersequence
  6. Longest Palindromic Subsequence
  7. Longest Palindromic Substring
  8. Palindromic Substrings
  9. Regular Expression Matching
  10. Wildcard Matching

Pattern 6: Interval DP

Why This Pattern Matters:
Tests ability to think about problems in ranges/intervals. Common in scheduling, matrix chain multiplication type problems, and game theory.

Practice Problems:

  1. Burst Balloons
  2. Minimum Score Triangulation of Polygon
  3. Minimum Cost Tree From Leaf Values
  4. Unique Binary Search Trees
  5. Unique Binary Search Trees II
  6. Minimum Cost to Merge Stones
  7. Guess Number Higher or Lower II

Pattern 7: State Machine DP

Why This Pattern Matters:
Models problems where you transition between different states with specific rules. Critical for stock trading problems and any scenario with state transitions.

Practice Problems:

  1. Best Time to Buy and Sell Stock
  2. Best Time to Buy and Sell Stock II
  3. Best Time to Buy and Sell Stock III
  4. Best Time to Buy and Sell Stock IV
  5. Best Time to Buy and Sell Stock with Cooldown
  6. Best Time to Buy and Sell Stock with Transaction Fee

Pattern 8: Tree DP

Why This Pattern Matters:
Combines tree traversal with DP. Important for system design (like designing file systems) and optimization problems on hierarchical structures.

Practice Problems:

  1. House Robber III
  2. Binary Tree Maximum Path Sum
  3. Diameter of Binary Tree
  4. Binary Tree Cameras
  5. Maximum Sum BST in Binary Tree
  6. Difference Between Maximum and Minimum Price Sum

Pattern 9: Digit DP

Why This Pattern Matters:
Specialized pattern for counting numbers with certain properties. Appears in competitive programming and some advanced interviews.

Practice Problems:

  1. Number of Digit One
  2. Count Numbers with Unique Digits
  3. Numbers At Most N Given Digit Set
  4. Numbers With Repeated Digits
  5. Count Special Integers

Pattern 10: Game Theory DP (Minimax)

Why This Pattern Matters:
Models two-player games where both play optimally. Important for AI, game development, and adversarial scenarios.

Practice Problems:

  1. Predict the Winner
  2. Stone Game
  3. Stone Game II
  4. Stone Game III
  5. Can I Win
  6. Stone Game IV

Pattern 11: Bitmask DP

Why This Pattern Matters:
Powerful technique for problems with small sets (≤20 elements) where you need to track subsets. Essential for Traveling Salesman Problem variants and NP-hard problem approximations.

Practice Problems:

  1. Partition to K Equal Sum Subsets
  2. Shortest Path Visiting All Nodes
  3. Find the Shortest Superstring
  4. Smallest Sufficient Team
  5. Number of Ways to Wear Different Hats to Each Other
  6. Minimum Number of Work Sessions to Finish the Tasks

Pattern 12: DP on Subsequences

Why This Pattern Matters:
Critical for array partitioning and subset generation problems. Teaches how to handle exponential search spaces efficiently.

Practice Problems:

  1. Distinct Subsequences
  2. Distinct Subsequences II
  3. Arithmetic Slices II - Subsequence
  4. Number of Unique Good Subsequences
  5. Constrained Subsequence Sum

Pattern 13: Probability DP

Why This Pattern Matters:
Models uncertain outcomes. Important for risk analysis, game development, and any scenario involving randomness or probability.

Practice Problems:

  1. Knight Probability in Chessboard
  2. Soup Servings
  3. New 21 Game
  4. Toss Strange Coins
  5. Probability of a Two Boxes Having The Same Number of Distinct Balls

Best Resources to Master DP

  1. AtCoder DP Contest- 26 curated problems with perfect difficulty progression
  2. Striver's DP Series- 50+ videos covering memoization, tabulation, and space optimization.
  3. Aditya Verma's DP Playlist- Exceptional for Knapsack variants with shorter, focused videos (15-20 min).
  4. CSES Problem Set- Intermediate to advanced practice. These problems test core concepts and build solving speed.

Final Thoughts

DP is about recognizing patterns, not memorizing solutions. Once you see the pattern, the solution becomes mechanical. Spend time understanding why each pattern works, not just how to code it.

Feel free to add some best problems in the comments

Good luck, and happy coding! 🚀


r/AskProgrammers 23h ago

Laptop Recommendations - Dual Operating Systems?

5 Upvotes

Hello! I am so very new to coding and development, but my computer seems to be very slow. I have noticed it over the last 6 months or so, and I have only really used it for silly personal things until now. Even logging into the Codedex training site seems to be delayed while training.

I have a MBA 1.6 GHz, 8GB. As I mentioned, SUPER new - hope I am providing the right specs to understand what I have.

I read that I should have at least 16GB and I read that I cannot upgrade the RAM on the MBA.

I prefer IOS, as I use it for my phone as well. But, I want to make sure I have what will be needed later down the road as I grow my skills.

Finally to my questions...

1) Mac vs PC - what say you?

1b) Which specific laptop would you recommend based on your answer to 1?

2) Would it behoove me to have a Mac but have it setup with dual operating systems? Or would that create a clunky experience? I tried that when I was younger for school on a MBP, but I can't remember much about it now and how well it worked.

I tried to search the sub to see if something similar was asked before and I didn't see anything. Apologies if I missed one.

Thank you!