• What are you working on? November 2011 Edition
    3,673 replies, posted
[QUOTE=Tobba;33221672]Fucking java Since there is no way to actually force the shutdown of a thread, im gonna have to dismantle an entire library to get this to work[/QUOTE] Bad library design? :p Anyway... restarted writing some kind of game "engine" for android (the n-th time).. actually working well so far :p It's forced OpenGL ES 2.0, 90% of the maths stuff is done and shaders are working nice and as expected :D [img]http://i.cubeupload.com/c8WQiN.png[/img] Dot3 bumpmapping :D
[QUOTE=Tobba;33221672]Fucking java Since there is no way to actually force the shutdown of a thread, im gonna have to dismantle an entire library to get this to work[/QUOTE] Having to forcefully kill a thread is a sign of poor design. You should always wait for the thread to complete by joining it.
[QUOTE=RyanDv3;33222125]I'd like to express my unhappiness with C#/Java's inheritance. Specifically, the lack of multiple inheritance, as well as the fact that you can't override static functions. In addition, I'd appreciate it if static variables could also be "overridden". I HATE duplicating code, and the lack of these features causes me to do it all the time.[/QUOTE] what do you need multiple inheritance for
[QUOTE=icantread49;33222288]what do you need multiple inheritance for[/QUOTE] I rated this 'agree' and went to write a sensible reply with the same direction, quoting Java's interfaces as a good side-step for the lack of multiple inheritance, when I realised that in no way shape or form does an implemented interface match an inherited class in any terms of functionality, efficiency or convenience. This has got to be the first time I've personally found a reason to look upon Java critically. Hey look! I'm learning!
[QUOTE=VoiDeD;33222185]Having to forcefully kill a thread is a sign of poor design. You should always wait for the thread to complete by joining it.[/QUOTE] There are plenty of situations where you could benefit from being able to forcefully close a thread. for example if it hangs or is frozen for example a external thread or a thread that belongs to a different lib.
[QUOTE=OldFusion;33222576]There are plenty of situations where you could benefit from being able to forcefully close a thread. for example if it hangs or is frozen for example a external thread or a thread that doesn't belong to your lib.[/QUOTE] That doesn't account for "plenty" of situations. Those are edge cases and areas of bad design. [url]http://msdn.microsoft.com/en-us/library/windows/desktop/ms686717%28v=vs.85%29.aspx[/url] [quote]TerminateThread is a dangerous function that should only be used in the most extreme cases. You should call TerminateThread only if you know exactly what the target thread is doing, and you control all of the code that the target thread could possibly be running at the time of the termination. For example, TerminateThread can result in the following problems[/quote]
[QUOTE=OldFusion;33222576]There are plenty of situations where you could benefit from being able to forcefully close a thread. for example if it hangs or is frozen for example a external thread or a thread that belongs to a different lib.[/QUOTE] Still bad software design.. you can nicely interoperate with threads using messages, object monitors, semaphores and lots of other fancy stuff Java provides..
NOot exactly programming, but it's for a game I'm working on [media]http://www.youtube.com/watch?v=jPb1LNSnyAc[/media] (Swedish for "Hey you, you criminal. Do you want a punch or is that just your pants talking?") It's gonna be made in unity. Also, I've worked on a game before in Unity which was programmed in Javascript ("UnityScript") but people say that it's better to work in C#. I don't know any C#. What do
[QUOTE=icantread49;33222288]what do you need multiple inheritance for[/QUOTE] I'm more interested in why he wants to override static methods... I dunno about Java, but in C# does that even make sense?
[QUOTE=jalb;33223366]I'm more interested in why he wants to override static methods... I dunno about Java, but in C# does that even make sense?[/QUOTE] Class A is a superclass of class B. Class A sets the precedent of having a color property. Only catch: this color property is the same across all instances. If you just had class A, it would be a no-brainer. You simply make a static variable that holds the color. But since you also have a derived class B, you can't, because Class B isn't allowed to override any static Class A stuff (meaning class B would have to be the same color as class A) So what do you do? You're forced make a non-static method return the information so you can override it in derived classes. Which means that that information -which only relates to the class itself, not the instance- is only available with through an instance of a class, which is terrible design. Contrived example, but I run into a lot.
@ people who rated me dumb and disagree: can you please elaborate? i really can't think of a proper case for multiple inheritance
[QUOTE=icantread49;33223729]@ people who rated me dumb and disagree: can you please elaborate? i really can't think of a proper case for multiple inheritance[/QUOTE] One example would be having a physics class "RigidBody" and a game class "BaseEntity" and inheriting from both. Otherwise you'd have to have RigidBody inherit from BaseEntity or vice versa to make it work when that may not be desired. Of course you can always do it other ways but once someone sets their mind on doing it this way all other ways look shit... [QUOTE=RyanDv3;33223645]Contrived example, but I run into a lot.[/QUOTE] I understand what you mean. But I asked about static methods, not variables.
[QUOTE=icantread49;33223729]@ people who rated me dumb and disagree: can you please elaborate? i really can't think of a proper case for multiple inheritance[/QUOTE] Generally you inherit from a class because that superclass does something, and you don't want to duplicate code. Let's say you have a Container superclass you want to inherit from, so your class will instantly gain the ability to store items. But WAIT! Your class already inherits from something else! So now, you have to rewrite Container into the interface IContainer, whilst stripping out various functionality because interfaces can't have member variables. Which means that now, each and every class that implements Container has to define it's [b]very own[/b] List<Item> member variable, as well as it's [b]very own[/b] implementation of say, TakeOut(), PutIn(), Peek(), etc. Even though, remember, that they all work exactly the same. Interfaces are useful when you want to define a ability that presumably is going to be handled differently by everything that implements it. It's NOT a replacement for inheritance, because while it does help organize, it does not cut down on code duplication.
[QUOTE=jalb;33223783]One example would be having a physics class "RigidBody" and a game class "BaseEntity" and inheriting from both[/QUOTE] that's a terrible argument for multiple inheritance and a [i]wonderful[/i] argument for composition [editline]11th November 2011[/editline] [QUOTE=RyanDv3;33223960] Let's say you have a Container superclass you want to inherit from, so your class will instantly gain the ability to store items. But WAIT! Your class already inherits from something else![/QUOTE] what else does it inherit from?
[QUOTE=jalb;33223783] I understand what you mean. But I asked about static methods, not variables.[/QUOTE] It's sorta the same problem; if I had overridable static methods, I could, in that example, just have a static method GetColor(), which would simply return a color, and derived classes would be able to override that method, achieving the same effect. I guess it just seems more natural to override a function rather than a variable.
[QUOTE=icantread49;33223969]that's a terrible argument for multiple inheritance and a [I]wonderful[/I] argument for composition [editline]11th November 2011[/editline] what else does it inherit from?[/QUOTE] Java gives a good example: You have JPanel All other GUI components like JButton etc inherit off of JPanel, due to JPanel having the base code. Duplicating 1000+ lines every time to make something new that could inherit is wasteful and slow. The reason you can't override static methods/fields is due to the way the JVM works. There is no "this" keyword when using static functions, which makes it complicated to figure out which is which
[QUOTE=icantread49;33223969]that's a terrible argument for multiple inheritance and a [i]wonderful[/i] argument for composition [/QUOTE] I was actually thinking mentioning component based design as a great argument FOR mulitple inheritance, but then, maybe "composition" is something different. What exactly is that?
I bought skyrim. There was no CD key inside box. FUCK.
[QUOTE=Map in a box;33224083]Java gives a good example: You have JPanel All other GUI components like JButton etc inherit off of JPanel, due to JPanel having the base code.[/QUOTE] wait, what? how is that multiple inheritance? [editline]11th November 2011[/editline] [QUOTE=RyanDv3;33224113]I was actually thinking mentioning component based design as a great argument FOR mulitple inheritance, but then, maybe "composition" is something different. What exactly is that?[/QUOTE] composition is composing an object out of smaller objects that contain specific functionality doing components via multiple inheritance is a [i]terrible[/i] idea. that's like saying that a Car is-a Engine and Chassis rather than has-a Engine and Chassis
[QUOTE=C:\;33224335]I bought skyrim. There was no CD key inside box. FUCK.[/QUOTE]Call Bethesda? E-mail them? Do [i]Something[/i]?
[QUOTE=danharibo;33224457]Call Bethesda? E-mail them? Do [i]Something[/i]?[/QUOTE] Ok, emailed them. i am very mad
[QUOTE=icantread49;33224412]wait, what? how is that multiple inheritance? [editline]11th November 2011[/editline] composition is composing an object out of smaller objects that contain specific functionality doing components via multiple inheritance is a [i]terrible[/i] idea. that's like saying that a Car is-a Engine and Chassis rather than has-a Engine and Chassis[/QUOTE] I never suggested something like that. What I've suggested was more like a Car is a moving object and is a container.
[QUOTE=RyanDv3;33224706]I never suggested something like that. What I've suggested was more like a Car is a moving object [b]and is a container[/b].[/QUOTE] ... wat [editline]11th November 2011[/editline] i feel like you're desperately creating contrived examples to support multiple inheritance [editline]11th November 2011[/editline] just playing around with texture-based anti-aliased edges: [img]http://i.imgur.com/01Fa9.png[/img] there are obvious issues at corners
[QUOTE=icantread49;33224969] just playing around with texture-based anti-aliased edges: [IMG]http://i.imgur.com/01Fa9.png[/IMG] there are obvious issues at corners[/QUOTE] Just draw 2px diameter circles on all of the corners.
[img_thumb]http://i.imgur.com/Ikt1x.png[/img_thumb] It's not much compared to the graphical wonder of the other stuff I've done, but it's a big step for me seeing as I've never made a game before... Also, all of this discussion about why C#/Java/etc should have multiple inheritance can be easily resolved by going to the [URL="http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612"]source [/URL]of those decisions. Besides what they've all said on the subject, I think the reason that a language such as C++ has multiple inheritance isn't because it's insanely useful so much as they let you do whatever the hell you want with it and restricting inheritance behavior wouldn't fit that idea. As for being able to override static variables...is there even a language that explicitly allows this? I can't think of one and I don't see any point to it at all, there's tons of ways the achieve whatever effect you'd hope to solve with that and they're all much more straight forward and unlikely to confuse the shit out of whoever has to maintain your code (including you a few months down the road).
[QUOTE=icantread49;33224969]... wat [/QUOTE] ??? Can you not put things in your car!? How do you drive it...
I've run into a pretty realistic scenario where multiple inheritance makes sense. I had multiple classes with the nearest common ancestor being the very root of the class hierarchy. These classes needed to have some common functionality, but I didn't want to pollute every class in the hierarchy with some odd methods and attributes - so I used multiple inheritance. But then I realized I was just simulating an interface. This happens every time I come up with a reason to use multiple inheritance (without the result epitomizing the diamond problem). [url=http://www.parashift.com/c++-faq-lite/multiple-inheritance.html]Also, found this relevant.[/url]
[QUOTE=Night-Eagle;33225424]I've run into a pretty realistic scenario where multiple inheritance makes sense. I had multiple classes with the nearest common ancestor being the very root of the class hierarchy. These classes needed to have some common functionality, but I didn't want to pollute every class in the hierarchy with some odd methods and attributes - so I used multiple inheritance. But then I realized I was just simulating an interface. This happens every time I come up with a reason to use multiple inheritance (without the result epitomizing the diamond problem). [url=http://www.parashift.com/c++-faq-lite/multiple-inheritance.html]Also, found this relevant.[/url][/QUOTE] Yeah I like that site, it's very informative. I really don't have a problem with multiple inheritance. At my school as a software engineer I've spent enough hours pondering the Gang of Four book to come up with my own arguments for and against their ideas. As I see it, the reason they disapprove of multiple inheritance is because it can lead to the dreaded [URL="http://en.wikipedia.org/wiki/Diamond_problem"]diamond problem[/URL], which is a very real and very annoying problem to have. They just suggest a number of design patterns that allow you to achieve the same end goal as multiple inheritance while avoiding the threats. If you use multiple inheritance sparingly and with care I don't see a problem with it.
[QUOTE=chimitos;33225237]Just draw 2px diameter circles on all of the corners.[/QUOTE] yup, that's a possible solution
[QUOTE=C:\;33224335]skyrim[/QUOTE] R.I.P WAYWO
Sorry, you need to Log In to post a reply to this thread.