wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Access Modifiers, do I realy need them Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Access Modifiers, do I realy need them" Watch "Access Modifiers, do I realy need them" New topic
Author

Access Modifiers, do I realy need them

Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 916

I have a simple question :
Are the access modifiers (aka scopes) something what you need to know to "program" in java or is enough to know only some API (e.g that the String class has a split method).

I know the answer, but I need to know some other people meaning.
How about you guys ? feel free to add all your comments (related with the topics) to this post.

Regards,
M


SCJP, SCJD, SCWCD, OCPJBCD
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38851
    
  23
Yes, you do. But don't confuse access modifiers with scopes, which are something completely different.

You want to hide the fields of your classes, usually by giving them private access and you usually want to make the methods widely available by giving the public access.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61218
    
  66

Are traffic lights something I need to know to "drive"? Is it enough too know what a few of the signs mean?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11314
    
  16

Originally posted by Bear Bibeault:
Are traffic lights something I need to know to "drive"? Is it enough too know what a few of the signs mean?

that would depend on where you are driving. if you're only on country roads that don't HAVE stoplights, then no, you don't.

The same would go for java (IMHO). if you are just going to do simple stuff, then no, you don't need access modifiers. if you are going to do anything even REMOTELY beyond a basic program, then yes.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38851
    
  23
If you're only on country roads without stoplights, you still have to know about traffic lights (at least in Britain) because you will have to take a driving test which is mainly town traffic.

Or you can drive without a licence, without a test on the car, without tax and insurance. etc.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by fred rosenberger:

The same would go for java (IMHO). if you are just going to do simple stuff, then no, you don't need access modifiers. if you are going to do anything even REMOTELY beyond a basic program, then yes.


If you are saying that access modifiers are necessary to write complex programs, Smalltalk programmers will disagree. In Smalltalk all methods are automatically public, and all fields private. And Smalltalk is known to be quite appropriate for complex programs.

I'd still say that to be taken seriously as a Java programmer, you will need to at least understand how they work.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 916

Hi people,

First I'll like to thanks for your interest.
I anticipate this answers and I agree with everything.
I come on this (strange) questions after some endless discussions with some of the "visual" developers, this people are used to use smart IDES where everything is pink, or at least it looks like. This is a classical case where a tool changes quick from a bless in to curse and this without the victim can check something.
Even if you try use the theory like argument they have the "look it works" argument.
What arguments can I bring in this kind of dispute ?
What you guys think about ?


Regards,
M
[ April 24, 2008: Message edited by: Mihai Radulescu ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Access Modifiers, do I realy need them