Java Time Savers

frameworks, java

Solution

There's getting the "project" completed efficiently and there are "short cuts". I suspect the following may fall into the "avoiding wasted effort" category rather be truly short cuts but if any of them get you to then end more quickly then I perhaps they help.

1). Decomposition and separation of concerns. You've already identified high-level chunks (UI, persistence layer, parser etc.). Define the interfaces for the provider classes as soon as possible and have all dependent classes work against those interfaces. Pay a lot of attention to the usability of those interfaces, make them easy to understand - names matter. Even something as simple as the difference between setShutdownFlag(true) and requestShutdown(), the second has explicit meaning and hence I prefer it.

Benefits: Easier maintenance. Even during initial development "maintenance" happens. You will want to change code you've already written. Make it easy to get that right by strong encapsulation.

2). Expect iterative development, to be refining and redesigning. Don't expect to "finish" any one component in isolation before you use it. In other words don't take a purely bottom up approach to developing your componenets. As you use them you find out more information, as you implement them you find out more about what's possible.

So enable development of higher level components especially the UI by mocking and stubbing low level components. Something such as JMock is a short-cut.

3). Test early, test often. Use JUnit (or equivalent). You've got mocks for your low level components so you can test them.

Subjectively, I feel that I write better code when I've got a "test hat" on.

4). Define your error handling strategy up front. Produce good diagnostics when errors are detected.

Benefits: Much easier to get the bugs out.

5). Following on from error handling - use diagostic debugging statements. Sprinkle them liberally throughout your code. Don't use System.out.println(), instead use the debugging facilities of your logging library - use java.util.logging. Interactive debuggers are useful but not the only way of analysing problems.

Problem

I find the nature of this question to be quite suited for the practical-minded people on Stack Overflow. I'm setting out on making a rather large-scale project in Java. I'm not going to go into specifics, but it is going to involve data management, parsing of heterogeneous formats, and need to have an appealing interface with editor semantics. I'm a undergraduate student and think it would evolve into a good project to show my skill for employment -- heck, ideally it would even be the grounds for a startup. I write to ask you what shortcuts I might not be thinking about that will help with a complicated project in Java. Of course, I am planning to go at it in Eclipse, and will probably use SWT for the GUI. However, I know that Java has the unfortunately quality of overcomplicating everything, and I don't want to get stuck. Before you tell me that I want to do it in Python, or the like, I just want to reiterate why I would choose Java: Lots more experience with algorithms in Java, and there will be quite a bit of those. Want a huge library of APIs to expand functionality. ANTLR, databases, libraries for dealing with certain formats Want to run it anywhere with decent performance I am open-minded to all technologies (most familiar with Java, perl, sql, a little functional). EDIT: For the moment, I am giving it to djna (although the low votes). I think all of your answers are definitely helpful in some respect. I think djna hit better the stuff I need to watch out for as novice programmer, recognizing that I'm not taking shortcuts but rather trying not to mess up. As for the suggestions of large frameworks, esp. J2EE, that is way too much in this situation. I am trying to offer the simplest solution and one in which my API can be extended by someone who is not a J2EE/JDBC expert. Thanks for bringing up Apache Commons, although I was already aware. Still confused over SWT vs. Swing, but every Swing program I've used has been butt ugly. As I alluded to in the post, I am going to want to focus most on the file interchange and limited DB features that I have to implement myself (but will be cautious -- I am aware of the concurrency and ACID problems). Still a community wiki to improve.

Original source