Results 1 to 15 of 15
Like Tree1Likes
  • 1 Post By JosAH

Thread: How often do you *? Questions to experienced java programmers

  1. #1
    Pojahn_M's Avatar
    Pojahn_M is offline Senior Member
    Join Date
    Mar 2011
    Location
    Sweden
    Posts
    197
    Rep Power
    4

    Default How often do you *? Questions to experienced java programmers

    Here is my questions to you who are good at java.

    How often do you:
    - create your own inner/nested classes? Do you often find them useful?
    - create your own abstract class?
    - create your own enum?
    - use annotations other than Override and Deprecated?

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    6

    Default

    How often do you:
    - create your own inner/nested classes? Do you often find them useful?
    * often and yes
    - create your own abstract class?
    * often
    - create your own enum?
    * if it makes sense :)
    - use annotations other than Override and Deprecated?
    * very often!


  3. #3
    Join Date
    Aug 2011
    Location
    salt Lake City, Utah
    Posts
    10
    Rep Power
    0

    Default

    How often do you:
    - create your own inner/nested classes? Do you often find them useful?
    Answer: Not very often. Most of the time when I think I'm going to create an inner or nested class, I find myself talking myself out of it, because most of the time it doesn't seem sensical, nor is it often very complimentary to the goal of maintainability. My mantra is one class per file, and I stand by that as a rule, though there are some exceptions to that rule, and they aren't well-defined.
    - create your own abstract class?
    Answer: Often, however I only use abstract classes when an interface doesn't make sense or fit the need and I need some kind of *interface*. Abstract classes are essentially a partially implemented interface that serves as an interface.
    - create your own enum?
    Answer: When is makes sense, I create an enum. In Java enums are especially powerful, and can be used for more than just a series of constants. You might use them in an abstract factory. You should look into them. They are very different from C/C++ and C#.
    - use annotations other than Override and Deprecated?
    Answer: Sometimes I even create my own annotations. It depends on the need. I wouldn't go out of my way to use them in most scenarios, but in some cases it is requisite. for example if you are doing unit testing, JUnit and TestNG utilize annotations to identify a unit test and other methods that are important to the unit test framework.

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,585
    Rep Power
    12

    Default

    I don't write code of any scale... But inner/nested classes seem a nice way of handling events. Often they're anonymous, suggesting (to me at least) that they're small things scarcely deserving their own file and who derive their semantics and purpose from their context.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default

    As pbrockway says, anonymous inner classes...lots.
    As nathandelane says...named inner classes, not so much. I tend to prefer to package things together, and thus aim for 1 class per file. There have been exceptions, but they are just that...exceptions.

    Abstract classes? Occasionally do an abstract version of an interface. But there's always an interface there.

    Enums? I use them quite a lot, but do check whether something is really an enum, or is it something that implies there should be a different series of classes. In other words, are the enums acting as flags to determine flow through the code more than is healthy.

    Annotations? If you use most any framework these days you will use annotations. I've not had to bother writing one yet, since the likes of Spring cover pretty much anything I would think of.

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Pojahn_M View Post
    How often do you:
    - create your own inner/nested classes? Do you often find them useful?
    Whenver needed/convenient. Yes, they can be very useful.

    Quote Originally Posted by Pojahn_M View Post
    - create your own abstract class?
    Ditto.

    Quote Originally Posted by Pojahn_M View Post
    - create your own enum?
    Ditto.

    Quote Originally Posted by Pojahn_M View Post
    - use annotations other than Override and Deprecated?
    Not very often.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  7. #7
    Pojahn_M's Avatar
    Pojahn_M is offline Senior Member
    Join Date
    Mar 2011
    Location
    Sweden
    Posts
    197
    Rep Power
    4

    Default Re: How often do you *? Questions to experienced java programmers

    An other question.
    How often have you ran into a situation, were java language is not strong enough, so you was forced to create a native method(and implant it in C/C++)?

  8. #8
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default Re: How often do you *? Questions to experienced java programmers

    Quote Originally Posted by Pojahn_M View Post
    An other question.
    How often have you ran into a situation, were java language is not strong enough, so you was forced to create a native method(and implant it in C/C++)?
    It has nothing to do with the 'strength' of the language; it's the domain of the language that determines whether or not you can use Java. e.g. I had to use C to make a video card work with some vague frame buffer implementation so that at least a bit of SWT (an AWT look alike) could work. The same occurs with other hardware stuff ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  9. #9
    Pojahn_M's Avatar
    Pojahn_M is offline Senior Member
    Join Date
    Mar 2011
    Location
    Sweden
    Posts
    197
    Rep Power
    4

    Default Re: How often do you *? Questions to experienced java programmers

    So, would you recommend a java programmer to also learn C?

  10. #10
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default Re: How often do you *? Questions to experienced java programmers

    Quote Originally Posted by Pojahn_M View Post
    So, would you recommend a java programmer to also learn C?
    Yep, and C++ and Lisp and a couple of other languages as well. Just living in a world of Java is so narrow minded. There is much more to computing than just PCs and Java ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  11. #11
    Pojahn_M's Avatar
    Pojahn_M is offline Senior Member
    Join Date
    Mar 2011
    Location
    Sweden
    Posts
    197
    Rep Power
    4

    Default Re: How often do you *? Questions to experienced java programmers

    Lisp?
    Well, I will study C++ or C# once I am really good at java. Which one of these have I not decided yet. Which one do you prefer, C++ or C#?

  12. #12
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default Re: How often do you *? Questions to experienced java programmers

    Quote Originally Posted by Pojahn_M View Post
    Lisp?
    Well, I will study C++ or C# once I am really good at java. Which one of these have I not decided yet. Which one do you prefer, C++ or C#?
    C++; with C# you're tied to PCs and mostly MS Windows. Try to read something about Lisp too, or Haskell or Scheme or Hope ...

    kind regards,

    Jos
    Pojahn_M likes this.
    cenosillicaphobia: the fear for an empty beer glass

  13. #13
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default Re: How often do you *? Questions to experienced java programmers


  14. #14
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,585
    Rep Power
    12

    Default Re: How often do you *? Questions to experienced java programmers

    @andie: please start a separate thread for your question rather than hijacking this one.

  15. #15
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default Re: How often do you *? Questions to experienced java programmers

    Deleted hijack post by andie.

Similar Threads

  1. Need a experienced Java dev opinion ! :O
    By santa in forum New To Java
    Replies: 7
    Last Post: 06-02-2011, 12:58 PM
  2. need experienced guys interview questions and answers
    By akiravelmont in forum Forum Lobby
    Replies: 1
    Last Post: 05-26-2011, 07:58 AM
  3. Replies: 0
    Last Post: 03-17-2011, 10:50 PM
  4. Replies: 2
    Last Post: 03-03-2011, 09:23 AM

Posting Permissions

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