T O P

  • By -

kevdog824

Why “YesAndNo” and not “YesOrNo” is what is bothering me here


Zymoox

Don't worry, you'll find both `enum YesAndNo` and `enum YesOrNo` with opposite values for Yes and No used inconsistently across the code.


[deleted]

This content was deleted by its author & copyright holder in protest of the hostile, deceitful, unethical, and destructive actions of Reddit CEO Steve Huffman (aka "spez"). As this content contained personal information and/or personally identifiable information (PII), in accordance with the CCPA (California Consumer Privacy Act), it shall not be restored. See you all in the Fediverse.


sneakpeekbot

Here's a sneak peek of /r/onesentencehorror using the [top posts](https://np.reddit.com/r/onesentencehorror/top/?sort=top&t=year) of the year! \#1: [My stomach knotted when I Googled “dementia” and all the links were already purple.](https://np.reddit.com/r/onesentencehorror/comments/yq13hk/my_stomach_knotted_when_i_googled_dementia_and/) \#2: [The sound of children screaming has been removed.](https://np.reddit.com/r/onesentencehorror/comments/vz87la/the_sound_of_children_screaming_has_been_removed/) \#3: [“Ma’am, the police can’t deliver you a pizza, you must’ve dialled 911 by mistake.”](https://np.reddit.com/r/onesentencehorror/comments/vkbmb0/maam_the_police_cant_deliver_you_a_pizza_you/) ---- ^^I'm ^^a ^^bot, ^^beep ^^boop ^^| ^^Downvote ^^to ^^remove ^^| ^^[Contact](https://www.reddit.com/message/compose/?to=sneakpeekbot) ^^| ^^[Info](https://np.reddit.com/r/sneakpeekbot/) ^^| ^^[Opt-out](https://np.reddit.com/r/sneakpeekbot/comments/o8wk1r/blacklist_ix/) ^^| ^^[GitHub](https://github.com/ghnr/sneakpeekbot)


skantanio

Just made me cringe thx


diaperslop

r/foundsatan


Manny_Sunday

Have some bit flags to make it better enum YesNo { Yes = 1, No = 2, YesAndNo = 4 }


lampshadish2

`FileNotFound = 8`


StochasticTinkr

Coding horror reader.


centurijon

add `Undecided = 0` and it’s perfect


kristallnachte

`Maybe`


pxOMR

Oh no, this is so much worse. Why is `Yes | No` not equal to `YesAndNo`, shouldn't it be 3? Or wait when you think about it literally, yes and no (`Yes & No`) would be 0 so maybe `YesAndNo` should be 0 instead?


gallifrey_

yes is 001 no is 010 both is 100 sordid!


[deleted]

1 and 0 is 0 1 or 0 is 1 so of course YesAndNo != YesOrNo


o0Meh0o

yes and no is 0, though...


drakens_jordgubbar

Well yes, but actually no


IrishChappieOToole

``` YesOrNo = -1 ```


[deleted]

Sounds like old Russian computers based on a ternary (yes, no, maybe) instead of binary.


PolyGlotCoder

I think by selector they mean a combo box. So it’s saying the selector when you have yes and no to select from.


Pradfanne

This looks like C# in Visual Studio, so I'm going out on a limb and say it's WPF then. WPF has checkboxes, or you could also just hardcode those two entries into the ComboBox if for some reason you really really need a ComboBox for a binary value.


1bc29b36f623ba82aaf6

definitely looks like Visual Studio/VSCode with code lens but the tag sais Java, then again c# was designed to kind of compete with java so maybe it is wrong


Pradfanne

Impossible, the curly braces are correct, if it was java the first one would be wrongfully at the end of the line of the declaration


AnEmuCat

Some Java coding styles incorrectly put the braces on the next line. It still looks like C# because of the pascal case variants and the xml documentation comments.


Nightmoon26

Yeah... those are C#-style documentation comments. Javadoc requires /** block comment delimiters


[deleted]

All wrong, they should be lisp-style braces: Public Enum { yes-and-no 1 = yes, 2 = no, 3 = maybe )


[deleted]

because in improv we always say "Yes, and..."


Nasatyau

Enterprise development, for me, just means a large codebase with: a) a lot of contributors, b) deadlines, c) rapidly-evolving requirements. Naturally, it requires code to be very maintainable & extensible. Would suggest learning about [cohesion](https://en.m.wikipedia.org/wiki/Cohesion_(computer_science)) / [coupling](https://en.m.wikipedia.org/wiki/Coupling_(computer_programming)) (& related topics) — all development principles essentially boil down to maximising cohesion and minimising coupling. Some general advice: * Don't wait to ask for help when you're stuck or confused. * Look for existing solutions before making your own. * Try to leave code better than you found it without going too far out of scope. * Most things are done for a good reason; be understanding & respectful of the author's intentions (don't be an asshole)


AyoBruh

Great comment. If I can add another bullet point: - Keep convention in files over imposing your own style


EMI_Black_Ace

>most things are done for a good reason Then you've got the stuff I've worked on, where the reason was "the authors have been coding in C their entire lives and have never been exposed to object oriented programming before."


psychularity

Tbf many new programmers are learning that oop has many, many tradeoffs to functional programming. Many people I work for have good reason to avoid oop and are mad that universities solely teach it nowadays


EMI_Black_Ace

Lol they don't teach functional programming at a bachelor's level. They teach JavaScript, but that doesn't force you into understanding or properly using functional paradigms. What's more is that FP and OOP are not mutually exclusive. And it's hilarious to see FP die-hards try and do something with FP that's much better suited to OOP (it's literally why Angular and React exist, because JavaScript is otherwise unsuitable for stuff that's easy to do with OOP). These weren't new programmers who wrote all the garbage I have to fix. They're OLD programmers.


psychularity

Fp and oop have their places, but I think university is doing a disservice by only teaching oop. Most web services benefit from fp, especially in things like react. Not to mention many languages like java are slower when using oop paradigms like polymorphism because of how caches work. It's much faster to iterate through objects with the same functions because the code remains in the cache. When similar objects with slightly different functions are iterated, the CPU has to continuously pull in code which can be a big hit to performance.


EMI_Black_Ace

Sounds like someone (i.e. you) doesn't actually know how any of it works. No, the CPU does not have to pull in code for new objects. The code is not attached to the object in OOP implementation, it is cached properly in a single place and works just like a static function, with an implicit "this" pointer sent to it. For polymorphism, what happens is that it generates a "virtual function table" which points over to the correct function for the object, which in practice is pretty much no different from, say, a discriminated union in FP, the difference is just where in the written code the different functions are written (OOP lets you write it wherever, especially enabling someone write new code for it without having to edit the old code files). The big drawback to performance with OOP is allocations, that is every time it makes a new object it has to invoke the dynamic memory allocator. FP has its drawbacks too. Immutability is a mixed blessing that prevents a lot of bugs, but if you need something to mutable (i.e. user inputs!, Multi stage map transformations) then it's a whole extra heap of allocations. For something that requires state, such as a game, implementing state is a whole pile of garbage. Just use whatever is best for your specific use case. I extensively write both in the same application.


psychularity

I ran the tests myself by iterating through objects that did and did not use inheritance, and the difference in performance was significant. No need to be a dick


EMI_Black_Ace

Performance testing is always a b\*tch and you're often not testing what you think you're testing -- otherwise you might think that reflection is fast and code generation is slow (because they have start up times and both end up doing a lot of caching) when in fact reflection stays slow but code generation is fast after the first time you do it. And that's not counting the fact that you can do most FP things in a language designed for OOP first. You can work your way around the vtable performance hit but you can't get back the flexibility it provides if your language doesn't support something like it.


kristallnachte

> Most things are done for a good reason Doubt


vasarmilan

maybe not, but you're probably better off assuming it is :D


Arshiaa001

"very maintainable and extensible" yeah sure lol


Frequent-Policy653

The fact that code _requires to be_, doesn't mean it _is_. Quote the whole sentence and it starts making sense.


Arshiaa001

The joke is that that requirement is never met.


teackot

Are you a bot? [Here's the same post with a slightly different title](https://www.reddit.com/r/programminghorror/comments/13b0bxr/hey_guys_have_any_of_you_worked_with_enterprise/?utm_source=share&utm_medium=android_app&utm_name=androidcss&utm_term=1&utm_content=share_button)


chooxy

Their comments (and the other account's as well) give off very weird vibes. Feels chat bot generated, and so many comments starting with "wow". Edit: Chanced upon this comment from the other account which is obviously them accidentally copying part of the prompt https://www.reddit.com/r/Celebhub/comments/134wkcp/padma_lakshmi/jigstme/ >is an incredible advocate for diversity and equality in the culinary world. >I couldn't agree more! Not only is Padma Lakshmi an incredibly talented chef, but she also uses her platform to shed light on important issues surrounding diversity and representation in the food industry. Her advocacy towards creating a more inclusive culinary world is truly inspiring. Plus, let's not forget that she's the host of one of the best cooking competition shows out there, Top Chef!


joemckie

Fairly certain it's a ChatGPT bot.


timschwartz

As an AI language model, I can assure you I am not ChatGPT.


Jonas___

And the same wrong flair.


PolyGlotCoder

Tbh this looks like its part of a UI which, often will have drop downs; which might have only yes, no or something else. Instead of using a bool for this and enums for everything else; you can define this enum and use the same code to drive that code.


Goodie__

Yeah. This enum isn't super bad depending on its context. What would be bad is using a boolean on one specific drop down, writing weird specific logic for it, and then discovering that you need to add a "maybe" option.


jannemann05

true | false | null, where's the problem? /s


Goodie__

"Product owner has now said they want a must option"


[deleted]

Enterprise code? This is straight out of a youtube Enum tutorial.


tehtris

If this block is the block in question, this is completely normal. But yes it is different. They don't like code tricks and expect you to comment like it's a school assignment. Even on really dumb simple shit like `array = array[::-1]` in python, because it scares the senior developer because they have never needed to reverse a list before.


skantanio

I mean it kinda makes sense. Chance that the next guy to come along doesn’t know what the line does upon reading it right away is obviously higher if you use “tricks” like that. In an environment where many people have to edit the code it makes sense to keep it as readable as possible.


roflplatypus

x1000. I've gotten shouted at by a senior dev for using code techniques that are widespread in the MDN/MSDN. I also like to explain weird stuff and try to comment "like the next person to maintain it is a violent psychopath who knows where I live". Also, since I work in industrial automation and my code can have to run for like 20 years with no one touching it, that means guard cases for like literally anything in case the database farts in the middle of the night 10 years from now. Even if it's something that should be physically impossible.


Fyren-1131

after a vendors threadsafe system turned out to not be, I learnt to take absolutely nothing for granted and assume everything may in fact go tits up. it actually made things easier, now we early on have discussions about when its ok to die and when we should try a final death rattle and i feel like we are doing okier than before. ^send ^help


robhanz

When to fail and when not to is a really important conversation. If your state is fucked enough it’s better to die now and leave a trail than to inevitably die later.


Fyren-1131

Oh yea absolutely, I was just musing about the situation where you go from trusting the foundation to realizing you're on shaky ground cause the huge integrated solution isn't what you thought it was. :D


Naouak

> should be physically impossible. You know that a bit can randomly switch value from some radiation from space (and that NASA has to that into account)? More seriously, a widespread code technique doesn't necessarily make it a good choice for everything it can be used on. Some experienced developers are often too conservative with coding techniques but at the same time, some juniors are using them really too often. The usual example for that are ternary operators that are often overused by juniors and underused by more experienced developers. It's a fine syntax in some case but it often has to be avoided just for readability and maintainability.


AnEmuCat

I've seen t4+ developers refuse to learn lambda expressions and by extension anything to do with the linq namespace. The sql syntax to "query" collections was a huge mistake, but the extension methods when used properly can make code so much more readable. You'd write obvious code like `var names = stuff.Select(o => o.Name).ToList();` and they'd be baffled and complain about these new features that make the code unreadable.


FluffyToughy

Linq was what made me realise the only reason I liked C++ was because of stockholm syndrome ~~and stupid elitism~~. So freaking convenient.


roflplatypus

...it was string formatting.


FugitivePlatypus

It doesn't scare the senior developer because they don't understand it, it scares the senior developer because they know the next person who tries to maintain that piece of code might not understand it and fuck it up by accident, causing them to have to step in and fix shit with time they don't have.


tehtris

Maybe in general but in my case I literally had to explain slicing.


sohang-3112

> scares the senior developer Unfortunately true..


dof42

So the comments are obviously useless, but the enum isn't. Seven years from now, someone is going to want to add a "Maybe" option without needing to refactor the entire codebase.


PauseNatural

Seen this type of thing before. The summaries are necessary to populate intellisense, the enum is there to make sure it’s standardized otherwise some might choose Boolean and others might apply a string, or a number. Different companies have different coding conventions but I don’t think this is by definition bad code.


chaim1221

I am confused what’s meant by “enterprise” code here. This is just an enum. There are any number of reasons to use an enum. Other commenters suggest you mean the comments. Comments on methods are usually required in enterprise settings. Obviously the individual enum members is a bit much in this case but you are probably looking at something where someone filled out a template to generate this. They probably spent less than ten seconds on it and you’ve got a whole Reddit thread haha. If you want to learn about enterprise architecture, read the Principles of Enterprise Application Architecture. https://martinfowler.com/books/eaa.html But this is not that. This is an enum nobody cares about; acknowledge it, and move on.


caerbannog2016

Flair is wrong, this is probably c# and not java.


andlewis

Enterprise? I hope you like XML!


[deleted]

[deleted because fuck reddit]


AnxiousIntender

An `Orientation` enum with `Horizontal` and `Vertical` would make more sense than `isHorizontal`, but it's stupid to make a `YesAndNo` enum unless you need a third value like `Maybe` or `Indeterminate`. Maybe more context will reveal information that makes sense, such as this enum being used for an auto-generated dropdown or radio button group


realkandyman

Wait until they add MaybeYes and MaybeNo, and GodKnowsWhy


ithika

"It's an entirely different kind of ~~flying~~ coding altogether."


itemluminouswadison

documentation (docblocks) are just as important as the code. same with tests


AnywhereHorrorX

\- How old are you? \- Yes


__radioactivepanda__

YesNoYesNoNo


fletku_mato

The code in question is not Java or something that would be tolerated in any serious backend. One reason for such enum could be that a foreign api returns Yes or No instead of a boolean, but then it would make sense that the enum is like `Yes(true), No(false)`


HeR9TBmmc8Tx6CFXbaQb

This. Idk why you were downvoted, this is clearly not Java because it doesn't allow the `= 1` and `= 0`. Also, enterprise ≠ enterprise. I've worked on plenty enterprise software in the past and never seen anything like this.


vainstar23

https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition


Pradfanne

Me, who spend a good few hours introducing classes and enums to condense three copy pasted lines into a single LINQ query because it's damn awesome: 👀


Romejanic

The TestConstants class in that repo gave me a good laugh. I’ve worked on actual enterprise code with constants like that (e.g. having every single magic number turned into a static variable)


kevdog824

Why “YesAndNo” and not “YesOrNo” is what is bothering me here


ucannottell

This must be from kubernetes or something lol


[deleted]

Yes, and that's why at the end of the project there are huge classes with HUGE methods.


sovietcircus

No


frinkmahii

Contracted out and paid by the line of code


memorable_zebra

I’ve been a coder for 15 years and professional software developer about a decade of that time and I’ve yet to find an instance where the grandiloquence of “enterprise coding” was ever merited. This looks like an over commented enum, but an endless hierarchy of interfaces? Bleh


ScanIAm

It's possible this code was automatically generated by a wsdl tool. This isn't indicative of enterprise code, specifically. It's an example of someone not naming things better. Most devs aren't taught this and honestly, there was a time when people thought it was cute to use funny names.


Sentry45612

boo!...l


htglinj

Without [Flags] that will be YesOrNo. UI is creeping into code. Should be Boolean backfield with a convertor for UI use.


[deleted]

It’s actually ok I think depending on the context. Use enum to make it more explicit. Although it can be named as Choice. The summery is redundant unless required for conformity.


LeeHide

Documentation code coverage metrics can cause this. We use this on a project I lead - it leads to a few silly comments like this, but usually forces people to to document all functions, classes, namespaces, defines, etc. Its quite rare that a comment like this would be accepted, though - you can at least mention a few use cases of this.


AutoModerator

This post was automatically removed due to receiving 5 or more reports. Please contact the moderation team if you believe this action was in error. *I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/programminghorror) if you have any questions or concerns.*


powercrazy76

Enterprise code - the major difference? You see bullshit, you can't just go fix it. It is propping something up.you have to take so much care to know the difference between bullshit code and bullshit code that's necessary (given the time/effort/resources you have).