Results 1 to 10 of 10

Thread: Anonymous classes

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Quote Originally Posted by pstudio View Post
    The thing is, that this is common practise in Java, and some Java libraries basically expect you to use anonymous classes. If you don't use anonymous classes you are gonna end up with 100's of small classes (for a larger project) with one or two functions in it designed for one specific case.
    I didn't know that some libraries actually demmand annonymus classes in Java. But then again I do try to stay away from Java as I don't like its syntax. And now I also think I wouldn't like some approaches that are used in Java.

  2. #2
    Quote Originally Posted by SilverWarior View Post
    I didn't know that some libraries actually demmand annonymus classes in Java. But then again I do try to stay away from Java as I don't like its syntax. And now I also think I wouldn't like some approaches that are used in Java.
    Well they don't demand you to use anonymous classes. You can always get by with making traditional classes. It is just a **** of a lot more convenient to use anonymous classes in some cases.

    I wasn't a big fan of this design approach when I first met it but I suppose I've gotten used to it by now. If I was designing an API for Pascal compilers I certainly wouldn't require the user to create a bunch of classes implementing interfaces with one or two methods in it. But for Java this has become a design approach used by many. I guess it has something to do with the mantra that everything must be a class and in stead of letting people extend large classes just to implement one method they let them implement a small interface which they can then pass as an argument.

    Anyway there are many advantages using the Java RT imo, especially when I can use Oxygene in stead of Java, so this curious design pattern isn't going to stop me from using Oxygene. Not even if I have to create a bunch of small classes with only one method in them
    Imagine I've written something clever here inspiring you to make something awesome. If that happens give me credits

  3. #3
    Based on your description this sounds as a way of how Java tries to implement generics.
    So maybe you should look in this way to find your answer faster.

  4. #4
    Quote Originally Posted by SilverWarior View Post
    Based on your description this sounds as a way of how Java tries to implement generics.
    So maybe you should look in this way to find your answer faster.
    Maybe my description sounds like I'm talking about generics but that is certainly not the issue. Java and Oxygene both support generics and they are used where appropiate.
    The use of anonymous classes I'm describing is more a method of simulating delegates.

    Anyway as I write earlier, it turns out Oxygene has partial support for this feature. I'll have to do with that.
    Imagine I've written something clever here inspiring you to make something awesome. If that happens give me credits

  5. #5
    For whomever it may concern the latest update to Oxygene for Java now supports Inline interfaces inheriting from classes. Clearly I was not the only one desiring this feature.
    Now I have to seriously think about if I want to renew my subscription.
    Imagine I've written something clever here inspiring you to make something awesome. If that happens give me credits

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •