Site Sponsors:
PHP EzLog? 
I am teaching a class on Advanced PHP today. Was surprised at how much we all enjoyed a simple logging demonstration:

* Just ezlog a message to a file.
* @author profnagy
class logfile {

var $defaultFile = 'default.log';

public function open($file) {
$rev = strrev($file);
if (strpos($rev, 'gol.') != 0)
$this->defaultFile = $file . '.log';
$this->defaultFile = $file;
$br = file_exists($this->defaultFile);
return $br;

public function write($message) {
$now = date('Y-m-d H:i:s', time());
$line = "$now\t$message\n";
$result = file_put_contents($this->defaultFile, $line, FILE_APPEND | LOCK_EX);
if ($result === false)
return false;
return true;

public function remove() {
return unlink($this->defaultFile);


The example succinctly demonstrates using PHP dates, time, file I/O, locking, strings... and a little bit more. (i.e If you ever went looking for a Java-Style "endsWith()" in PHP, then consider the fast & easy use of strrev() in the above. Can be logically the same as a "startsWith" in the C/C++/PHP/Standard Lib/PHP Core.)

So if you are just getting into the more advanced features of PHP (or, if you enjoy seeing the spirit of the Standard C Library in use!), then you might enjoy playing with the above PHP Class.

By way of a bonus, it looks and smells a lot like the RFC Log Date & Time format I used for my Open Source / Skype's C/C++ (.ezlog) Legacy.

Time-tested & ready for production.



[ view entry ] ( 9522 views )   |  permalink  |  related link
UML & Hadoop 

What the "H"?

I first bumped into Hadoop in 2010.

While Consulting at the Electronic Proving Ground (EPG) as the Technical Sections Leader, our section was exploring ways to digest the the terabytes of data captured from a typical battlefield. Simulation.

While our flagship product (RICS) had no problem faithfully logging everything from sessions & phone calls to pictures, the SQL Database-bound post-processing could take days. -Far too much time when troops were wanting in the wings to see the KML. Something had to be done to speed things up.

Big Data?

Well, after driving my truck around Fort Huachuca, harvesting the KML for the Google Map proved to be the easy part. -What was daunting at the time was that "T" in terrabye... -Almost as taunting as the "P" in petabyte sounds today! (Got hardware? --Then Hadoop can tackle both 'P' & 'T' ...)


This story had a happy ending... But I would have to shoot BOTH of us if I told anyone why ;-)

Recollecting the challenge I had to host a Hadoop VM ... let alone 50 ... on the racks, I was happy when a colleague of mine asked me to train a his 2013 students on Hadoop. Why? Because - while named for a toy elephant, many believe that wresting a "do-oop" pun out of the mascot's name would make for an extremely accurate pun. HadOOP.



Resolving to make our training for Hadoop a lot more OOP-ey, today I cracked out our favourite editor for a little UML Action. --I wanted to share the ease of the chore, as well as some of the results, with you.

After a few hours tinkering, it seems that we could get NetBeans to generate diagrams, but the UML Feature is decidedly no longer ready for prime time. We decided to use Eclipse, instead.

Today we also downloaded & played with JDeveloper’s UML feature set. A recommended experience!



[ view entry ] ( 1715 views )   |  permalink  |  related link
Dot-Bomb Developer Woes? 
Those of us who have been writing software for any length of time are becoming distressed by the army of - what seems to be increasingly - blissfully ignorant, if not implicitly arrogant - software maintainers.

Harsh Words?

Indeed, from completely alienating decade-long users from even wanting to touch things like the new Microsoft Word (ignorant - ever heard of Microsoft’s CUA guidelines?), to completely breaking our code & understanding of how a framework works (arrogant - do they think that the folks who originally designed it were stupid?), the prognosis for an egalitarian future looks about as short as the tenure that accompanies many of our maintenance woes.


Such were my thoughts as I set my hand toward updating my electronic book reader recently. Wanting to simply replace a JTextArea in favour of some owner-drawn text, we blissfully set about creating our own JPanel to do just that.

Sadly, as I tested my new JPanel, "OMG" was the polite version of what raced thru my mind. The Panel drew. Then it blanked & went fascinatingly stupid on me.

What could be the problem?

Dues, & Dues Not?

Of course, for those of us who have paid our dues in learning the way of the paint(), validate() and update() paradigm, the recommended way of doing things TODAY in Java is to instead use paintComponent(). No problems there. Lots of folks have blogged about it: The default super.paint() quite reasonably manages the draw, as well as paintChildren(etc). Nice design.


The problem is that, even after replacing paint() with paintComponent(), that the flippin' thing still blanks... and blanks... and draws & blanks. --So much so that folks who encounter the problem are being humiliated by folks who thought they knew how painting in Java works.

The Source is Strong with Us

Not to worry though, while only about .01% of the blogs are keeping up with the latest (or even dare date their articles!) Java lets us get to the source of the problem. By chasing the implementation down to the new PaintManager, it became obvious that double-buffering was the culprit. (Image was grabbed before my render - Blank!)

Know Thy Google...

Now that I knew what to 'google for, we came across a nice little post or two on the subject. Push comes to shove, it seems that most folks are okay with the fact that RepaintManager will work so as to ignore any traditional way of using a canvas, paint() or paintComponent() call. I, as well as many others, are not. Blanking our content by default is not cool. It is arrogant.


Sure, the point was made on posts cerca & since 2008 that "the comment on the paint manager has a warning", but the effect is to enforce behaviour on folks who might want to move their legacies forward without reading up on every framework & feature change. In short, things did not blank by default.

Who cares about that GrayRect fix for JDK 6 ... We assume that a company is using tenured resources. (Tenured software develops know their legacies.) We presume that companies know that the best software developer are SMEs on their products well before they are allowed to write a line of code.

Ass u me

I suppose we are now learning never to assume: In the battle between cost, quality, and time, quality takes a back seat. That has ever been the case?

Yet because anyone with a compiler-in-hand is allowed to "save" their companies a few dollars for-the-year, companies should not, therefore, mind as folks decide to abandon their flagship projects. Products like Mic.sos.oft Office. --Look at the savings hiring cheap developers brings!

But Frameworks like Swing impact millions of products. The way it operates should be sacred. Indeed, as I turn a jaundiced eye toward Java ballyhooing their embedded prowess this month, anyone with any tenure simply laughs up their sleeves. Why? Because we know that things like Hadoop are insanely busy re-writing the PERFORMANCE CRITICAL PARTS of their ENTERPRISE Map/Reduce TOOLING in C/C++. (Smile: Only those tiny players - like Facebook, Google, Yahoo, and the DoD, use Hadoop. There are only so many rooms full of servers one should be willing to host: Little wonder they have the need for speed!) (Amazon loves C/C++)

One Map / Reduce Process per JVM = lots of wasted processing power. Indeed, like everyone else, I have my OWN inane theory on one origin of black holes: I believe that, whenever the amount of idle oscillating processing power exceeds the ambient life-force energy (or something :) in any given solar system, that an inevitable implosion results when any rogue dark, strange, uncle (or aunty) -matter migrates there-to. --So the next time you ponder the Horsehead Nebula (or perhaps a stray asteroid ever-drifting nearer our orb?), whimsically imagine a logo in the midst of each perplexity, all body-snatchingly hissing & pointing our way, effectively declaring "Java / Intel Inside"? ;-)

The Way of the Farce

Java Everywhere, indeed? -You want to put Java in a pacemaker with 4K memory? Wow!

Anyone out there understand the very language an operating system is written in (C/C++) ... and why? BECAUSE C/C++ IS FASTER THAN JAVA, FOLKS! That, after all, is WHY we have JNI!

But does anyone c-a-r-e?

Of course not. It is all about marketing today - let the developer & user hang.

For shame!

O, say ... can you .. C?

But when it comes time for ME to look into OUR set-top box, operating system, interstellar probe, weapons system, or pacemaker (!), I, like every other tenured software developer, wants to see a sticker that effectively says "C/C++ Inside."

In the embedded marketplace, all we have to do is to witness how quickly innovations like the BASIC STAMP platform lost their market to AVR / Arduino (even Radio Shack now carries Arduino!) to see how much better C/C++ is ... ! Would anyone even laughingly consider writing an operating system in 100% pure Java?

So call me prejudiced. Call me evil. Call me a communist, liberal, or democrat... but we must believe that part of being a professional is to know the right tool, for the right job.

Conversely, part of being a neophyte is to do well to (1) learn how to use a hammer, but then to do poorly & try to (2) turn everything into a nail. That is just being lazy. (i.e. Be careful who you call "D-e-m-o-c-r-a-t"?! ;-)


Okay - I got that our of my system (pun intended?) Everyone knows I love Java. I also love the way Obama was allowed to destroy the financial future of our nation. I also cherish the fact that both Oracle & Obama still think that what they have done is right. (I voted for the other guy :) Smart is what smart does?

So while far from being the most efficient implementation, and completely for educational purposes, here is how I solved the blinking text (or anything else you might want to draw!) problem in Java:

public void paintComponent(Graphics gr) {
if (manager == null) {
manager = RepaintManager.currentManager(this);

Now it works the way it did before all of those wonderful developers at Sun (ahem) forced their RepaintManager on U.S.



[ view entry ] ( 3114 views )   |  permalink  |  related link

<<First <Back | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | Next> Last>>