Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Learning Java

  Asked By: Lourdes    Date: Nov 23    Category: Java    Views: 1017
  

I am about to start learning Java but I need
something clarified first:

I hope to use example code or samples to base my
programs on. Can I redistibute these modified
code as my own? How much do I have to modify free
code until it becomes my own? Can I use this commercially?

Links to sites plus some info would be nice: does "Open Source"
mean I can do the above?

I hope to share my examples with other people and the group and post
examples on the Internet : I do not want any copyright problems.

Share: 

 

6 Answers Found

 
Answer #1    Answered By: Guilherme Silva     Answered On: Nov 23

> I hope to use example  code or samples  to base  my
> programs on. Can I redistibute these modified
code  as my own? How much do I have to modify  free
> code until it becomes my own? Can I use this commercially?

There are legal issues with this, and I am not a lawyer. You can modify
free code ... however it doesn't become your code untill it is all
essentially yours. If there is still code in there from other people,
then they still need to be refferenced too.

> Links to sites  plus some info  would be nice: does "Open Source"
> mean I can do the above?

Commercially, that depends on the licence they are published on. With
most generic open  Source things, you can create commerical products that
stand along side with open source prouducts, but you couldn't claim that
open source product to be your own as well.

> I hope to share  my examples  with other people and the group  and post
> examples on the Internet : I do not want any copyright problems.

The tricky problem when you want to commericalise code is making sure
that every single person who contributed to a product is reffered to and
rewarded for their time, and they allow their code to be used.

Essentialy it comes down to a point, imagine how annoyed you would be if
someone was making money off of your code, and you made nothing.

 
Answer #2    Answered By: James Evans     Answered On: Nov 23


As I said thanks for your helpful comments..

I have another question: If it is relevent I have followed a course
in Java and C# , and spoken to several people but the exact concept
of Object Oriented Programming is still a bit confusing to me :

What is the difference between a procedural language and an OO
language

a) When coding and desiging an app
b) at compilation and run -time

would be grateful if anyone can shed some light on this

 
Answer #3    Answered By: Clarence Nichols     Answered On: Nov 23

Procedural languages are efficient
and useful, don't let anybody tell you otherwise. However as the product
gets larger and larger it is harder keep track of how everything fits
together.

In the very basic sense Object Oriented code  is a way of breaking up
code into chunks reconizable in the real world. If you wanted to make a
program that represented my house, you could have some Objects like
"House", "Person" and "Dog".

My House object would hold information about where in the world it is,
and what kind of Objects that are inside it (Like Person and Dogs).

There are a bunch of Person Objects in the house, there is the Person
Object called Adam, the Person Object called Carla, the Person Object
called Justin and so on.

Currently we only have one Dog Object (who is called Mate), sadly the
great Garbage Collector came and took our other Dog Object away :( (Java
coding joke).

Below you will see two classes (House and People), notice how I can keep
adding people into my house?

public class House {
int streetNumber;
String streetName;
String suburb;
String City;
int postCode;
String country;
<Person>ArrayList people;
<Dog>ArrayList dogs;

//constructor, getter and setter stuff to make these variables
//valid

/**
makes a new person and puts it in the ArrayList
people.
@params personName is a String representing a
persons name
*/
public void newPerson(String personName){
Person p = new Person()
p.setName(name);
people.add(p);
}

/**
Lists out all of the people in the ArrayList
peoples, to the console.
*/
public void listPeople(){
Person p;
for (Person item : people){
p = item;
System.out.println(p.getName());
}
}

}

/**
An Object of People
*/
public class People {
String name;

//constructors and stuff

/**
sets this persons name
*/
public void setName(String name){
this.name = name;
}

/**
returns this persons name.
*/
public String getName(){
return name;
}
}

 
Answer #4    Answered By: Geena Ma.     Answered On: Nov 23

Now here is where it gets confusing:
a) Can you do that in C ? (C++ is OO so I mention C.
(Actually I get the
impression from C programmers that you can do anything in C but it
will take longer)
b) Is it possible, to implement object oriented concepts in a
procedural language?

I get your point that it is easier to create code  in OO languages,
and easier to manipulate 'procedures' - classes. OK

My point about compilation is that in either case procedural or OO
language created code, the compiled code is just a set of
instructions fed to the processor but the OO language created code is
longer and less efficient and maybe containing a lot of redundancy?

 
Answer #5    Answered By: Garrett Brooks     Answered On: Nov 23

I have a theory (which I am sure someone here will hate :P), but inside
every great C programmer is a OO programmer waiting to jump out.

Serriously, there are ways you can get the same effect. Except bending
your brain around them is much harder.


> (Actually I get the
> impression from C programmers that you can do anything in C but it
> will take longer)

That is pretty much the truth of the matter. Also if you are a not a
mystic c ninja then it will take even longer on top of that.

> b) Is it possible, to implement object oriented concepts in a
> procedural language?

Yes but they are strange, and mind bending. Essentialy one of the
reasons that OOP was invented was because they wanted to model the
entire universe (well attempt to), and they just couldn't do it with the
tools they had.


> I get your point that it is easier to create code  in OO languages,
> and easier to manipulate 'procedures' - classes. OK

It is probably easier to manipulate data in OO. However that is probably
all to do with how your brain was formed on programming. I am sure that
Scheme weenies love the way their kind of langage works


> My point about compilation is that in either case procedural or OO
> language created code, the compiled code is just a set of
> instructions fed to the processor but the OO language created code is
> longer and less efficient and maybe containing a lot of redundancy?

Actually OO code is designed to reduce redundancy. Also compiled code is
simply that compiled. Both C++ and C after compiled are essentialy the
same, both of them have been formed into machine code by the compiler.

As for what is longer and what isn't... that probably depends on how you
programm it. I have seen some pretty long winded waffly C code
recently, but I have also seen giant code circles in Java.

bad code is bad code, no matter what language you are writing it in.

At the end of the day OO code suffers a very slight performance hit
every time it loads up a object from scratch. There are ways to minimise
this difference, and with the speed of computers the whole speed issue
is rapidly becoming mute for all but a few industries.

C++ with inline Assembler is used in heaps of games instead of C and
inline assembler, in fact many games just use C++ instead of C now days.

OO code, at least in my mind, makes much more sense when there is a a
few hundred thousands of lines in the project. If you have to work on
the data object Person, you know exactly where it is. In fact it is
almost a metaphore for how the Class should be used.

 
Answer #6    Answered By: Willis Hill     Answered On: Nov 23

When comparing the two points here ... I think that coding and design
wins for OOP. Just because it is less cognitive load to work out what
needs maintaining and creating.

Compilation and run time ... well that is arguable. If you where some
mystic C ninja then compilation and run time would be better. However
mystic C ninjas are hard to find, and very hard to become. Even if you
are a C Ninja it still took 5 times longer to develop than if you did
with say Java or C#.

If you where going to write the core engine to a game like doom ... then
you will need C with inline ASM, if you want to do just about anything
else then C++, Java, C#, are all good places to look at.

 
Didn't find what you were looking for? Find more on Learning Java Or get search suggestion and latest updates.




Tagged: