Hi ,
In the next month i will be involved in java project that deal with the changes of code that depends on some upgraded version .
I am a student so i have never seen before upgrade code ,I really want to understand how the upgrade work , what are the changes for example? which are the problems that upgrade deal with?

Maybe one simple thing that i know about upgrading versions will help to explain my question,
for example :
at the previous version :

void foo( int num );

at the new version the same function but :

void foo(int num1, int num2 );

so , at the code that depends on this software any where there is call function

foo(/*some number*/)

, now we will need to send two numbers

foo(/*some number*/ ,/*some number*/);

I will appreciate any answer ,and will be happy to expand my understanding .

Thanks ,
Rivka :)

Edited 5 Years Ago by Rivka Schwartz: n/a

I am not able to understand your problem perfectly.See as and when versions are upgraded new facilities are added. I think you are saying first the method foo() was taking 1 argument and now 2 arguments but from Java 5 i.e. Tiger if you are not sure that a method will take how many arguments you should go for variable-argument list i.e. varargs . So you can write your method like this

void foo(int...no){//code}

Now you can call this method like this

foo(5);

OR

foo(10,20,55);

That is you can pass any number of arguments to the method.This facility was not available in Java 2.

Thanks for response , I think i didn't made it clearly.
I will explain my question ..

let's say that I have version X , and a code that use this version we will call it A.
And then Our version X was upgraded to version "X+1" .
this process of upgrading includes some changes like add arguments to function , changing kine of arguments ,I believe there is many more things that change , that what i will want to know from you ...

when we know what are the changes , we can go to the code A and change the code to fit the version "X+1".

is there is changes that you know about them that you can share with me?
when you said "when versions are upgraded new facilities are added" what the influence on the code? files are added? functions are changed ? what else?

thanks alot!

See as far as Java is concerned i had Java 2 in my college syllabus and at present we are having Java 7 (most people still use Java 6 due to some bug problem which everybody is mentioning in Java 7- i am not sure about this). So i did java 2 in my college and now i am studying java 6 and that doesn't mean that i cannot run my java 2 programs in my java 6 JRE(java run-time environment) because java 6= java 2 + and more features and yes i cannot do the reverse i.e. running java 6 programs in java 2 JRE. So according to me you should not be bothered if the version upgrades because your previous code is still valid and will run perfectly. Some of the changes i would say new facilities that were added in Java 5 and Java 6 from Java 2 are as
(1)Generics
(2)Varargs
(3)enhanced for loop
(4)Autoboxing and autounboxing
(5)Collections
and many more which you can google

I will explain my self again , maybe it's still not clearly ...

Many companies develop a software infrastructure that others in the develop team use this software infrastructure in there develop code , every few month or maybe years the company release a new version of the software infrastructure because of adding features , functionality , different algorithms etc' ..
The issue is that i want to know about the changes when the company release new version of the software infrastructure code .
I wrote about simple change that i know , that the develop team need to cope with , if in the past the develop team used a function with 1 argument to do something lets call it X , today , to do the same thing X they need to call the same function but with 2 parameters , because in the software infrastructure the function was changed in the new version.
So , They need to change the old code to fit the new version of software infrastructure .
So , I really want to know more about this process, which changes there are more ,on functions, on classes , on packages , and more ?
what are the problems that the software develop team has to deal with?

Thanks for your patience :)
Rivka

One of the joys of Java is that there isn't often a need to do that. Maybe X is found to be insufficient in some way, and needs to be enhanced with a second parameter. Java polymorphism means you can keep the old version, and add the new version alongside it. Existing code is not broken, but the enhanced version is there for anyone who needs it. Designers will go to great lengths not to break existing interfaces, but very often enhance them with new methods that break nothing.

Another thing you can do in Java when you really want to get rid of a method is to mark it "deprecated". That way anyone who uses it will get a compiler warning that they should change their code, but it doesn't actually stop working.

There is misunderstanding...
I gave an example that exist , so for sure there is some things that not clear .
You are right that the fact that there is a new infrastructure software - new version to the old one , the old infrastructure software not need to be change , it exist buא it doesn't make seance to the new one and the code that was depend on the old , the code will run without Errors ... but , the idea is that the company want's to fit *all* code that depends on the old version to the new version .

I am not asking about java , I am asking about the issue of handle the code that was depends of the old version and now have to be depend on the new version .
It's exist , Today , when programmer have a code that depends on software , and the software was upgraded , he need to change his old code to fit the new version .

When upgrading the underlying code / compiler / whatever for your work, the thing of greatest importance is that you know the upgrade worked. For this, you must have an already existing test suite that you trust to tell you when something breaks. The upgrade process then works like this:

  1. Run the suite in the old environment, taking copious notes about failures so you can later see if you have the same ones
  2. Upgrade the underlying "thing"
  3. Try to rebuild your work using the new "thing".
    • Continue fixing/changing and trying to rebuild until you get it "working"
  4. Run your test suite, taking copious notes
  5. Repeat
    • making changes/fixes
    • adding new tests
    • Running the test suite, taking notes

    until you run out of time or money, or the quality is at least as good as before.

You will notice that the precondition is a working test suite. If you don't already have one, you would be well advised to create one before you try to upgrade.

Thanks! thank you for explain the upgrading process ,it is benefits me to know that. Actually i don't need to cope with the upgrading i need explore the simple things that the programmer need to change manually , like changing the calling sentence to a function that has change.
What else examples you thinking about? It will really help me !

When you upgrade a compiler or library, steps 3 and 5 above tell you where you need to make changes. You are now asking how to make the changes, if I understand your most recent post. That is not an easy answer because it is different for every problem. There are some categories, though:

  • The code does not compile. Same as with new code, you examine the compiler's error message and think about what caused it, then make the appropriate fix. (See below for 'appropriate fix')
  • The code compiles with new warnings. This is an important one that many people don't understand. The compiler is telling you that your code may have problems that are too subtle to be actual errors. Things like in C when you pass an uninitialized pointer to a library function. Each warning should be considered and you should either
    • Fix the code to avoid the underlying problem
    • Document the decision to ignore the warning (why is it not important in this case?)
  • The code compiles, but the test suite reports failures. This is probably where most of the work happens. You have to make an "appropriate fix" in each case.

So what is an "appropriate fix"? Once again: Very difficult to explain clearly. You try to keep these principles in mind when changing the code:

  • Change as little as possible
  • Keep the changes simple and understandable
  • Document what you did and why (in the code is best. Reference a bug identifier)
  • If there is a "recurring theme" to some of the problems, try to make a single change that can fix them all at once. Perhaps use a different utility method or function when the code is associated with the new (compiler).
    • In C, you would define a macro to dispatch to the old function or the new one.
    • In Java you might have two subclasses of a base class and instantiate the appropriate one in a FactoryMethod.
    • if you know you will never use the old (compiler) again, you can avoid the complexity of having and testing two execution branches, but be sure you can undo the change when needed! (Use source control, of course, and mark each 'breaking' change)
  • Keep a list of all the newly discovered problems and work on them in priority order (use bug tracking software!)
  • Run your unit/regression tests after every change: Don't let one "fix" perturb the system into causing other failures

Edited 5 Years Ago by griswolf: n/a

This article has been dead for over six months. Start a new discussion instead.