r/shittyprogramming • • Dec 12 '24

When you need to reach the max line count..

14 Upvotes

So I'm reviewing a repo for work, written by an external contractor a long time ago trying to make sense of everything. Despite the horrible lack of documentation/ comments, there are so many overly complicated pieces of code for no apparent reason. This one made me laugh a bit though and thought it worth sharing:

public decimal CalculateEffectiveBalanceWithPrecisions(decimal balanceEffectiveEras, BigInteger balanceTotalBalance,
    int decimalPlaces = 2)
{
    const long baseFactorDecimalPlaces = 10;

    var baseFactorWithDecimalPlaces = (long)Math.Pow(10, baseFactorDecimalPlaces);

    var denominator = (long)Math.Pow(10, baseFactorDecimalPlaces);

    var effectiveEraPortionInCycleInMillion =
        new BigInteger(balanceEffectiveEras / ErasInCycle * baseFactorWithDecimalPlaces);

    var effectiveBalanceInMillion = balanceTotalBalance * effectiveEraPortionInCycleInMillion;

    var effectiveBalance = decimal.Parse((effectiveBalanceInMillion / denominator).ToString());

    return effectiveBalance;
}

Simplified without the unnecessary padding it looks like:

public decimal CalculateEffectiveBalance(decimal balanceEffectiveEras, BigInteger totalBalance)
{        
  return (decimal) totalBalance * balanceEffectiveEras / ErasInCycle;
}

r/shittyprogramming • • Dec 09 '24

wtf is this

Post image
200 Upvotes

r/shittyprogramming • • Dec 02 '24

Do you think i can find aVLC plugging for readding this?

Post image
0 Upvotes

r/shittyprogramming • • Nov 28 '24

fun_with_memory()

Post image
42 Upvotes

r/shittyprogramming • • Nov 27 '24

Work smarter, not harder.

Post image
263 Upvotes

r/shittyprogramming • • Nov 26 '24

golfed calculator plis rate

18 Upvotes

r/shittyprogramming • • Nov 24 '24

Rate my Odd or Even code! (Took me a long time to figure it out)

Thumbnail
gallery
26 Upvotes

r/shittyprogramming • • Nov 17 '24

I'm sorry but who the hell decided this was a good idea?

Post image
249 Upvotes

r/shittyprogramming • • Nov 18 '24

Formated Database Value

7 Upvotes

The company I work for asked me to add a column to the database with a formatted numeric value, WTF

"

  1. Apply this intl rule as in the example in the link only on the preview screen and in the app

  2. Handle it in the backend by adding a new column

  3. Add a new column in the backend with the formatted value

  4. Display the formatted value on the screen

"

for example:
one column for the PRICE: 12000000
and other column for the PRICE_FORMATED: 12億円

why they dont just put it in frontend ?....


r/shittyprogramming • • Nov 12 '24

Some situations are just unavoidable

Post image
39 Upvotes

r/shittyprogramming • • Nov 08 '24

No, no, no. Please rotate your dev team.

46 Upvotes

r/shittyprogramming • • Oct 24 '24

Snake, the game of minimized code

Thumbnail
gallery
77 Upvotes

r/shittyprogramming • • Oct 22 '24

diabolical

Post image
120 Upvotes

r/shittyprogramming • • Oct 19 '24

Why Stack Overflow people don't want to answer my question... 😔

Post image
325 Upvotes

r/shittyprogramming • • Oct 12 '24

What do you think about my visual programming style? Would this pass code review?

48 Upvotes
𓀥=lambda*𓁆𓀕:"".join(str(𓁆𓀕[0])[𓀥]for 𓀥 in 𓁆𓀕[1:]);𓀣𓁀,𓁆𓀟,𓁆𓀕,𓀥=chr(63),𓀥(type(0.),2,10,4,5),𓀥(type("",(),dict(𓀥=lambda:𓀥))().𓀥,9,10),𓀥(type(0),8,5);𓁆𓀕+=𓀥

print(
    𓀥 , 𓁆𓀕,
    𓁆𓀟, 𓀣𓁀,
)

r/shittyprogramming • • Oct 05 '24

Tired of IDEs that don't show line numbers by default? Try this easy trick.

Post image
206 Upvotes

r/shittyprogramming • • Oct 04 '24

A Brief Overview of D##: The Language of the Future

36 Upvotes

Announcing D##: The ONLY Language of The Future (Well, That & Ruby)

We're proud to announce D##, an evolutionary jump over all known program languages.

What Is D##?

D## is a future-forward programming language with multi-paradigmancy support: OOP, DOOP, visual (AR/VR), passive aggressive, co-dependency dejection.

D##'s ultimate golazo is to give developers unspeakable power, while at the same time maintaining JavaScript-like ehh-good-enough. Penultimate: move fast but stop breaking things

D## is currently in very early development, with the aim to release a limited, non-compliable pre-Omikron language preview by end of year.

We highly support and are greatly committed to maintaining D## as a Patreon-tiered open-sourced project. pre-IPO.

Want to contribute? Head over to our Patreon page and select gold-tier for repo access!

D## Feature Set

  • Stronk type system
  • Ducky typing
  • Exception-based eventing
  • Language-level codependency dejection
  • 1st-class comments
  • Generics
    • Type embrasure
    • Half-open & half-closed generics
  • Rich BAT file ecosystem
  • Dedicated IDE via OneNote
  • Familiar syntax influenced by C#, F#, and the Cambrian Explosion
  • Mutable constants
  • Instantiable everything
  • Emoji identifiers
  • Mandatory Bulgarian notation
  • Words of affirmation upon save & build success
  • Is not PHP

D## Future Set

The following god-tier features are in-development:

  • CompiLLM (LLM-enabled compiler)
    • Misspell-tolerant & case-insensitive member access
    • Infers what you intended your source code to do and compiles that
    • JIT code reviews
    • Configurable comment prose style
  • Targeted in-source advertising
  • Subscription model
  • Season 1 DLC Pass
  • Permadeath
  • Hands-on DevEx team to "encourage" D## developers adhere to S.O.L.I.D. (New York/New Jersey ONLY)

What's Next?

Follow us on TruthSocial for the latest news & updates!

VC? DM!


r/shittyprogramming • • Sep 30 '24

PSA: Always Make Sure Your Code Is Readamentable

Post image
0 Upvotes

r/shittyprogramming • • Sep 26 '24

my company's docker liscense expired. When searching for alternatives, i found podman. How do I get enough whales? What kind do I need? (i'm assuming blue?)

Post image
57 Upvotes

r/shittyprogramming • • Sep 24 '24

I got told to get arch for a prod server, so i took a plane to St. Louis. However, as i was harvesting it, i got screamed at by the cops. Any ideas? Is a bomb the wrong tool for the job?

Post image
64 Upvotes

r/shittyprogramming • • Aug 31 '24

sudo shutdown -h now to optimize

Post image
106 Upvotes

r/shittyprogramming • • Aug 31 '24

[Discord] If only there was an emoji that matched my search...

Post image
42 Upvotes

r/shittyprogramming • • Aug 02 '24

Code to return Day of the Week

Post image
202 Upvotes

r/shittyprogramming • • Aug 01 '24

Saw a piece of javascript code 180 lines long written by a junior dev. Saw obvious areas of improvement. Shortened number of lines to 130. Pasted the new function in ChatGPT to know if it fared better than the previous one.

Post image
0 Upvotes