Management obstacles
If youre a manager, your job is to acquire resources for your team, to overcome barriers to your teams success, and in general to try to provide the most productive and enjoyable environment so your team is most likely to perform those miracles that are always being asked of you. Moving to Java falls in all three of these categories, and it would be wonderful if it didnt cost you anything as well. Although moving to Java may be cheaperdepending on your constraintsthan the OOP alternatives for a team of C programmers (and probably for programmers in other procedural languages), it isnt free, and there are obstacles you should be aware of before trying to sell the move to Java within your company and embarking on the move itself.
Startup
costs
The cost of moving to Java is more than just the acquisition of Java compilers (the Sun Java compiler is free, so this is hardly an obstacle). Your medium- and long-term costs will be minimized if you invest in training (and possibly mentoring for your first project) and also if you identify and purchase class libraries that solve your problem rather than trying to build those libraries yourself. These are hard-money costs that must be factored into a realistic proposal. In addition, there are the hidden costs in loss of productivity while learning a new language and possibly a new programming environment. Training and mentoring can certainly minimize these, but team members must overcome their own struggles to understand the new technology. During this process they will make more mistakes (this is a feature, because acknowledged mistakes are the fastest path to learning) and be less productive. Even then, with some types of programming problems, the right classes, and the right development environment, its possible to be more productive while youre learning Java (even considering that youre making more mistakes and writing fewer lines of code per day) than if youd stayed with C.
Performance
issues
A common question is, Doesnt OOP automatically make my programs a lot bigger and slower? The answer is, It depends. The extra safety features in Java have traditionally extracted a performance penalty over a language like C++. Technologies such as hotspot and compilation technologies have improved the speed significantly in most cases, and efforts continue toward higher performance.
When your focus is on rapid prototyping, you can throw together components as fast as possible while ignoring efficiency issues. If youre using any third-party libraries, these are usually already optimized by their vendors; in any case its not an issue while youre in rapid-development mode. When you have a system that you like, if its small and fast enough, then youre done. If not, you begin tuning with a profiler, looking first for speedups that can be done by rewriting small portions of code. If that doesnt help, you look for modifications that can be made in the underlying implementation so no code that uses a particular class needs to be changed. Only if nothing else solves the problem do you need to change the design. If performance is so critical in that portion of the design, it must be part of the primary design criteria. You have the benefit of finding this out early using rapid development.
Chapter 15 introduces profilers, which can help you discover bottlenecks in your system so you can optimize that portion of your code (with the hotspot technologies, Sun no longer recommends using native methods for performance optimization). Optimization tools are also available.
Common design errors
When starting your team into OOP and Java, programmers will typically go through a series of common design errors. This often happens due to insufficient feedback from experts during the design and implementation of early projects, because no experts have been developed within the company, and because there may be resistance to retaining consultants. Its easy to feel that you understand OOP too early in the cycle and go off on a bad tangent. Something thats obvious to someone experienced with the language may be a subject of great internal debate for a novice. Much of this trauma can be skipped by using an experienced outside expert for training and mentoring.