Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
User Journal

Journal Journal: Programming puzzle 12

Write a "Hello world" program, without using a semicolon, in:
  1. C (puzzle taken from here) -- takes a while if you've switched your mentality from C to Java (is that a hint or what?)
  2. Java (a bit more thought and knowledge of language is necessary)

Comments below present the correct solutions, respectively, by Fuckhead Sr. and Fuckhead Jr., with guest commentary by FucksHisMomInTheAssCauseHerPussy'sFilledWithPus... And to think that all three of them is one and the same incestuous redneck schizo... wow...

User Journal

Journal Journal: While waiting for enums in Java

catamount suggested the following trick:

public static final int ZERO = 0x0;
private static int enum = ZERO;
public static final int FIRST = ++enum;
public static final int SECOND = ++enum;
...

User Journal

Journal Journal: Java sizeof

"Memory matters" article in Javadoc Q&A by Tony Sintes (referring to FAQ Question of the Week No. 107 of JDC) suggests a way using Runtime.getRuntime().totalMemory().

I suggest another way of determining object's size:

public static long sizeof(Object pObj) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(pObj);
byte[] bytes = baos.toByteArray();
oos.close();
baos.close();
return bytes.length;
} catch (IOException ioe) {
return -1;
}
}

User Journal

Journal Journal: From the "no shit" department...

A Microsoftie blogs (emphasis mine):

I'm a Microsoft guy, so reading news about the spread of Linux is often times disheartening. [...] Linux advocates will go to no end to find new and interesting ways to position the language, installing it on anything with a microprocessor.

Say what?

User Journal

Journal Journal: From the "hobgoblin-of-little-minds" department

So I download a VSS plugin for Eclipse. The ZIP archive is entitled org.vssplugin_1.5.0- 3.0-M8 -compability.zip. Yeah, 3.0-M8 , just what I wanted. But the Readme.html file (which has a <TITLE> tag reading"VSS Plugin version 1.5 for Eclipse 2.1 ") includes the following statements (ellipsis and emphasis mine):

1 Getting Started

This plug in supports Eclipse release 3.0M4 .

...

1.1 Prerequisites

Eclipse release 3.0 M6 for Windows 98/ME/2000/XP.

The truth is, probably, somewhere in between...

User Journal

Journal Journal: Java exception trick 3

This trick is due to catamount, an excellent programmer with whom I have an honor of currently working .

Often one does not want to declare exceptions to be thrown. An example that comes to mind is a use of a Visitor pattern, because one may want to declare a common interface specifying a visitor (that the accepting classes have to accept), but the differing implementations of visitors may have quite differing errors (and having some sort of VisitorException means that the exceptions are then classified by who throws it, and "not so hot on why".

However, along the call stack, some callers may be aware of this. So what one does is wrap an Exception in a RuntimeException, catches the latter in the code that's aware of it, and unwraps it.

Cute, eh...

User Journal

Journal Journal: Java tautologies

Ok, so you can have abstract as a method modifier in a Java interface, though it's redundant, as they're implicitly abstract. But I just accidentally discovered that an interface itself can be defined explicitly abstract. Why, Mr.Anderson?
User Journal

Journal Journal: Feature: cut-and-paste flexibility

WIBNI (wouldn't it be nice if) one could:
  • ...switch, at will, between MS Windows style way (highlight, then perform copy action, saving the result to clipboard, then pasting) and X way (highlight copies, some other action -- like mouse middle button -- pastes, with no action required to save -- "copy" -- the highlighted portion, and thus the next highlighting replaces the previous contents of the clipboard).
  • ...switch between highlighting along the text flow (as in, for example, Notepad) or "rectangular" region highlighting (as in MS command window).
  • ...highlight at once (and copy) non-consecutive regions of text (pasting them, then, consecutively, or one-by-one, numbered in order, somehow).
  • ...additionally, define their own patterns of the copy-paste procedure.

For depending on what I am doing, I find that a particular way is more useful in one situation, and another one in another.

User Journal

Journal Journal: Hotkeys for portables (and other consumer electronics)

(Also submitted to ShouldExist.org)

This is especially good for things one uses often and "rapidly" - by the latter I mean things for which the utility increases exponentially (more or less) as the time-to-action (between point A: decision to use and point B: using it in a particular mode) decreases (By the way, is there an official term that UI specialists use for this? I'd think that there should be...)

An example of what I mean are cameras and cell-phones. For example, often, I want to be able to quickly turn off a cell phone ringer (not to turn off the phone, though!) when I realize I forgot to do it in the middle of a movie; or I want to go to a particular often-used setting of a digital camera to do a shot that will soon disappear (say, I want to very rapidly set the "film speed" and the exposure compensation to a particular one, knowing that, on average, given the nature of the shots I make, it would yield better results than either automatic setting or going through the menus; or, even, to rapidly go to the UI dialog responsible for setting one of these parameters, instead of, again, iterating through some menus).

This is not the case, for example, with things such as a DVD player -- if I spend another minute or two playing around with it, it won't spoil the movie I am about to watch.

It would be nice, then, to include a feature to program a hotkey in your own way, to be able to set the often-used needed mode for the device in fraction of a second. A few buttons should be provided for that express purpose. The time spent on learning such functionality is not a problem.

Java

Journal Journal: Java meets Russian lore

java.lang.NullPointerException
              at Needle.break(Needle.java:27)
              at Egg.getNeedle(Egg.java:22)
              at Duck.getEgg(Duck.java:24)
              at Hare.getDuck(Hare.java:34)
              at Chest.getHare(Chest.java:55)
              at Oak.getChest(Oak.java:34)

P.S. Chest.getHair() pun was already claimed...

User Journal

Journal Journal: New term proposed: Undersight

Undersight, n. (term coined by BOBHYTAPb) -- as opposed to oversight (2nd meaning) - an approach to design that dogmatically emphasizes flexibility/extensibility, often to absurd extremes. As a knee-jerk reaction against problem-causing assumptions such as "storing the year as 2 digits", this approach rejects all assumptions it can see, even those that seem immanent. Everything, it claims, must be configurable or in other ways "easily" changed later, even at the cost of the complexity of current development. The cases U. provides for later mostly fail to occur.

Here are some examples of undersight:

  • public final static char PACKAGE_SEPARATOR = '.';
  • More coming soon...
User Journal

Journal Journal: Desired documentation tags

(Having faced reality, it's better to ask for better javadoc tags than to think of literate programming. And so, I think the following Javadoc tags are in order:
  • @pre - Pre-condition
  • @post - Post-condition -- see above
  • @inv[ariant] - Invariant -- see above
  • @todo - Todo - this would involve changing the idea of the doc. tool to have different displays for project developers and for those using the project. But for now, it could be common, at least before figuring out who should be able to see this.

Javadoc generates HTML, and so it's nice to have the ability to put links, etc., in the documentation. Howeve, that makes it harder to read in the source. What would be the solution here, hmmm?

Slashdot Top Deals

Suggest you just sit there and wait till life gets easier.

Working...