As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/

SELECT * FROM posts WHERE tid = 'PA PROGRAMMING THREAD'

16162646667100

Posts

  • DrunkMcDrunkMc Registered User regular
    I love OO, but man, you can over due it really easily. Still sweet and my favorite way to code though.

  • bowenbowen How you doin'? Registered User regular
    Java is what happens when you overdo it.




    :rotate:

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Monkey Ball WarriorMonkey Ball Warrior A collection of mediocre hats Seattle, WARegistered User regular
    edited April 2012
    DrunkMc wrote: »
    I love OO, but man, you can over due it really easily. Still sweet and my favorite way to code though.

    Yeh. Learning how to write plain C in an OO manner was one of the more interesting things I've learned at this school. It gave me new respect for having language support for classes, or even something like Go that isn't fully OO (no inheritance), but at least has interfaces and lets you assign functions to types (basically methods, so any type that has the right methods fits a given interface, and "interface{}" fits all types).

    Java is just a very verbose way of expressing OO. C# cleans it up quite a lot but I feel sometimes it should have been a bit more daring with the syntax.

    Monkey Ball Warrior on
    "I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
  • centraldogmacentraldogma Registered User regular
    I remember my lecture on OO programming on C. My first thought was “maybe leave the Object Oriented programming to the Object Oriented languages”. Taking the slight performance hit is worth it to get proper support for the paradigm.

    When people unite together, they become stronger than the sum of their parts.
    Don't assume bad intentions over neglect and misunderstanding.
  • bowenbowen How you doin'? Registered User regular
    Haha OO in C is like taking a shit through a straw. Nothing but poopybutt.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • SyphyreSyphyre A Dangerous Pastime Registered User regular
    I agree, trying to turn a programming language into something it wasn't designed for, when better languages exist, is usually not the right way to go.

  • Jimmy KingJimmy King Registered User regular
    I think one of my favorite quotes I've seen about OO recently was from one of the more well known Scala devs on twitter (I forget which one). It was basically "Sure, OO is very powerful. It's just that it's the sort of power only wielded by madmen and evil sorcerers." Referring to it being very flexible and powerful, but very easy to overdo and make a convoluted mess with all of that flexibility combined with mutability.

    I love OO for code organization, but I totally understand the issue. I'm always fighting with myself on how much flexibility I need... do I need a parent class and then subclasses because feature X might happen in the future or do I keep it simple and just create this one class, etc.

  • bowenbowen How you doin'? Registered User regular
    I am the Gandalf to their Saruman.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • SaerisSaeris Borb Enthusiast flapflapflapflapRegistered User regular
    edited April 2012
    I try to tame my OO designs with KISS and YAGNI. Success varies, though. Sometimes it is the right call to add a bit of complexity now in the interest of simplifying the future, as long as that future isn't too distant.

    Saeris on
    borb_sig.png
  • DrunkMcDrunkMc Registered User regular
    Jimmy King wrote: »
    I think one of my favorite quotes I've seen about OO recently was from one of the more well known Scala devs on twitter (I forget which one). It was basically "Sure, OO is very powerful. It's just that it's the sort of power only wielded by madmen and evil sorcerers." Referring to it being very flexible and powerful, but very easy to overdo and make a convoluted mess with all of that flexibility combined with mutability.

    I love OO for code organization, but I totally understand the issue. I'm always fighting with myself on how much flexibility I need... do I need a parent class and then subclasses because feature X might happen in the future or do I keep it simple and just create this one class, etc.

    Exactly. Sometimes you just have to take a step back and go WHOA WHOA WHOA!!! I will NEVER reuse this code, I'm going to make a Duck() class instead of an OxygenBreather->Animal->WingedAnimal implements LivesInWater-> Duck() class.

  • InfidelInfidel Heretic Registered User regular
    The point of OO isn't that you need to implement or account for everything.

    The most powerful aspect of OO is that if you're doing it right, you'll be able to adapt and implement things when you need them without having to throw up your hands and start over.

    OrokosPA.png
  • SaerisSaeris Borb Enthusiast flapflapflapflapRegistered User regular
    Leave it to Infidel to say exactly what I mean. :P

    borb_sig.png
  • DrunkMcDrunkMc Registered User regular
    Infidel wrote: »
    The point of OO isn't that you need to implement or account for everything.

    The most powerful aspect of OO is that if you're doing it right, you'll be able to adapt and implement things when you need them without having to throw up your hands and start over.

    I think that's why I like it. Its very easy to change direction midway through and still have very readable code. But doing it "right" and designing it with full OO in mind and such just makes me insane. Like my aforementioned OxygenBreather example.

  • PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    bowen wrote: »
    I am the Gandalf to their Saruman.

    YOU SHALL NOT DERIVE

  • bowenbowen How you doin'? Registered User regular
    Yeah adding fields to a class isn't a thing, but the point is one day down the line when you want to change MyClass->Action(); to work with a different internal method, the person on the outside won't notice it.

    So maybe you found a better way to sort your list, the person on the outside doesn't need to care. That's the largest benefit to OOD. There are more but that's the way I see it.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • InfidelInfidel Heretic Registered User regular
    bowen wrote: »
    Yeah adding fields to a class isn't a thing, but the point is one day down the line when you want to change MyClass->Action(); to work with a different internal method, the person on the outside won't notice it.

    So maybe you found a better way to sort your list, the person on the outside doesn't need to care. That's the largest benefit to OOD. There are more but that's the way I see it.

    That is more about contract interface than OO, but for good reasons it is associated with class interfaces.

    OrokosPA.png
  • InfidelInfidel Heretic Registered User regular
    Haven't finished my comp review yet but I am looking forward to delicious delicious backpay. 3.5 months of it and counting~

    OrokosPA.png
  • bowenbowen How you doin'? Registered User regular
    I'll take half.

    Uh.. finder's fee and all.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • InfidelInfidel Heretic Registered User regular
    Plugging my webgame of sorts here since the theme probably appeals to some.

    Was a game/interface I made as part of a Phalla game on the boards here last year and I'm going to update it into something that will just stand on its own.

    OrokosPA.png
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    The thing about people who rally against OO because it's "powerful and you can hurt yourself with it" tend to be academic types who haven't actually written real software in their entire life. Yes, you can write shit code with it. I can write shit functional code with Lisp too. And I can write shit procedural code with C. Over years of experience doing OO, you learn how to avoid writing that shit code. You learn when you're "overdoing it" (we call this over engineering, it has a real term). You learn to sniff out very quickly when you've architected a system to be too complex or not complex enough.

    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    Infidel wrote: »
    bowen wrote: »
    Yeah adding fields to a class isn't a thing, but the point is one day down the line when you want to change MyClass->Action(); to work with a different internal method, the person on the outside won't notice it.

    So maybe you found a better way to sort your list, the person on the outside doesn't need to care. That's the largest benefit to OOD. There are more but that's the way I see it.

    That is more about contract interface than OO, but for good reasons it is associated with class interfaces.

    Completely ignoring contract interface, it's also an example of encapsulation and separation of concerns, both huge pillars of OO. You can do what Bowen is describing without any sort of contractual interface, though providing one makes the design cleaner and easier to predict.

    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • InfidelInfidel Heretic Registered User regular
    GnomeTank wrote: »
    The thing about people who rally against OO because it's "powerful and you can hurt yourself with it" tend to be academic types who haven't actually written real software in their entire life. Yes, you can write shit code with it. I can write shit functional code with Lisp too. And I can write shit procedural code with C. Over years of experience doing OO, you learn how to avoid writing that shit code. You learn when you're "overdoing it" (we call this over engineering, it has a real term). You learn to sniff out very quickly when you've architected a system to be too complex or not complex enough.

    And unfortunately it isn't something you can teach. It is just experience.

    So keep on keeping on~

    OrokosPA.png
  • InfidelInfidel Heretic Registered User regular
    GnomeTank wrote: »
    Infidel wrote: »
    bowen wrote: »
    Yeah adding fields to a class isn't a thing, but the point is one day down the line when you want to change MyClass->Action(); to work with a different internal method, the person on the outside won't notice it.

    So maybe you found a better way to sort your list, the person on the outside doesn't need to care. That's the largest benefit to OOD. There are more but that's the way I see it.

    That is more about contract interface than OO, but for good reasons it is associated with class interfaces.

    Completely ignoring contract interface, it's also an example of encapsulation and separation of concerns, both huge pillars of OO. You can do what Bowen is describing without any sort of contractual interface, though providing one makes the design cleaner and easier to predict.

    There may be more formal lines drawn but to me contract interface means/includes "I am giving you this and expect this, sort it out however you like." So it means those other things too imo.

    As I said, all common themes in OO, but not things that require OO.

    OrokosPA.png
  • wildwoodwildwood Registered User regular
    Infidel wrote: »
    GnomeTank wrote: »
    The thing about people who rally against OO because it's "powerful and you can hurt yourself with it" tend to be academic types who haven't actually written real software in their entire life. Yes, you can write shit code with it. I can write shit functional code with Lisp too. And I can write shit procedural code with C. Over years of experience doing OO, you learn how to avoid writing that shit code. You learn when you're "overdoing it" (we call this over engineering, it has a real term). You learn to sniff out very quickly when you've architected a system to be too complex or not complex enough.

    And unfortunately it isn't something you can teach. It is just experience.

    So keep on keeping on~

    Premature polymorphism is a lot like premature optimization, in my experience.

  • urahonkyurahonky Registered User regular
    New kid at work. He's an intern working on my project. He's about 3 weeks away from graduating... And hasn't heard of regex before.

  • admanbadmanb unionize your workplace Seattle, WARegistered User regular
    edited April 2012
    wildwood wrote: »
    Premature polymorphism is a lot like premature optimization, in my experience.

    I wrap them both under the header of over-engineering.
    urahonky wrote: »
    New kid at work. He's an intern working on my project. He's about 3 weeks away from graduating... And hasn't heard of regex before.

    Does he know Java?

    admanb on
  • TomantaTomanta Registered User regular
    edited April 2012
    urahonky wrote: »
    New kid at work. He's an intern working on my project. He's about 3 weeks away from graduating... And hasn't heard of regex before.

    It was 4 years after I graduated before I heard of regex.

    But I graduated ten years ago from a crappy school. (My assembly class was for some IBM-specific hardware that required us to use an emulator and photocopied book because it went out of print a decade before).

    Tomanta on
  • zeenyzeeny Registered User regular
    urahonky wrote: »
    New kid at work. He's an intern working on my project. He's about 3 weeks away from graduating... And hasn't heard of regex before.

    A good thing in my book.

  • urahonkyurahonky Registered User regular
    He's working in Java. But yeah, not that NOT knowing regex is a bad thing... Just seems odd that his school didn't teach him anything about regex.

  • Alistair HuttonAlistair Hutton Dr EdinburghRegistered User regular
    bowen wrote: »
    Java is what happens when you overdo it.




    :rotate:

    Java is an example of when you under do it but don't provide any other way. The decision to not make functions first class objects is still inexplicable to this day.

    I have a thoughtful and infrequently updated blog about games http://whatithinkaboutwhenithinkaboutgames.wordpress.com/

    I made a game, it has penguins in it. It's pay what you like on Gumroad.

    Currently Ebaying Nothing at all but I might do in the future.
  • centraldogmacentraldogma Registered User regular
    Infidel wrote: »
    GnomeTank wrote: »
    Infidel wrote: »
    bowen wrote: »
    Yeah adding fields to a class isn't a thing, but the point is one day down the line when you want to change MyClass->Action(); to work with a different internal method, the person on the outside won't notice it.

    So maybe you found a better way to sort your list, the person on the outside doesn't need to care. That's the largest benefit to OOD. There are more but that's the way I see it.

    That is more about contract interface than OO, but for good reasons it is associated with class interfaces.

    Completely ignoring contract interface, it's also an example of encapsulation and separation of concerns, both huge pillars of OO. You can do what Bowen is describing without any sort of contractual interface, though providing one makes the design cleaner and easier to predict.

    There may be more formal lines drawn but to me contract interface means/includes "I am giving you this and expect this, sort it out however you like." So it means those other things too imo.

    As I said, all common themes in OO, but not things that require OO.
    I think I'd call it "black boxing", but I'd probably be misusing the term.
    urahonky wrote: »
    He's working in Java. But yeah, not that NOT knowing regex is a bad thing... Just seems odd that his school didn't teach him anything about regex.

    Does he not know regular expressions or the function regex? Because it'd be odd to graduate without learning the former.

    When people unite together, they become stronger than the sum of their parts.
    Don't assume bad intentions over neglect and misunderstanding.
  • PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    bowen wrote: »
    Java is what happens when you overdo it.




    :rotate:

    Java is an example of when you under do it but don't provide any other way. The decision to not make functions first class objects is still inexplicable to this day.

    Maybe they didn't want to deal with closures? (Depending on what you consider first class object to mean)

  • KambingKambing Registered User regular
    GnomeTank wrote: »
    The thing about people who rally against OO because it's "powerful and you can hurt yourself with it" tend to be academic types who haven't actually written real software in their entire life. Yes, you can write shit code with it. I can write shit functional code with Lisp too. And I can write shit procedural code with C. Over years of experience doing OO, you learn how to avoid writing that shit code. You learn when you're "overdoing it" (we call this over engineering, it has a real term). You learn to sniff out very quickly when you've architected a system to be too complex or not complex enough.

    The reason that academics (in particular certain PL folk) don't like OO is because it precisely leads to overly complex code whereas functional styles lead to more concise, elegant code.

    There's a whole bunch of features mixed into the debate when it is phrased as "OO vs. functional" (like mutation, ADTs, polymorphism, etc.) so its not a cut-and-dry argument. However, after being in industry and academia now, I'm firmly in the functional side of things.

    @TwitchTV, @Youtube: master-level zerg ladder/customs, commentary, and random miscellany.
  • bowenbowen How you doin'? Registered User regular
    To be honest, I don't know regex. I dealt with it about 1 class before graduation and I said "what the fuck is this fucking shit?" and then stopped dealing with it. I mean I can do it, but it takes me like 12 times as long to do it the regex way as it does to actually take the verbiage, break it down, and check for correctness via tokens.

    something@domain.com is really easy to check tokenwise. You do the same thing properly in regex and you're looking at, easily, a 256+ character regex that makes 0 sense outside of people that specialize in regex or have hours to dissect it.

    Regex causes way more problems than it's worth. I'd probably admit to not knowing it too if someone asked me or if an interviewer questioned why I don't use it.

    I wouldn't want to work for someone that uses regex anyways, shit be poopybutt-like.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Monkey Ball WarriorMonkey Ball Warrior A collection of mediocre hats Seattle, WARegistered User regular
    Kambing wrote: »
    GnomeTank wrote: »
    The thing about people who rally against OO because it's "powerful and you can hurt yourself with it" tend to be academic types who haven't actually written real software in their entire life. Yes, you can write shit code with it. I can write shit functional code with Lisp too. And I can write shit procedural code with C. Over years of experience doing OO, you learn how to avoid writing that shit code. You learn when you're "overdoing it" (we call this over engineering, it has a real term). You learn to sniff out very quickly when you've architected a system to be too complex or not complex enough.

    The reason that academics (in particular certain PL folk) don't like OO is because it precisely leads to overly complex code whereas functional styles lead to more concise, elegant code.

    There's a whole bunch of features mixed into the debate when it is phrased as "OO vs. functional" (like mutation, ADTs, polymorphism, etc.) so its not a cut-and-dry argument. However, after being in industry and academia now, I'm firmly in the functional side of things.

    And even if you are just taking some aspect of functional and using them in a basically OO system it is still a nice way to make things clear and clean. Or at least it feels that way, I'm far too new at coding to be good at design yet.

    "I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
  • EtheaEthea Registered User regular
    edited April 2012
    I thought I went to a shitty school, and we still had a class on finite automata and regular grammers. We covered the formal definition of turing machines, and pumping lemma and than had to build basic regular grammers and DFA's for a simple regular expression parser.

    Ethea on
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    Kambing wrote: »
    GnomeTank wrote: »
    The thing about people who rally against OO because it's "powerful and you can hurt yourself with it" tend to be academic types who haven't actually written real software in their entire life. Yes, you can write shit code with it. I can write shit functional code with Lisp too. And I can write shit procedural code with C. Over years of experience doing OO, you learn how to avoid writing that shit code. You learn when you're "overdoing it" (we call this over engineering, it has a real term). You learn to sniff out very quickly when you've architected a system to be too complex or not complex enough.

    The reason that academics (in particular certain PL folk) don't like OO is because it precisely leads to overly complex code whereas functional styles lead to more concise, elegant code.

    There's a whole bunch of features mixed into the debate when it is phrased as "OO vs. functional" (like mutation, ADTs, polymorphism, etc.) so its not a cut-and-dry argument. However, after being in industry and academia now, I'm firmly in the functional side of things.

    I'm on the "correct tool for the job" side of things. In most cases, that ends up being a mixture of OO and functional design patterns. They actually mix incredibly well if you know what you're doing.

    The problem is too many people graduate from college and think they know what they are doing: They don't. It takes college + years of experience to actually know what you're doing, and the part that is optional is the college, not the years of experience. Not that college is bad, I recommend it for everyone. People just need to understand what a comp sci program is actually going to give you, and what it's not going to give you.

    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • urahonkyurahonky Registered User regular
    In Java, is there ever a reason you would want to use an ArrayList over a HashMap unless you don't have a unique identifier?

  • EndEnd Registered User regular
    edited April 2012
    the biggest reason is that hashmaps aren't ordered

    Normally I'd flip around your assumption though: you wouldn't care about using a hashmap unless you need to look something up via some identifier.

    if you need an ordered hashmap, it looks like LinkedHashMap does what you want

    End on
    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpg
  • EtheaEthea Registered User regular
    If the order of the list means something top your application.
    If you need to define a view or slice of the group a list will be easier
    If you can use a custom allocator for the list it can get great sequential iteration performance ( but just use a vector )
    list can be used by multiple threads where one removes items and another adds items way easier than a hash map
    I expect rehasing will be slow, so if you are dramatically changing the amount of items being stored a list would preform better.

This discussion has been closed.