Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   programming styles (http://www.velocityreviews.com/forums/t390633-programming-styles.html)

Amali 02-05-2007 06:12 PM

programming styles
 
What is meant by programming "style" and why it is important


Alex Hunsley 02-05-2007 06:27 PM

Re: programming styles
 
Amali wrote:
> What is meant by programming "style" and why it is important


What is meant by homework, and why is it important not to cheat at it?

Liz 02-05-2007 06:34 PM

Re: programming styles
 
On 5 Feb 2007 10:12:05 -0800, Amali wrote:

>What is meant by programming "style" and why it is important


Observing naming conventions.
One statement per line.
Using appropriate comments.
Indenting code to show structure.
Avoiding obfuscation.

Those are important.

There might be more subtle elements of "style", such as the order in
which you put a gui together, which might be important to an
individual programmer because by following their own routine they
ensure that everything is covered.

Hakusa@gmail.com 02-05-2007 11:09 PM

Re: programming styles
 
On Feb 5, 1:12 pm, "Amali" <amalikarunanay...@gmail.com> wrote:
> What is meant by programming "style" and why it is important


It's important because it makes your code more readable.
Some conventions like where to put the brackets might seem odd to you,
but if everyone puts them in similar places, it's easier to read
everyones code.

Many people have died over long winded discussions of format, spacing
and such.


John T 02-05-2007 11:48 PM

Re: programming styles
 
Liz wrote:
> Avoiding obfuscation.

I have run into this word many times and am unclear as to how one of
these definitions:

1. to confuse, bewilder, or stupefy.
2. to make obscure or unclear: to obfuscate a problem with extraneous
information.
3. to darken.

relates to Java programming. Is there a definition which is more
applicable to Java or is the general "make it hard to understand"
concise enough?



Lew 02-06-2007 06:25 AM

Re: programming styles
 
"Amali" wrote:
>> What is meant by programming "style" and why it is important


Hakusa@gmail.com wrote:
> It's important because it makes your code more readable.
> Some conventions like where to put the brackets might seem odd to you,
> but if everyone puts them in similar places, it's easier to read
> everyones code.
>
> Many people have died over long winded discussions of format, spacing
> and such.


There is far more to style than mere indentation. Where you place your braces
isn't style, it's formatting. Style is whether you use compact algorithms with
solid invariants and good error checking, or if you just slap together some
crude loops and hope it works. Style is anally javadocing everything in sight,
vs. letting the next schnook forensically discern your intentions. Style is
choosing whether to make a method public final or protected inheritable. Style
is making nicely encapsulated, beautifully cooperating modules that emergently
produce magic and cannot break or fail in the face of the most outrageous user
input. Style is coding an application at sixty-four times the industry average
and having a fraction of the bugs, and leaving easy room for every future
enhancement the customer wishes.

As long as you remain focused on the braces and indents, you will never see
the grasshopper.

- Lew

Luc The Perverse 02-06-2007 08:55 AM

Re: programming styles
 
"John T" <printdude1968@gmail.com> wrote in message
news:knPxh.2964$R71.44972@ursa-nb00s0.nbnet.nb.ca...
> Liz wrote:
>> Avoiding obfuscation.

> I have run into this word many times and am unclear as to how one of these
> definitions:
>
> 1. to confuse, bewilder, or stupefy.
> 2. to make obscure or unclear: to obfuscate a problem with extraneous
> information.
> 3. to darken.
>
> relates to Java programming. Is there a definition which is more
> applicable to Java or is the general "make it hard to understand" concise
> enough?


Deliberate obfuscation is doing "tricks" to make your code exceptionally
hard to understand.

Simple examples are since the letter l (lowercase) looks like the number 1,
you could have some obscure reference int l = 200

and then have a for statement

for(int x=l;x<201;x++)


Which appears to run 200 times (if you don't realize the l is an L not the
number 1) but really only runs once

Another is exceptionally unusual names for functions and variables (most
effective when they have NOTHING to do with what the variable actually
does/means)

while(EaT(DOG + cat) - BuNNy > S142 )

etc.

Though not java for an extreme case of c code obfuscation look no further
than the international c obfuscation contest!

http://www.ioccc.org/2004/anonymous.c Here is an example winning entry.

Java is a little harder to obfuscate than c or c++ because there are no
macros.

--
LTP

How can you have any pudding if you don't eat your meat?



dagarwal82@gmail.com 02-06-2007 09:17 AM

Re: programming styles
 
Amail... worte:-
>What is meant by programming "style" and why it is important

/* why it is important */
Just make a big hall or a room at your home and keep everything in
that messed up.
Now everyday when you need something ,go to the hall and find the
things..... (It may include your hair-brush, tooth-paste, tooth-
brush... a lot of things)....

/* What is meant by programming "style" */
Now, keep your tooth-paste and tooth-brush near wash-basin, hairbrush
and makeup on the dressing table. This is what a programming style
mean. Right thing at the right place at the right time.


Alex Hunsley 02-06-2007 10:46 AM

Re: programming styles
 
John T wrote:
> Liz wrote:
>> Avoiding obfuscation.

> I have run into this word many times and am unclear as to how one of
> these definitions:
>
> 1. to confuse, bewilder, or stupefy.
> 2. to make obscure or unclear: to obfuscate a problem with extraneous
> information.
> 3. to darken.
>
> relates to Java programming. Is there a definition which is more
> applicable to Java or is the general "make it hard to understand"
> concise enough?


Btw, there are broadly two types:
1) source code level obfuscation, which is what the others are talking about
2) bytecode obfuscation - compacts the bytecode (also in the process
making it probably harder to pick meaning out of any decompilation of
said bytecode) - often used in J2ME projects to reduce download size

Chris Uppal 02-06-2007 05:19 PM

Re: programming styles
 
John T wrote:

[about "obfuctation"]
> Is there a definition which is more
> applicable to Java or is the general "make it hard to understand"
> concise enough?


That's pretty close. The term gains a couple of small extra shades of meaning
in a Java context, though.

One shade is inherited from more general programming terminology, where
"obfuscate" tends to suggest a /deliberate/ (wilful, playful, or malicious)
attempt to obscure the meaning of some bit of code.

Another shade comes from the fact that Java is translated into, and delivered
as, rather easy-to-understand bytecode. So some people see a need for
"obfuscators" which mangle that bytecode in an attempt to hide its meaning and
structure from those who might seek to discover it.

-- chris




All times are GMT. The time now is 05:21 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.