21 December 2006

Bitwise Tricks and Techniques

Dr. Knuth has released a new version Pre-Fascicle from his famous TAOCP called Bitwise Tricks and Techniques.
Please, go to http://www-cs-staff.stanford.edu/~knuth/news.html to download the postscript, also can be found an update to:
* Pre-Fascicle 0b: Boolean Basics (version of 20 Dec 2006)
* Pre-Fascicle 0c: Boolean Evaluation (version of 20 Dec 2006)
As usual it’s a important collection of many paper, books, articles retrieved through years by Donald Knuth and includes many work by himself (also asking if someone has done some research before to give correct acknowledge).

07 December 2006

XML + RegExp = Relax NG

Although it’s an “old” definition for validation of XML, now Relax NG is being considered to integrated inside Sun development mentioned by: Tim Bray. With this has a new revival interest on it.
We can see the beauty of simplicity on this project:
In science, strong theories tend to be simple, yet have almost infinite potential for complexity in application. RELAX NG is, because of its simplicity, one of those theories that is easy to explain, easy to implement, and generic and flexible enough to meet the most stringent requirements.
Eric van der Vlist, RELAX NG, O’Reilly ,2003.
more information can be found at: http://relaxng.org and its most important implementations at the moment in Java are Jing and The Sun Multi-Schema XML Validator (MSV).

22 November 2006

Balanced Design

Like most thing in life we have to choose, become, behave in a balanced way. Always there are consequences opting an extremity. Similar to Statistics where it can be shown in a graph like the Gaussian Distribution:

This also can be seen in language programming (i.e. the level of encapsulation, factorization, etc.) and even in design. The classic book Design Patterns from GoF identifies 23 patterns cataloging them under 3 classifications (creational, structural, behavioral).

The level, granularity and quantity you use them depends on several factor, nevertheless it is not advisable apply to used all of them at once, like in the following interview Eric makes mention of a similar case.

Do not start immediately throwing patterns into a design, but use them as you go and understand more of the problem. Because of this I really like to use patterns after the fact, refactoring to patterns. One comment I saw in a news group just after patterns started to become more popular was someone claiming that in a particular program they tried to use all 23 GoF patterns. They said they had failed, because they were only able to use 20. They hoped the client would call them again to come back again so maybe they could squeeze in the other 3.

Trying to use all the patterns is a bad thing, because you will end up with synthetic designs—speculative designs that have flexibility that no one needs. These days software is too complex. We can’t afford to speculate what else it should do. We need to really focus on what it needs. That’s why I like refactoring to patterns. People should learn that when they have a particular kind of problem or code smell, as people call it these days, they can go to their patterns toolbox to find a solution.

How to Use Design Patterns A Conversation with Erich Gamma,
http://www.artima.com/lejava/articles/gammadp.html

From Ajax in Action book called this symptom (or condition) of overused of patterns as paralysis by analysis.

We can conclude, First try to make your first effort coding (of course there is analysis and design before, but we are stand at development and trying to refactor the solution) unless you have already the experience to use a known pattern to a particular problem then try to use some pattern from the catalog, and use them carefully, remember the first and final idea is to make things more simple, elegant and not chaos.

19 October 2006

Knuth Selected Papers

Dr Knuth has been publishing compilations of his papers in different subject he is involved, as wide as literate programming until recreational mathematics, This is a good compendium of his work.
the list is:
at his page you can find more information.
http://www-cs-faculty.stanford.edu/~knuth/selected.html

08 September 2006

Eclipse JSP Styles

I have been seen how Eclipse IDE has been growing by the community, sometimes with huge improvement for code donation, however there are some features left that can be found in the plug-ins, but not always, by instance in JSP editing (inherated form Lomboz plug-in) it use to be yellow all the tags from Struts/JSTL/etc. and leaving blank the rest helping to see more easily the JSP/Tag code from Javascript/HTML.

This works great for Struts framework pages, where coexistence between HTML and Struts/JSTL Tags is important, but now working with JSF it is not for much help because here (at least for a average scenario) our code doesn’t contain traditional HTML tags (or a few tags) only JSF-HTML tags, so the final rendering it’s only a yellow stain, thus we better change under:

Window->Preferences->Web and XML->JSP Files->JSP Styles

the “Restore Defaults” and has a better looking. nevertheless if we open a struts projec again we loose this yellow easy to see feature, just right here we can change outside the IDE itself the following file

org.eclipse.jst.jsp.ui.prefs

which can be found at

.metadata/.plugins/org.eclipse.core.runtime/.settings

inside can be seeing verbatim the codes of the colors:

#Fri Sep 30 15:10:35 VET 2005
tagBorder=\#008080 | \#ffff80 | false
tagAttributeName=\#7f007f | \#ffff80 | false
tagName=\#3f7f7f | \#ffff80 | false
org.eclipse.wst.sse.ui.custom_templates=\r\n
SCRIPT_AREA_BORDER=\#bf5f3f | \#ffff80 | false
tagAttributeValue=\#2a00ff | \#ffff80 | false
jsp_content=null | \#ffff80 | false
eclipse.preferences.version=1
commentBorder=\#3f5fbf | \#ffff80 | false
commentText=\#3f5fbf | \#ffff80 | false

the .metadata directory can be found in your workspace -your workspace by default is under eclipse directory, however is a good practice is to have it in a different place (and your plug-ins too).

04 August 2006

Fractal Pop Beverage

although today fractal are used commonly in graphics design, television and any graphics interpretation, seeing spectacular images from http://ziza.ru/2006/05/24/otlichnaya-podborka.html, this image in particular still takes my attention for using in a very good way a fractal sensation :)
(please see the original image, there you can appreciate what I mean).

I don’t know which tool the artist used however you can do interesting artwork with: ultra fractal (shareware) and with povray also (but this last program is not fractal oriented as the first one and it uses a script language).

27 June 2006

The Art of Computer Programming in Boolean

Dr. Donald Knuth, still is working in draft of TAOCP, right now you can find the last drafts which regards basic and advanced boolean studies. Still I’m waiting for the 7.2.2 chapter dealing with backtracking in general (this is mentioned in prefaces of Knuth’s drafts).
Meanwhile you can read a joyful article from Stanford Magazine: Love at First Byte by Kara Platoni.

20 June 2006

Pandigital Magic Square

Although this is an old solution, I’m publishing here because it has been appeared in several books from Cliff Pickover.

Below it’s my first solution and then a better one found by Rodolfo Kurchan and I proved it with an exhaustive search and finding more pandigital magic squares:

I found a smaller solution to your magic square with pandigital numbers, which appeared at Journal of Recreational Mathematics issue 28

1034786295 1035687294 1024796385 1025697384
1024697385 1025796384 1034687295 1035786294
1035697284 1034796285 1025687394 1024786395
1025786394 1024687395 1035796284 1034697285

As you can see the sum is 4120967358

Later Rodolfo Kurchan found:

Pandigital magic sum = 4120736958. He says that German Gonzalez-Morris told him that this was now the smallest (just for the 4×4 case, as you will learn in short).

German Gonzalez-Morris added (May 2006) that he made a computer program and found an smaller pandigital sum (4120967358) then Rodolfo (by hand) found the smallest sum (4120736958), finally German found (and prove by exhaustive search) all smallest sums beginning from: 4120736958, 4120953678, 4120967358, 4127360958, 4129536078, …

1034728695 1035628794 1024739685 1025639784
1024639785 1025739684 1034628795 1035728694
1035629784 1034729685 1025638794 1024738695
1025738694 1024638795 1035729684 1034629785

more information can be found at: http://www.primepuzzles.net/puzzles/puzz_249.htm

http://www.mathforum.org/kb/thread.jspa?forumID=265&threadID=611491&messageID=1787982#1787982

http://mathforum.org/kb/message.jspa?messageID=1787984&tstart=0

30 May 2006

Month-Text Ordering

Reading Dr. Dobbs’s magazine December 2005 issue in the article Month-Text Ordering, appears the following phrase:

first we analyze QSortAlgorithm Class:

while( ( lo <> lo0 ) && (test.compareTo (a[hi], mid) > 0))

As we can see it’s unnecessary the amount of the number, only its sign, therefore it doesn’t affect at all the final result. thus we can improve the simpleANCompareTo method.

We can improved a little more taking out the IntParser method and return the difference of length or the compareTo method from String Class instead.

finally the new code in MonthOrder.java may be:


//Start New Code
if (e1!=e2) test = e1-e2;
else test = name1.substring (n1, e1).compareTo(name2.substring (n2, e2));

if (test != 0) return test; //End New Code

Diff file is:


87,99c89,94 < val1 =" Integer.parseInt" val1 =" -1;" val2 =" Integer.parseInt" val2 =" -1;" test =" val1"> > if (e1!=e2) test = e1-e2; > else test = name1.substring (n1, e1).compareTo(name2.substring (n2, e2)); > > > if (test != 0) 100a96 > 124a121,123 > > >


of course this new change is to avoid the limitation that integer range has (2^31-1), in this example it doesn’t matter the size because we are comparing years (yes, probably in the year 2147483647 this code will be obsolete :) ).

Perhaps it can be implemented something similar to the final version of numeric alphanumeric of October 2000 issue.

I have to appreciate David Wincelberg for sharing with us this simple and beautiful solution.

The original magazine’s source code can be obtained at:
ftp://66.77.27.238/sourcecode/ddj/2005/0512.zip

01 April 2006

Hello World!

This is the very first post, here will appear Programming, Math, Gaming and other issues… coming soon.

Here you can find thoughts about my hobbies and sometimes seriuos things from my job. Math, Programming, Design.

--This is my new blog after having problems with my webhosting...

My Blog List

Blog Archive

There was an error in this gadget

Disclaimer

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.